etcd添加新节点

第一步:etcd客户端执行
[root@k8s-master-1 ~]# etcdctl member add node180 https://109.105.1.180:2380
Added member named node180 with ID ead16f36d2aa4f03 to cluster
ETCD_NAME=“node180”
ETCD_INITIAL_CLUSTER=“k8s-ceph5=https://109.105.1.246:2380,node176=https: //109.105.1.176:2380,k8s-n2=https://109.105.1.208:2380,k8s-master-1=https://109.105.1.253:2380,k8s-master-2=https://109.105.1.254:2380,node180=https://109.105.1.180:2380”
ETCD_INITIAL_CLUSTER_STATE=“existing”
记住上面生成的参数,第二步使用
第二步:在节点执行
a.编辑/etc/etcd/etcd.config.yml
[root@node180 ~]# cat /etc/etcd/etcd.config.yml
name: ‘node180’
data-dir: /data/etcd
wal-dir: /data/etcd/wal
snapshot-count: 10000
heartbeat-interval: 100
election-timeout: 1000
quota-backend-bytes: 0
listen-peer-urls: ‘https://0.0.0.0:2380
listen-client-urls: ‘https://0.0.0.0:2379
max-snapshots: 5
max-wals: 5
cors:
initial-advertise-peer-urls: ‘https://109.105.1.180:2380
advertise-client-urls: ‘https://109.105.1.180:2379
discovery:
discovery-fallback: ‘proxy’
discovery-proxy:
discovery-srv:
initial-cluster: ‘k8s-ceph5=https://109.105.1.246:2380,node176=https://109.105.1.176:2380,k8s-n2=https://109.105.1.208:2380,k8s-master-1=https://109.105.1.253:2380,k8s-master-2=https://109.105.1.254:2380,node180=https://109.105.1.180:2380’
initial-cluster-token: ‘etcd-k8s-cluster’
initial-cluster-state: ‘existing’
strict-reconfig-check: false
enable-v2: true
enable-pprof: true
proxy: ‘off’
proxy-failure-wait: 5000
proxy-refresh-interval: 30000
proxy-dial-timeout: 1000
proxy-write-timeout: 5000
proxy-read-timeout: 0
client-transport-security:
ca-file: ‘/etc/etcd/ssl/etcd-ca.pem’
cert-file: ‘/etc/etcd/ssl/etcd.pem’
key-file: ‘/etc/etcd/ssl/etcd-key.pem’
client-cert-auth: true
trusted-ca-file: ‘/etc/etcd/ssl/etcd-ca.pem’
auto-tls: true
peer-transport-security:
ca-file: ‘/etc/etcd/ssl/etcd-ca.pem’
cert-file: ‘/etc/etcd/ssl/etcd.pem’
key-file: ‘/etc/etcd/ssl/etcd-key.pem’
peer-client-cert-auth: true
trusted-ca-file: ‘/etc/etcd/ssl/etcd-ca.pem’
auto-tls: true
debug: false
log-package-levels:
log-output: default
force-new-cluster: false
b.编辑/etc/kubernetes/manifests/etcd.yml
[root@node180 ~]# cat /etc/kubernetes/manifests/etcd.yml
apiVersion: v1
kind: Pod
metadata:
annotations:
scheduler.alpha.kubernetes.io/critical-pod: “”
labels:
component: etcd
tier: control-plane
name: etcd
namespace: kube-system
spec:
hostNetwork: true
containers:

  • name: etcd
    image: registry.bst-1.cns.bstjpc.com:5000/gcr.io/google_containers/etcd-amd64:3.1.13
    command:
    • etcd
    • –config-file=/etc/etcd/etcd.config.yml
      livenessProbe:
      failureThreshold: 8
      tcpSocket:
      port: 2379
      initialDelaySeconds: 15
      timeoutSeconds: 15
      volumeMounts:
    • mountPath: /etc/etcd/ssl
      name: etcd-certs
    • mountPath: /etc/etcd/etcd.config.yml
      name: etcd-conf
    • mountPath: /data/etcd
      name: data
      volumes:
  • hostPath:
    path: /etc/etcd/ssl
    type: DirectoryOrCreate
    name: etcd-certs
  • hostPath:
    path: /etc/etcd/etcd.config.yml
    name: etcd-conf
  • hostPath:
    path: /var/lib/etcd
    type: DirectoryOrCreate
    name: data
    第三步:加入完毕
    [root@k8s-master-1 manifests]# etcdctl member list
    4a8b48537d57efd: name=k8s-ceph5 peerURLs=https://109.105.1.246:2380 clientURLs=https://109.105.1.246:2379 isLeader=false
    fb619523b2a8125: name=node176 peerURLs=https://109.105.1.176:2380 clientURLs=https://109.105.1.176:2379 isLeader=false
    7b6ffda9f312baeb: name=k8s-master-1 peerURLs=https://109.105.1.253:2380 clientURLs=https://109.105.1.253:2379 isLeader=true
    9d93723536b3d72f: name=k8s-master-2 peerURLs=https://109.105.1.254:2380 clientURLs=https://109.105.1.254:2379 isLeader=false
    ead16f36d2aa4f03: name=node180 peerURLs=https://109.105.1.180:2380 clientURLs=https://109.105.1.180:2379 isLeader=false

猜你喜欢

转载自blog.csdn.net/lyf0327/article/details/89364151