1. Configure the cluster

Error: message: ‘the runtime network not ready: NetworkReady = false reason: NetworkPluginNotReady message: docker: network plugin is not ready: cni config uninitialized’

Cause: CNI is not initialized. (CNI stands for Container Network Interface, which is the K8S Interface specification for configuring the Linux Container Network.)

[root@slave zkpk]# kubectl get nodes -o yaml apiVersion: v1 items: - apiVersion: v1 kind: Node metadata: annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock node.alpha.kubernetes.io/ttl: "0" volumes.kubernetes.io/controller-managed-attach-detach: "true" creationTimestamp: "2021-04-27T13:36:43Z" labels: beta.kubernetes.io/arch: amd64 beta.kubernetes.io/os: linux kubernetes.io/arch: amd64 kubernetes.io/hostname: slave kubernetes.io/os: linux node-role.kubernetes.io/master: "" name: slave resourceVersion: "5420" selfLink: / API /v1/nodes/slave UID: 77EC909A-04D8-4f87-9f2a-8CFb3d48b9BC spec: podCIDR: 10.244.0.0/24 Taints: - effect: NoSchedule key: node-role.kubernetes.io/master - effect: NoSchedule key: node.kubernetes.io/not-ready status: Addresses: -address: 192.168.211.130 Type: internalip-address: slave type: Hostname Allocatable: CPU: "2" ephemeral-storage: "27037535802" hugepages-1Gi: "0" hugepages-2Mi: "0" memory: 893524Ki pods: "110" capacity: cpu: "2" ephemeral-storage: 29337604Ki hugepages-1Gi: "0" hugepages-2Mi: "0" memory: 995924Ki pods: "110" conditions: - lastHeartbeatTime: "2021-04-27T14:44:55Z" lastTransitionTime: "2021-04-27T13:36:37Z" message: kubelet has sufficient memory available reason: KubeletHasSufficientMemory status: "False" type: MemoryPressure - lastHeartbeatTime: "2021-04-27T14:44:55Z" lastTransitionTime: "2021-04-27T13:36:37Z" message: kubelet has no disk pressure reason: KubeletHasNoDiskPressure status: "False" type: DiskPressure - lastHeartbeatTime: "2021-04-27T14:44:55Z" lastTransitionTime: "2021-04-27T13:36:37Z" message: kubelet has sufficient PID available reason: KubeletHasSufficientPID status: "False" type: PIDPressure - lastHeartbeatTime: "2021-04-27T14:44:55Z" lastTransitionTime: "2021-04-27T13:36:37Z" message: 'runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized' reason: KubeletNotReadyCopy the code

Install the network plug-in CNI

kubectl apply -fhttps://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.y mlCopy the code

The startup succeeded and the state is ready

[root@slave zkpk]# kubectl get nodes
NAME    STATUS   ROLES    AGE    VERSION
slave   Ready    master   158m   v1.15.0
Copy the code

You can now view the status of all the pods

[root@slave zkpk]# kubectl get pods --all-namespaces
NAMESPACE     NAME                            READY   STATUS             RESTARTS   AGE
kube-system   coredns-bccdc95cf-lpbg6         1/1     Running            0          3h21m
kube-system   coredns-bccdc95cf-m5dnz         1/1     Running            0          3h21m
kube-system   etcd-slave                      1/1     Running            0          3h20m
kube-system   kube-apiserver-slave            1/1     Running            0          3h20m
kube-system   kube-controller-manager-slave   0/1     CrashLoopBackOff   23         3h20m
kube-system   kube-flannel-ds-amd64-zcsn9     1/1     Running            0          139m
kube-system   kube-proxy-tl4xq                1/1     Running            0          3h21m
kube-system   kube-scheduler-slave            1/1     Running            22         3h20m

Copy the code

2. Add the node

  1. Install the Docker and other software as you would on the master node

  2. Generate tokens on matser

[root@slave zkpk]# kubeadm token create 
vxx3mh.i7voxmkglvli99dt
[root@slave zkpk]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
5168f393e212678c9954bbf8f5003df29d11fe41dbeca240dca90d7bc3cb77df

Copy the code
  1. Run the following commands on the node node (token ones using the ones just generated on the master)

[root@slave1 zkpk]# kubeadm join 192.168.211.130:6443 --token vxx3mh.i7voxmkglvli99dt  --discovery-token-ca-cert-hash sha256:5168f393e212678c9954bbf8f5003df29d11fe41dbeca240dca90d7bc3cb77df

Copy the code
  1. Test whether a node has been added to a cluster
[root@slave1 ZKPK]# kubectl get node NAME STATUS ROLES AGE VERSION slave Ready master 45h v1.15.0 slave1 Ready <none> 23 m v1.15.0Copy the code