Rate This Document
Findability
Accuracy
Completeness
Readability

Operations on the Master Node

Initialize the cluster on the master node.

  1. Download necessary images.
    1
    kubeadm config images pull 
    

    If no error is reported, the download is successful.

    Configure an image repository if required, for example:

    1
    kubeadm config images pull --image-repository registry.aliyuncs.com/google_containers
    
  2. 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:
    1
    crictl images
    
    Figure 1 Image information
    The following uses registry.aliyuncs.com/google_containers/pause:3.9 in Figure 1 as an example:
    1
    sed -i 's|sandbox_image =.*|sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"|g' /etc/containerd/config.toml
    
  3. Restart containerd.
    1
    systemctl restart containerd
    
  1. Initialize the cluster.
    1
    kubeadm 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:

    1
    kubeadm init --pod-network-cidr=10.244.0.0/16 --image-repository registry.aliyuncs.com/google_containers
    
    Figure 2 Cluster initialization success

    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
    
  2. 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
    
  3. Check the cluster status.
    1. Check the status of the current node.
      1
      kubectl 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.

    2. Check the Pod status.
      1
      kubectl 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.