...
- CentOS 7 (minimum supported version);
- at least 2 GB of RAM and 2 CPUs per machine;
- opening doors on the control plane (6443, 2379-2380, 10250-10252) and on the worker (10250, 30000-32767);
- install Docker on the nodes (official guide);
- complete connectivity between the cluster nodes and uniqueness of MAC address and product_uuid for each node;
- swap disabled on nodes.
...
The swap values should all be 0 bytes. If not, comment on the swap line of the /etc/fstab
file and reboot. In this way the swap is permanently deactivated.
Installation
Installing CRI
By default, Kubernetes uses the Container Runtime Interface (CRI) to interface with your chosen container runtime. So, you need to install a CRI into each node in the cluster, in order that Pods can run there. Common CRI with Kubernetes, on Linux, are: containerd, CRI-O and Docker. We will focus on the latter. First, therefore, install Docker on each of your nodes (install Docker on CentOS).
After installation, create the following .json
file in the given path to set up the Docker daemon
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF |
Finally, create the docker.service.d
folder and restart Docker
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ sudo mkdir -p /etc/systemd/system/docker.service.d
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
# If you want the docker service to start on boot, run the following command
$ sudo systemctl enable docker |
Installing kubeadm, kubelet and kubectl
At this point we are ready with the installation of Kubeadm
, Kubectl
and Kubelet
on all VM of the cluster (procedure valid, as well as for CentOS, also for RedHat and Fedora)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ 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 |
...