集群的扩缩

集群编排变化

假设原来的 inventory.ini 内容如下:

# ## Configure 'ip' variable to bind kubernetes services on a
# ## different ip than the default iface
# ## We should set etcd_member_name for etcd cluster. The node that is not a etcd member do not need to set the value, or can set the empty string value.
[all]
k8s-1 ansible_host=172.17.8.101 ip=172.17.8.101 etcd_member_name=etcd1
k8s-2 ansible_host=172.17.8.102 ip=172.17.8.102 etcd_member_name=etcd2
k8s-3 ansible_host=172.17.8.103 ip=172.17.8.103 etcd_member_name=etcd3

# ## configure a bastion host if your nodes are not directly reachable
# bastion ansible_host=x.x.x.x ansible_user=some_user

[kube-master]
k8s-[1:2]

[etcd]
k8s-[1:3]

[kube-node]
k8s-[1:3]

[k8s-cluster:children]
kube-master
kube-node

# ## Hosts in group 'ceph' must be in group 'kube-node' too.
# nodes in this group will be labeled with 'ceph=true'
# If this group is not exist or empty, rook ceph will deploy to all kube nodes
[ceph]
k8s-[1:3]

[all:vars]
ansible_ssh_user=vagrant
ansible_user='vagrant'
ansible_ssh_private_key_file='/home/haibin/.vagrant.d/insecure_private_key'
kube_network_plugin=calico

机器增加并重新编排如下:

# ## Configure 'ip' variable to bind kubernetes services on a
# ## different ip than the default iface
# ## We should set etcd_member_name for etcd cluster. The node that is not a etcd member do not need to set the value, or can set the empty string value.
[all]
k8s-1 ansible_host=172.17.8.101 ip=172.17.8.101 etcd_member_name=etcd1
k8s-2 ansible_host=172.17.8.102 ip=172.17.8.102 etcd_member_name=etcd2
k8s-3 ansible_host=172.17.8.103 ip=172.17.8.103 etcd_member_name=etcd3
k8s-4 ansible_host=172.17.8.104 ip=172.17.8.104
k8s-5 ansible_host=172.17.8.105 ip=172.17.8.105
k8s-6 ansible_host=172.17.8.106 ip=172.17.8.106
k8s-7 ansible_host=172.17.8.107 ip=172.17.8.107
k8s-8 ansible_host=172.17.8.108 ip=172.17.8.108

# ## configure a bastion host if your nodes are not directly reachable
# bastion ansible_host=x.x.x.x ansible_user=some_user

[kube-master]
k8s-[1:3]

[etcd]
k8s-[1:3]

[kube-node]
k8s-[4:8]

[k8s-cluster:children]
kube-master
kube-node

# ## Hosts in group 'ceph' must be in group 'kube-node' too.
# nodes in this group will be labeled with 'ceph=true'
# If this group is not exist or empty, rook ceph will deploy to all kube nodes
[ceph]
k8s-[6:8]

[all:vars]
ansible_ssh_user=vagrant
ansible_user='vagrant'
ansible_ssh_private_key_file='/home/haibin/.vagrant.d/insecure_private_key'
kube_network_plugin=calico

你可以通过以下 playbook 完成集群扩展。

$ ansible-playbook 01-bootstrap.yml
$ ansible-playbook -b kubespray/scale.yml