Add/Remove node to Kubernetes cluster
- Minion node pre-operation preparation
#关闭防火墙systemctl stop firewalld#禁止防火墙开机启动systemctl disable firewalld#检查selinuxgetenforceDisabled#端口检查
- Add node to the Kubernetes cluster
When the KUBEADM Init initialization operation is complete, the system finally gives the command to join the node to the cluster:kubeadm join 10.0.0.39:6443 --token 4g0p8w.w5p29ukwvitim2ti --discovery-token-ca-cert-hash sha256:21d0adbfcb409dca97e655641573b2ee51c77a212f194e20a307cb459e5f77c8
Note: This command must be kept good, because the late can not reproduce!!
Operation on Swarm1 (Minion Node):
kubeadm join 10.0.0.39:6443 --token 4g0p8w.w5p29ukwvitim2ti --discovery-token-ca-cert-hash sha256:21d0adbfcb409dca97e655641573b2ee51c77a212f194e20a307cb459e5f77c8
To operate on Swarm2 (Master):
kubectl get nodesNAME STATUS ROLES AGE VERSIONswarm1 Ready <none> 3h v1.10.0swarm2 Ready master 3h v1.10.0
Swarm1 join the cluster is very smooth!
- Removing node from the Kubernetes cluster
Execute on the master node:kubectl drain swarm1 --delete-local-data --force --ignore-daemonsetskubectl delete node swarm1
Execute on Node2:
kubeadm reset
- Add a problem with node
#Minion node has been in Notready state, such as:kubectl get nodesNAME STATUS ROLES AGE VERSIONswarm1 NotReady <none> 3h v1.10.0swarm2 Ready master 3h v1.10.0
#原因
(1) Start Kubelet, will pull the following two mirrors (gcr.io/**), because the celestial network generally can not turn the wall, can not pull successfully, so you have to find the two Docker image. Click images to download it yourself!
k8s.gcr.io/kube-proxy-amd64 v1.10.1 6e6237849607 3 weeks ago 97.1 MBk8s.gcr.io/pause-amd64 3.1 da86e6ba6ca1 4 months ago 742 kB
(2) The Kubernetes cluster, which is built using the Kubeadm tool, has been integrated with the security policy by default, so all files under the master node node/etc/kubernetes/pki are copied to the next copy of the Minion node directory. So on master node, execute:
scp /etc/kubernetes/pki/* [email protected]{minion-ip}:/etc/kubernetes/pki
Add/Remove node to Kubernetes cluster