kubeadm搭建单master-多node节点k8s集群 (3)

2)配置kubectl的配置文件config

[root@k8s-master1 ~]# mkdir -p $HOME/.kube [root@k8s-master1 ~]# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config [root@k8s-master1 ~]# sudo chown $(id -u):$(id -g) $HOME/.kube/config [root@k8s-master1 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master1 NotReady control-plane,master 2m11s v1.20.6 # 此时集群状态还是NotReady状态,因为没有安装网络插件。 2.4、扩容集群-添加第一个node节点 # 1.在k8s-master1上查看加入节点的命令: [root@k8s-master1 ~]# kubeadm token create --print-join-command kubeadm join 192.168.40.180:6443 --token mwk781.dqzihv2yt97f4v6v --discovery-token-ca-cert-hash sha256:c8e2661a2099c73475f0dcfb0679de5746f53a93d230b25e45c6ea3ce3f0d7c1 # 2.把k8s-node1加入k8s集群: [root@k8s-node1 ~]# kubeadm join 192.168.40.180:6443 --token mwk781.dqzihv2yt97f4v6v --discovery-token-ca-cert-hash sha256:c8e2661a2099c73475f0dcfb0679de5746f53a93d230b25e45c6ea3ce3f0d7c1 [preflight] Running pre-flight checks [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.7. Latest validated version: 19.03 [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. # 3.在k8s-master1上查看集群节点状况 [root@k8s-master1 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master1 NotReady control-plane,master 11m v1.20.6 k8s-node1 NotReady <none> 58s v1.20.6 2.5、扩容集群-添加第二个node节点 # 1.在k8s-master1上查看加入节点的命令: [root@k8s-master1 ~]# kubeadm token create --print-join-command kubeadm join 192.168.40.180:6443 --token lz5xqh.b9u5o7o0ndn25gn1 --discovery-token-ca-cert-hash sha256:c8e2661a2099c73475f0dcfb0679de5746f53a93d230b25e45c6ea3ce3f0d7c1 # 2.把k8s-node2加入k8s集群: [root@k8s-node2 ~]# kubeadm join 192.168.40.180:6443 --token lz5xqh.b9u5o7o0ndn25gn1 --discovery-token-ca-cert-hash sha256:c8e2661a2099c73475f0dcfb0679de5746f53a93d230b25e45c6ea3ce3f0d7c1 [preflight] Running pre-flight checks [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.7. Latest validated version: 19.03 [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. # 3.在k8s-master1上查看集群节点状况 [root@k8s-master1 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master1 NotReady control-plane,master 13m v1.20.6 k8s-node1 NotReady <none> 3m6s v1.20.6 k8s-node2 NotReady <none> 22s v1.20.6 # 4.给节点打标签 [root@k8s-master1 ~]# kubectl label node k8s-node1 node-role.kubernetes.io/worker=worker node/k8s-node1 labeled [root@k8s-master1 ~]# kubectl label node k8s-node2 node-role.kubernetes.io/worker=worker node/k8s-node2 labeled [root@k8s-master1 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master1 NotReady control-plane,master 14m v1.20.6 k8s-node1 NotReady worker 3m48s v1.20.6 k8s-node2 NotReady worker 64s v1.20.6 2.6、部署Calico

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgzwdw.html