Operations on the Master Node
Initialize the cluster on the master node.
- Download necessary images.
1kubeadm config images pull
If no error is reported, the download is successful.
Configure an image repository if required, for example:
1kubeadm config images pull --image-repository registry.aliyuncs.com/google_containers
- Modify the containerd image configuration in the config.toml configuration file based on the pause version in the pulled image information. Run the following command to check the pause version:
1crictl imagesThe following uses registry.aliyuncs.com/google_containers/pause:3.9 in Figure 1 as an example:1sed -i 's|sandbox_image =.*|sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"|g' /etc/containerd/config.toml
- Restart containerd.
1systemctl restart containerd
- Initialize the cluster.
1kubeadm init --pod-network-cidr=10.244.0.0/16
After the initialization is complete, information shown in Figure 2 is displayed.
If an image repository is configured for image download, the same image repository must be configured during cluster initialization. For example:
1kubeadm init --pod-network-cidr=10.244.0.0/16 --image-repository registry.aliyuncs.com/google_containers
Run the commands in the yellow box in Figure 2 to configure the cluster. Content in the red box indicates the token command for a worker node to join the cluster. Please save this command.
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 cluster initialization fails on the master node, locate the cause as prompted, reset the node, 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.

