1.添加node节点
[root@k8s-4 ~]# kubeadm join 192.168.191.30:6443 --token 6zs63l.4qmypshahrd3rt3x \ --discovery-token-ca-cert-hash sha256:851c0bf733fe1e9bff54af08b84e93635d5b9c6e047a68c694c613391e024185 W0323 15:58:36.010687 1427 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set. [preflight] Running pre-flight checks [preflight] Reading configuration from the cluster... [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml' [kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.17" ConfigMap in the kube-system namespace [kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml" [kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env" [kubelet-start] Starting the kubelet [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap... This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details. Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
2.执行成功后会在node节点的/etc/kubernetes目录下出创建kubelet.conf和pki等文件信息,同一节点再次加入时需要清空该目录下的文件信息
[root@k8s-4 kubernetes]# pwd /etc/kubernetes [root@k8s-4 kubernetes]# ll 总用量 4 -rw-------. 1 root root 1855 3月 23 16:15 kubelet.conf drwxr-xr-x. 2 root root 6 3月 13 07:57 manifests # 集群启动时的组件配置文件 drwxr-xr-x. 2 root root 20 3月 23 16:16 pki
3.在master节点查看集群节点信息
[root@k8s-3 ~]# kubectl get node NAME STATUS ROLES AGE VERSION k8s-3 Ready master 44h v1.17.4 k8s-4 NotReady <none> 111s v1.17.4 # 等待几分钟后的信息 [root@k8s-3 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-3 Ready master 44h v1.17.4 k8s-4 Ready <none> 5m40s v1.17.4
4.设置node的角色
[root@k8s-3 ~]# kubectl label nodes k8s-4(节点名字) node-role.kubernetes.io/node= node/k8s-4 labeled [root@k8s-3 ~]# [root@k8s-3 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-3 Ready master 44h v1.17.4 k8s-4 Ready node 12m v1.17.4
5.先将节点设置为维护模式(k8s-4是节点名称)
[root@k8s-3 ~]# kubectl drain k8s-4 --delete-local-data --force --ignore-daemonsets node/k8s-4 node/k8s-4 cordoned node/k8s-4 cordoned node/k8s-4 drained node/k8s-4 drained [root@k8s-3 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-3 Ready master 45h v1.17.4 k8s-4 Ready,SchedulingDisabled node 43m v1.17.4 恢复节点状态 [root@k8s-3 ~]# kubectl uncordon k8s-4 node/k8s-4 uncordoned [root@k8s-3 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-3 Ready master 45h v1.17.4 k8s-4 Ready node 46m v1.17.4
6.删除k8s-4节点
[root@k8s-3 ~]# kubectl delete node k8s-4 node "k8s-4" deleted [root@k8s-3 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-3 Ready master 44h v1.17.4
注意事项:
1.node加入集群后的操作
扫描二维码关注公众号,回复:
10092644 查看本文章
一.新增一个kubectl文件和pki目录,
二.启动kubectl的进程,默认端口10250,同一节点再次加入时需要停止kubelet的进程
目前只有这些,后续有新发现在补充。