Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Install Docker on all CentOS 7 VMs

    1. Update the package database

      Code Block
      sudo yum check-update
    2. Install the dependencies

      Code Block
      sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    3. Add and enable the official Docker Repository to CentOS 7

      Code Block
      sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    4. Install the latest Docker version on CentOS 7

      Code Block
      sudo yum install docker-ce
    5. A successful installation output will be concluded with a Complete!
      You may be prompted to accept the GPG key. This is to verify that the fingerprint matches. The format will look as follows. If correct, accept it.

      Code Block
      060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
    6. Manage Docker service
      Now Docker is installed, but the service is not yet running. Start and enable Docker using the commands. 

      Code Block
      sudo systemctl start docker
      sudo systemctl enable docker
    7. To confirm that Docker is active and running, use:

      Code Block
      sudo systemctl status docker
  2. Set up the Kubernetes Repository

    1. Since the Kubernetes packages aren’t present in the official CentOS 7 repositories, we will need to add a new repository file. Use the following command to create the file and open it for editing:

      Code Block
      sudo vi /etc/yum.repos.d/kubernetes.repo
    2. Once the file is open, press the I key to enter insert mode and paste the following contents:

      Code Block
      [kubernetes]
      name=Kubernetes
      baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
      enabled=1
      gpgcheck=1
      repo_gpgcheck=1
      gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

      Once pasted, press escape to exit insert mode. Then enter :x to save the file and exit.


  3. Install Kubelet on CentOS 7

    1. The first core module that we need to install on every node is Kubelet. Use the following command to do so:

      Code Block
      sudo yum install -y kubelet
  4. Install kubeadm and kubectl on CentOS 7

    1. kubeadm, the next core module, which has to be installed. Use the following command:

      Code Block
      sudo yum install -y kubeadm

      (Note that kubeadm automatically installs kubectl as a dependency)


  5. Disable swap

    1. For Kubelet to work, we also need to disable swap. The swap can be disabled using the below commands:

      Code Block
      sudo swapoff -a
      sudo sed -i '/ swap / s/^/#/' /etc/fstab


  6. Initialize Kubeadm and start the Kubernetes cluster

    1. When we initialize the kubeadm directly, then the kubeadm throws the error:

      Code Block
      Some fatal errors occurred: [ERROR CRI]: container runtime is not running Status from runtime service failed” err=”rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService”
    2. To resolve the above error, it is required to delete the config.tomal file and restart contained using the below steps:

      Code Block
      sudo rm /etc/containerd/config.toml
      systemctl restart containerd
    3. Initialize Kubeadm and Create required directories and start managing Kubernetes cluster

      Code Block
      sudo kubeadm init
      mkdir $HOME/.kube
      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
      sudo chown $(id -u):$(id -g) $HOME/.kube/config
      export KUBECONFIG=/etc/kubernetes/admin.conf
    4. Enable and restart docker and Kubernetes services.

      Code Block
      sudo systemctl enable docker.service
      sudo service kubelet restart
      sudo chown -R centos:centos kubernetes/
      
    5. Set up Pod network for the Cluster.

      Code Block
      kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml
      kubectl get nodes

...