首页 > 其他分享 >k8s组件之Etcd

k8s组件之Etcd

时间:2024-07-04 21:32:09浏览次数:6  
标签:Etcd etcdctl member role user etcd 组件 ETCD k8s

一、ectd数据库介绍

  etcd 是 CoreOS 团队于2013年6月发起的开源项目, 是一种开源的分布式键值存储库,用于保存和管理分布式系统保持运行所需的关键信息。 etcd 基于 Raft 共识算法而构建,可确保集群中所有节点之间的数据存储一致性。

  etcd 采用全新的设计,具有以下特性:

  • 完全复制:etcd 集群中的每个节点都可以访问完整的数据存储库。
  • 高度可用:etcd 被设计为没有单点故障,并且可以稳定地容忍硬件故障和网络分区。
  • 完全一致:每次数据“读取”都会返回所有集群中最新的“写入”数据。
  • 运行迅速:etcd 的基准测试速度为每秒 10,000 次写入。
  • 安全可靠:etcd 支持自动传输层安全性 (TLS) 和可选的安全套接字层 (SSL) 客户机证书认证。 由于 etcd 存储重要且高度敏感的配置数据,因此管理员应在部署中实施基于角色的访问控制,并确保与 etcd 交互的团队成员只具有执行其工作所需的最低级别的访问权限。
  • 操作简单:任何应用(从简单的 Web 应用到 Kubernetes 等高度复杂的容器编排引擎)都可以使用标准的 HTTP/JSON 工具在 etcd 中读写数据。

  由于 etcd 的性能在很大程度上取决于存储磁盘的速度,因此强烈建议在 etcd 环境中使用 SSD。

  etcd 是 Kubernetes 的核心组件之一,充当主要键值存储库,用于创建可正常运行且具有容错能力的 Kubernetes 集群。 Kubernetes API 服务器会将每个集群的状态数据都存储在 etcd 中。 Kubernetes 使用 etcd 的“观察”功能来监控这些数据,并在发生变化时自行重新配置。 “观察”功能会存储代表集群实际状态和理想状态的值,并且可以在这两种状态不同时作出响应。

  etcd数据库架构分为4个部分:

  • HTTP Server: 处理用户API请求以及其它etcd节点的同步与心跳请求。
  • Store:处理etcd事务,包括数据索引、节点状态变更、监控与反馈、事件处理与执行等等,是etcd对用户提供的大多数API功能的具体实现。
  • Raft:Raft强一致性算法的具体实现,是etcd的核心。
  • WAL:是etcd的数据存储方式。除了在内存中存有所有数据的状态以及节点的索引以外,etcd就通过WAL进行持久化存储。

二、etcd数据库安装和使用

  1、etcd安装:etcd数据库可以通过源码和二进制文件方式安装,详细文档可以查看https://etcd.io/docs/v3.5/install/,二进制方式安装可以从https://github.com/etcd-io/etcd/releases/下载合适的版本,解压文件生成一个包含二进制文件的目录,将目录添加到环境变量。输入 “etcd --version”可以查看etcd数据库的版本信息。

  2、etcd配置:etcd默认配置文件/etc/etcd/etcd.conf内容如下:

  • ETCD_NAME:节点名称,必须唯一;
  • ETCD_DATA_DIR:etcd的数据存放目录;
  • ETCD_LISTEN_PEER_URLS:用于监听其他节点的url;
  • ETCD_LISTEN_CLIENT_URLS:用于和客户端通信的url;
  • ETCD_ADVERTISE_CLIENT_URLS:建议本节点和客户端通信使用的url;
  • ETCD_INITIAL_CLUSTER:集群中所有节点的信息;
  • ETCD_INITIAL_CLUSTER_TOKEN:创建集群的token,这个值每个集群均相同;
  • ETCD_INITIAL_CLUSTER_STATE:初始集群状态;
  • ETCD_INITIAL_ADVERTISE_PEER_URLS:建议本节点用于和其他节点之间通信的url;
# cat >> /etc/etcd/etcd.conf << EOF
ETCD_NAME="etcd01"
ETCD_DATA_DIR="/var/lib/etcd"
ETCD_LISTEN_PEER_URLS="http://10.10.1.2:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.10.1.2:2380"
ETCD_LISTEN_CLIENT_URLS="http://10.10.1.2:2379,http://127.0.0.1:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://10.10.1.2:2379"
ETCD_INITIAL_CLUSTER="etcd01=http://10.10.1.2:2380,etcd02=http://10.10.1.3:2380,etcd03=http://10.10.1.4:2380"
ETCD_INITIAL_CLUSTER_TOKEN="xxxx"
ETCD_INITIAL_CLUSTER_STATE="new"
EOF

  3、交互:与etcd数据库进行交互通常使用etcdctl命令行工具,该工具在安装etcd时默认安装,etcdctl常见的 语法命令如下:

etcdctl        get                     Gets the key or a range of keys
etcdctl        put                     Puts the given key into the store
etcdctl        del                     Removes the specified key or range of keys [key, range_end)
etcdctl        txn                     Txn processes all the requests in one transaction
etcdctl        compaction              Compacts the event history in etcd
etcdctl        alarm disarm            Disarms all alarms
etcdctl        alarm list              Lists all alarms
etcdctl        defrag                  Defragments the storage of the etcd members with given endpoints
etcdctl        endpoint health         Checks the healthiness of endpoints specified in `--endpoints` flag
etcdctl        endpoint status         Prints out the status of endpoints specified in `--endpoints` flag
etcdctl        endpoint hashkv         Prints the KV history hash for each endpoint in --endpoints
etcdctl        move-leader             Transfers leadership to another etcd cluster member.
etcdctl        watch                   Watches events stream on keys or prefixes
etcdctl        version                 Prints the version of etcdctl
etcdctl        lease grant             Creates leases
etcdctl        lease revoke            Revokes leases
etcdctl        lease timetolive        Get lease information
etcdctl        lease list              List all active leases
etcdctl        lease keep-alive        Keeps leases alive (renew)
etcdctl        member add              Adds a member into the cluster
etcdctl        member remove           Removes a member from the cluster
etcdctl        member update           Updates a member in the cluster
etcdctl        member list             Lists all members in the cluster
etcdctl        snapshot save           Stores an etcd node backend snapshot to a given file
etcdctl        snapshot restore        Restores an etcd member snapshot to an etcd directory
etcdctl        snapshot status         Gets backend snapshot status of a given file
etcdctl        make-mirror             Makes a mirror at the destination etcd cluster
etcdctl        migrate                 Migrates keys in a v2 store to a mvcc store
etcdctl        lock                    Acquires a named lock
etcdctl        elect                   Observes and participates in leader election
etcdctl        auth enable             Enables authentication
etcdctl        auth disable            Disables authentication
etcdctl        user add                Adds a new user
etcdctl        user delete             Deletes a user
etcdctl        user get                Gets detailed information of a user
etcdctl        user list               Lists all users
etcdctl        user passwd             Changes password of user
etcdctl        user grant-role         Grants a role to a user
etcdctl        user revoke-role        Revokes a role from a user
etcdctl        role add                Adds a new role
etcdctl        role delete             Deletes a role
etcdctl        role get                Gets detailed information of a role
etcdctl        role list               Lists all roles
etcdctl        role grant-permission   Grants a key to a role
etcdctl        role revoke-permission  Revokes a key from a role
etcdctl        check perf              Check the performance of the etcd cluster
etcdctl        help                    Help about any command

   4、在服务器上安装Etcd注意的事项: 

  • 关闭selinux子系统;
  • 关闭firewalld或开放需要使用的端口;
  • 关闭swap内存交换;
  • 配置yum最新源;

 

标签:Etcd,etcdctl,member,role,user,etcd,组件,ETCD,k8s
From: https://www.cnblogs.com/zqhIndex/p/18283676

相关文章

  • HarmonyOS开发实战系列:网络连接绑定到应用规范-Web组件
    1.网络类型简介移动设备一般都具备移动网络和无线WIFI的连接能力,有些还可以接入有线以太网,这些网络可以根据需要随时切换。鸿蒙APP可以自动适应上述的网络,一般来说,会优先使用WIFI或者有线以太网,移动网络因为要收费,不会首选使用。但是在某些特殊情形下,可能要求必须使用某一种......
  • React组件性能优化中如何避免频繁更新?
    在React应用中,组件的频繁更新可能会导致性能问题,因为每次更新都涉及到重新渲染和布局计算。为了提升性能,避免不必要的更新是非常关键的。以下是一些优化React组件性能,避免频繁更新的策略:使用PureComponent或React.memoPureComponent和React.memo都会在组件接收新属性或状......
  • K8s
    kubernetes,简称K8s,是用8代替名字中间的8个字符“ubernete”而成的缩写。是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes的目标是让部署容器化的应用简单并且高效(powerful),Kubernetes提供了应用部署,规划,更新,维护的一种机制。传统的应用部署方式是通过插件或脚本......
  • k8s实战 ---- pod 基础
    如果你对k8s还不了解,可以看下前文k8s实战1----初识    (https://www.cnblogs.com/jilodream/p/18245222)什么是pod,pod在英文中是豌豆荚、分离仓、集装箱的意思。在k8s中,pod就是融合一堆容器实例的一个大容器(称之为集合更贴切)。K8s所能部署的最小单元就是容器,就是pod,一......
  • vue3父组件 调用子组件 方法
    父组件:通过ref获取子组件实例<template><divstyle="text-align:center"><button@click="callChildMethod">点击获取子组件数据</button><div>获取到子组件的数据如下:<div>{{childData}}</div></div&......
  • 对于浏览器请求接口限制,是否有必要开发一套请求任务管理器组件,自主的去控制请求的并发
    在现代Web开发中,浏览器对同时发起的网络请求确实存在一定的限制,这个限制通常与浏览器的安全性和性能优化有关。不同浏览器对最大并发连接数有不同的默认设置,例如,Chrome和Firefox大致允许每个域名上同时有6到8个TCP连接,而IE可能更低。当超过这个限制时,额外的请求会被排队等待,直......
  • K8S学习教程(二):在 PetaExpress KubeSphere容器平台部署高可用 Redis 集群
    前言Redis是在开发过程中经常用到的缓存中间件,为了考虑在生产环境中稳定性和高可用,Redis通常采用集群模式的部署方式。在制定Redis集群的部署策略时,常规部署在虚拟机上的方式配置繁琐并且需要手动重启节点,相较之下,使用PetaExpress提供的Kubernetes(k8s)服务进行Redis集......
  • 详解Web应用安全系列(7)使用具有已知漏洞的组件
    使用具有已知漏洞的组件,这种安全漏洞普遍存在,基于组件开发的模式使得多数开发团队根本不了解其应用或API中使用的组件,更谈不上及时更新这些组件了。下面就分别以.NET和Java各分享一个案例。.NET案例:XmlSerializer反序列化漏洞案例描述在.NET框架中,XmlSerializer类是一个常......
  • vue3 父组件【属性】传值给子组件【props】接收
     父组件文件:parentcomponent.vue子组件文件:childcomponent.vue传普通值传动态值传对象传数组<!--父组件--><template>   <h1>IamParentComponent</h1>   <ChildComponentmsg="nice"/>  </template><scriptsetup>   importC......
  • VCL界面组件DevExpress VCL v24.1 - 发布全新的矢量主题
    DevExpressVCL是DevExpress公司旗下最老牌的用户界面套包,所包含的控件有:数据录入、图表、数据分析、导航、布局等。该控件能帮助您创建优异的用户体验,提供高影响力的业务解决方案,并利用您现有的VCL技能为未来构建下一代应用程序。DevExpressVCLv24.1已于日前正式发布,新版本官......