Installing kubeadm

    • A compatible Linux host. The Kubernetes project provides generic instructions for Linux distributions based on Debian and Red Hat, and those distributions without a package manager.
    • 2 GB or more of RAM per machine (any less will leave little room for your apps).
    • 2 CPUs or more.
    • Full network connectivity between all machines in the cluster (public or private network is fine).
    • Unique hostname, MAC address, and product_uuid for every node. See here for more details.
    • Certain ports are open on your machines. See for more details.
    • Swap disabled. You MUST disable swap in order for the kubelet to work properly.

    Verify the MAC address and product_uuid are unique 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

    It is very likely that hardware devices will have unique addresses, although some virtual machines may 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 .

    Check network adapters

    If you have more than one network adapter, and your Kubernetes components are not reachable on the default route, we recommend you add IP route(s) so Kubernetes cluster addresses go via the appropriate adapter.

    Make sure that the br_netfilter module is loaded. This can be done by running lsmod | grep br_netfilter. To load it explicitly call sudo modprobe br_netfilter.

    As a requirement for your Linux Node’s iptables to correctly see bridged traffic, you should ensure net.bridge.bridge-nf-call-iptables is set to 1 in your sysctl config, e.g.

    For more details please see the page.

    Check required ports

    These need to be open in order for Kubernetes components to communicate with each other. You can use telnet to check if a port is open. For example:

    1. telnet 127.0.0.1 6443

    The pod network plugin you use (see below) may also require certain ports to be open. Since this differs with each pod network plugin, please see the documentation for the plugins about what port(s) those need.

    Installing runtime

    To run containers in Pods, Kubernetes uses a .

    By default, Kubernetes uses the Container Runtime Interface (CRI) to interface with your chosen container runtime.

    If you don’t specify a runtime, kubeadm automatically tries to detect an installed container runtime by scanning through a list of well known Unix domain sockets. The following table lists container runtimes and their associated socket paths:

    If both Docker and containerd are detected, Docker takes precedence. This is needed because Docker 18.09 ships with containerd and both are detectable even if you only installed Docker. If any other two or more runtimes are detected, kubeadm exits with an error.

    The kubelet integrates with Docker through the built-in dockershim CRI implementation.

    See for more information.

    By default, kubeadm uses Docker as the container runtime. The kubelet integrates with Docker through the built-in dockershim CRI implementation.

    You will install these 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 util to talk to your cluster.

    kubeadm will not install or manage kubelet or kubectl for you, so you will need to ensure they match the version of the Kubernetes control plane you want kubeadm to install for you. If you do not, there is a risk of a version skew occurring that can lead to unexpected, buggy behaviour. However, one minor version skew between the kubelet and the control plane is supported, but the kubelet version may never exceed the API server version. For example, the kubelet running 1.7.0 should be fully compatible with a 1.8.0 API server, but not vice versa.

    For information about installing kubectl, see .

    Warning: These instructions exclude all Kubernetes packages from any system upgrades. This is because kubeadm and Kubernetes require special attention to upgrade.

    For more information on version skews, see:

    1. Update the apt package index and install packages needed to use the Kubernetes apt repository:

      1. sudo apt-get update
      2. sudo apt-get install -y apt-transport-https ca-certificates curl
    2. Download the Google Cloud public signing key:

    3. Add the Kubernetes apt repository:

    4. Update apt package index, install kubelet, kubeadm and kubectl, and pin their version:

      1. sudo apt-get update
      2. sudo apt-get install -y kubelet kubeadm kubectl
      3. sudo apt-mark hold kubelet kubeadm kubectl
    1. cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
    2. [kubernetes]
    3. name=Kubernetes
    4. baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
    5. enabled=1
    6. gpgcheck=1
    7. repo_gpgcheck=1
    8. gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    9. exclude=kubelet kubeadm kubectl
    10. EOF
    11. sudo setenforce 0
    12. sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
    13. sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
    14. sudo systemctl enable --now kubelet
    • Setting SELinux in permissive mode by running setenforce 0 and effectively disables it. This is required to allow containers to access the host filesystem, which is needed by pod networks for example. You have to do this until SELinux support is improved in the kubelet.

    • You can leave SELinux enabled if you know how to configure it but it may require settings that are not supported by kubeadm.

    Install CNI plugins (required for most pod network):

    1. CNI_VERSION="v0.8.2"
    2. ARCH="amd64"
    3. sudo mkdir -p /opt/cni/bin
    4. curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz" | sudo tar -C /opt/cni/bin -xz

    Define the directory to download command files

    Note: The DOWNLOAD_DIR variable must be set to a writable directory. If you are running Flatcar Container Linux, set DOWNLOAD_DIR=/opt/bin.

    Install crictl (required for kubeadm / Kubelet Container Runtime Interface (CRI))

    1. CRICTL_VERSION="v1.22.0"
    2. ARCH="amd64"
    3. curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCH}.tar.gz" | sudo tar -C $DOWNLOAD_DIR -xz

    Install kubeadm, kubelet, kubectl and add a kubelet systemd service:

    1. RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)"
    2. ARCH="amd64"
    3. cd $DOWNLOAD_DIR
    4. sudo curl -L --remote-name-all https://storage.googleapis.com/kubernetes-release/release/${RELEASE}/bin/linux/${ARCH}/{kubeadm,kubelet,kubectl}
    5. sudo chmod +x {kubeadm,kubelet,kubectl}
    6. RELEASE_VERSION="v0.4.0"
    7. curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service" | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | sudo tee /etc/systemd/system/kubelet.service
    8. sudo mkdir -p /etc/systemd/system/kubelet.service.d
    9. curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf" | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | sudo tee /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

    Enable and start kubelet:

      Note: The Flatcar Container Linux distribution mounts the /usr directory as a read-only filesystem. Before bootstrapping your cluster, you need to take additional steps to configure a writable directory. See the to learn how to set up a writable directory.

      The kubelet is now restarting every few seconds, as it waits in a crashloop for kubeadm to tell it what to do.

      Configuring a cgroup driver

      Both the container runtime and the kubelet have a property called , which is important for the management of cgroups on Linux machines.

      Warning:

      Matching the container runtime and kubelet cgroup drivers is required or otherwise the kubelet process will fail.

      See Configuring a cgroup driver for more details.

      Troubleshooting