k8s集群添加新得node节点

  • 2020 年 10 月 16 日
  • 笔记

服务端操作:

方法一:

获取masterjoin token

kubeadm token create –print-join-command

 

重新加入节点 

kubeadm join 192.168.1.7:6443 –token iweubu.ebjsywhlaklmgjep     –discovery-token-ca-cert-hash sha256:f03b27e002e77fcec510e057385ce382c02171b7f28d71ac95d8ac0f7c7330b1

 

方法二:

[root@k8s-master ~]# kubeadm token create

yi55aa.kiu0nxc47kn0t56r

 

先执行:

[root@k8s-master ~]#  openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null |  openssl dgst -sha256 -hex | sed ‘s/^.* //’

ea7d2db27a987375034f8262be9f94b004a96ddcb5a22b6d6b7186aa8ba97b3f

 

客户端操作:

[root@k8s-node2 ~]# kubeadm join 192.168.1.7:6443 –token yi55aa.kiu0nxc47kn0t56r  –discovery-token-ca-cert-hash sha256:ea7d2db27a987375034f8262be9f94b004a96ddcb5a22b6d6b7186aa8ba97b3f

[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.15” 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] Activating the kubelet service

[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.

 

成功

在服务端打命令:

kubectl get node