kubernetes the add and delete node (kubeadm)

When using kubeadm installed, add and delete node ...

Add node

1, master token generated

[root@node-01 ~]# kubeadm token create --print-join-command
kubeadm join 172.19.8.250:8443 --token 83glhm.30nf8cih0q8960nu --discovery-token-ca-cert-hash sha256:30d13676940237d9c4f0c5c05e67cbeb58cc031f97e3515df27174e6cb777f60

2, the node node to be added to ensure kubelet, docker has started
every node of kubelet must go set cgroup-drive and swap closed boot option.
Note check /var/lib/kubelet/kubeadm-flags.env

[root@node-06 ~]# cat /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS=–cgroup-driver=systemd --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.1

3, docker docker-ce should be noted that the use of the file, if not create
[root @ the Node-06 ~] # CAT /etc/docker/daemon.json
{
"Exec-the opts": [ "native.cgroupdriver = systemd"] ,
"log-Driver": "JSON-File",
"log-the opts": {
"max-size": "100m"
},
"Storage-Driver": "overlay2",
"Storage-the opts": [
"overlay2 = to true .override_kernel_check "
]
}

4, close the swap, and logout / etc / fstab configuration information about the swap of
swapoff -a

5, start kubelet and Docker
[root @ the Node-06 ~] # systemctl Start kubelet
[root @ the Node-06 ~] # systemctl strart Docker

6, master node check whether to join
[root @ the Node-01 ~] # kubectl Nodes GET
NAME AGE VERSION the STATUS the ROLES
the Node-01 Ready Master 2d19h v1.14.1
the Node-02 Ready Master 2d19h v1.14.1
the Node-03 Ready Master 2d19h v1. 14.1
node-04 Ready 2d19h v1.14.1
node-05 Ready 2d19h v1.14.1
node 06 Ready-78s v1.14.1
If the display on the node is added successfully, but does not show up on the Master, use systemctl status on the node machine kubelet view the next service state, the inside of the status check, processed separately.

Delete node

1, before removing a node, first driven off the top of pod

kubectl drain node-06 --delete-local -data --force --ignore-daemonsets
case start node migration upper pod

Check node status is marked as non-scheduling node

[root@node-01 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
node-01 Ready master 2d19h v1.14.1
node-02 Ready master 2d18h v1.14.1
node-03 Ready master 2d18h v1.14.1
node-04 Ready 2d18h v1.14.1
node-05 Ready 2d18h v1.14.1
node-06 Ready,SchedulingDisabled 2d18h v1.14.1
最后删除节点

[root@node-01 ~]# kubectl delete node node-06
node "node-06” deleted

[root@node-01 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
node-01 Ready master 2d19h v1.14.1
node-02 Ready master 2d19h v1.14.1
node-03 Ready master 2d19h v1.14.1
node-04 Ready 2d18h v1.14.1
node-05 Ready 2d18h v1.14.1

发布了33 篇原创文章 · 获赞 0 · 访问量 3906

Guess you like

Origin blog.csdn.net/erhaiou2008/article/details/104110856