Rate This Document
Findability
Accuracy
Completeness
Readability

Common Operations on All Nodes

Install Kubernetes cluster software, configure containerd, and perform other related operations on all master and worker nodes.

  1. Change the host names to ensure that the host name of each server is unique.

    For example:

    • On the master node, change the host name to k8s-master.
      hostnamectl set-hostname k8s-master
      bash
    • On the worker node, change the host name to k8s-slave1.
      hostnamectl set-hostname k8s-slave1
      bash
  2. Change the passwords of all servers to the same.
  3. Disable the firewall.
    1
    2
    systemctl stop firewalld
    systemctl disable firewalld
    
  4. Disable SWAP partitions.
    • Run the following command. The setting becomes invalid after the server restarts.
      1
      swapoff -a   
      
    • Comment out the code for automatic mounting of SWAP partitions in the fstab file. The setting is still valid after the server restarts.
      1
      sed -i "/\/dev\/mapper\/openeuler-swap/ s|^|#|" /etc/fstab
      
  5. Disable SELinux.
    1
    sed -i "s|SELINUX=.*|SELINUX=disabled|g" /etc/selinux/config
    
  6. Configure the source required for installing Kubernetes cluster software.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    touch /etc/yum.repos.d/kubernetes.repo
    cat >/etc/yum.repos.d/kubernetes.repo <<EOF
    [kubernetes]
    name=Kubernetes
    baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
    enabled=1
    gpgcheck=1
    gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
    EOF
    
  7. Install Kubernetes cluster software.
    1
    2
    yum install -y kubelet kubeadm kubectl kubernetes-cni --disableexcludes=kubernetes
    systemctl enable --now kubelet
    
  8. Install containerd and runC based on 1 to 3 in (Optional) Deploying the Containerd Environment. After the installation is successful, restart the Docker service based on 6 on the worker node.
  9. Modify the containerd configuration file.
    1
    2
    3
    4
    mkdir -p /etc/containerd/
    cd /etc/containerd/
    containerd config default > /etc/containerd/config.toml
    sed -i "s|SystemdCgroup =.*|SystemdCgroup = true|g" /etc/containerd/config.toml
    
  10. Configure crictl and restart containerd.
    1
    2
    3
    4
    5
    echo "runtime-endpoint: unix:///run/containerd/containerd.sock" >> /etc/crictl.yaml
    echo "image-endpoint: unix:///run/containerd/containerd.sock" >> /etc/crictl.yaml
    echo "timeout: 10" >> /etc/crictl.yaml
    systemctl daemon-reload
    systemctl restart containerd
    
  11. Configure network forwarding. Perform this step again after the server is restarted.
    1
    2
    3
    4
    5
    6
    modprobe overlay
    modprobe br_netfilter
    echo "net.bridge.bridge-nf-call-ip6tables=1" >> /etc/sysctl.d/k8s.conf
    echo "net.bridge.bridge-nf-call-iptables=1" >> /etc/sysctl.d/k8s.conf
    echo "net.ipv4.ip_forward=1" >> /etc/sysctl.d/k8s.conf
    sysctl -p /etc/sysctl.d/k8s.conf