Installing kubeadm, kubelet, and kubectl

This topic describes how to install kubeadm, kubelet, and kubectl.

Before you begin

Below is the prerequisite:
  • One or more machines running one of the following:
    • Ubuntu 16.04+
    • Debian 9+
    • CentOS 7
    • Red Hat Enterprise Linux (RHEL) 7
    • Fedora 25+
    • HypriotOS v1.0.1+
    • Container Linux (tested with 1800.6.0)
  • 2 GB or more of RAM per machine
  • 2 CPUs or more
  • Full network connectivity between all machines in the cluster (public or private network is ok)
  • Unique hostname, MAC address, and product_uuid for every node:
    • You can get the MAC address of the network interfaces using the command ip link or ifconfig -a.
    • The product_uuid can be checked by using the command sudo cat /sys/class/dmi/id/product_uuid.
    • Hardware devices will likely have unique addresses, although some virtual machines can have identical values. Kubernetes uses these values to uniquely identify the nodes in the cluster. If these values are not unique to each node, the installation process may fail.
  • Swap disabled. You must disable swap so that the kubelet works properly.
  • Certain ports are open on your machines, see the below images for reference.

Procedure

  1. Install the following packages on all of your machines:
    • kubeadm: the command to bootstrap the cluster.
    • kubelet: the component that runs on all of the machines in your cluster and does things like starting PODs and containers.
    • kubectl: the command line until to talk to your cluster.
  2. Follow the below steps to install the above components:
    1. on RHEL, CentOS, and Fedora:
      cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
      [kubernetes]
      name=Kubernetes
      baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
      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
      exclude=kubelet kubeadm kubectl
      EOF
      
      sudo setenforce 0
      sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
      sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
      sudo systemctl enable --now kubelet
      
    2. on Ubuntu, Debian, and HypriotOS:
      sudo apt-get update && sudo apt-get install -y apt-transport-https curl
      curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
      cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
      deb https://apt.kubernetes.io/ kubernetes-xenial main
      EOF
      sudo apt-get update
      sudo apt-get install -y kubelet kubeadm kubectl
      sudo apt-mark hold kubelet kubeadm kubectl