博客园  :: 首页  :: 管理

首先对于node节点来说,有如下几点先决条件

1、基础环境的,这个与master节点一样

2、同样需要安装docker 和 k8s相关的软件,也是与master节点一样,包括docker的配置(必须)

 

接下来就是master节点使用kubeadm init命令进行初始化,当初始化完成后,如果一切正常、将会看到有如下一段

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.18.106.87:6443 --token 8iz44r.cxj5duahe37wsdgq \
        --discovery-token-ca-cert-hash sha256:08752ac13ae6f821c44abdf6eb1fa2481777b82d20335e4467829ac20b503e55

这里也即是说明,如果要加入一些 worker nodes 节点,可以使用root用户执行上面的 kubeadm join 命令即可, 有类似如下输出,即为成功

[root@k8s-node1 qq-5201351]# kubeadm join 192.18.106.87:6443 --token 8iz44r.cxj5duahe37wsdgq \
>         --discovery-token-ca-cert-hash sha256:08752ac13ae6f821c44abdf6eb1fa2481777b82d20335e4467829ac20b503e55
[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 -o yaml'
[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.

[root@k8s-node1 qq-5201351]# 

补充说明,当worker node 加入后,我们在worker节点上,可以看到也有自动有一些docker镜像了

[root@k8s-node1 ~]# docker images
REPOSITORY                                           TAG       IMAGE ID       CREATED         SIZE
registry.aliyuncs.com/google_containers/kube-proxy   v1.23.6   4c0375452406   12 months ago   112MB
registry.aliyuncs.com/google_containers/pause        3.6       6270bb605e12   20 months ago   683kB

而且此时,我们也就也可以在master节点上看到加入的node1机器了,笔者实验中,将node2也加入了、效果如下:

[root@k8s-master ~]# kubectl get nodes
NAME         STATUS     ROLES                  AGE     VERSION
k8s-master   NotReady   control-plane,master   7h53m   v1.23.6
k8s-node1    NotReady   <none>                 14m     v1.23.6
k8s-node2    NotReady   <none>                 12m     v1.23.6

至此,worker node 节点就成功加入了,但这里显示了NotReady,我们再通过如下kubectl get po -n kube-system,命令查看po资源

还会有一些异常,就是coredns一直显示Pending状态,这个是因为master节点还没有安装部署网络相关的组件服务(如calico)

[root@k8s-master ~]# kubectl get po -n kube-system
NAME                                 READY   STATUS    RESTARTS        AGE
coredns-6d8c4cb4d-5n968              0/1     Pending   0               7h53m
coredns-6d8c4cb4d-rj7d5              0/1     Pending   0               7h53m
etcd-k8s-master                      1/1     Running   1 (3h47m ago)   7h54m
kube-apiserver-k8s-master            1/1     Running   1 (3h47m ago)   7h54m
kube-controller-manager-k8s-master   1/1     Running   1 (3h47m ago)   7h54m
kube-proxy-2k6xf                     1/1     Running   1               12m
kube-proxy-g7j2p                     1/1     Running   1 (3h47m ago)   7h53m
kube-proxy-qfc5v                     1/1     Running   0               14m
kube-scheduler-k8s-master            1/1     Running   1 (3h47m ago)   7h54m
[root@k8s-master ~]#

说明:worker node 工作节点加入后,比之前多2个 kube-proxy-xxxxx  ,多的就是与worker node有关系的2个

如果calico部署后,上面的节点或者PO资源状态,就都会正常了,笔者将在后续的文章中,继续讲解calico的安装部署方法

 

 

 

尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/17381428.html