Operations on the Master Node
Initialize the cluster on the master node.
- Download the image.
1kubeadm config images pull
If no error is reported, the download is successful.
- Initialize the cluster.
1kubeadm init --pod-network-cidr=10.244.0.0/16
After the initialization is successful, information shown in Figure 1 is displayed.
Run the commands in the yellow box in Figure 1 to configure the cluster. Content in the red box indicates the token commands for adding the worker node to the cluster. Save the commands.
1 2 3 4
rm -rf $HOME/.kube mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
If the master node fails to be initialized, locate the cause as prompted, reset the cluster, and run the initialization command again. Reset commands:
1 2 3 4 5 6 7 8 9
kubeadm reset systemctl stop kubelet rm -rf /var/lib/cni/ rm -rf /var/lib/kubelet/* rm -rf /etc/cni/ ifconfig cni0 down ifconfig flannel.1 down ip link delete cni0 ip link delete flannel.1
- Start the kube-flannel network plugin.Obtain the DemoVideoEngine.tar.gz software package based on Video Stream Engine, and upload the software package to the /home/k8s directory on the server.
1 2 3 4
cd /home/k8s tar -xvf DemoVideoEngine.tar.gz cd /home/k8s/k8s/script kubectl apply -f kube-flannel.yml
- Check the cluster status.
- Check the status of the current node.
1kubectl get nodes -A -o wide
It is expected that the STATUS column of the master node is Ready and the CONTAINER-RUNTIME column is containerd://x.x.x.
- Check the Pod status.
1kubectl get pod -A -o wide
It is expected that the STATUS column of all Pods is Running.
If the status of the current node is NotReady and the error message "Network plugin returns error: cni plugin not initialized" is displayed when you run the systemctl status kubelet command to check the kubelet service status, you are advised to reset the cluster, restart the server, and initialize the cluster again.
- Check the status of the current node.
