We'll be creating three separate VM's, but since there are things that need to be set up on all of them, we'll start off by doing that on a single VM, then cloning[1]If you're using VMware, you can create linked clones, which will save a bit of disk space. it to create the two other VM's, then configuring each one individually for their specific needs.
For reference, we'll be setting the VM's up like this:
hostname | IP address |
vm-kcontrol | 192.168.50.70 |
vm-knode1 | 192.168.50.71 |
vm-knode2 | 192.168.50.72 |
Set up the base VM
We'll start by installing Fedora Server 35. The requirements for each VM are documented here:
- at least 2 GB of RAM
- at least 2 CPU's
- at least 1 NIC[2]192.168.50.0/24 is a local network I use for my dev boxes, so I'll need 2 NIC's, one for the LAN and one that has internet access.
Once Linux has been installed, set the hostname like this:
sudo hostnamectl set-hostname vm-kcontrol
To set a fixed IP address, first run nmcli connection show to get the UUID of NIC we want to use.
Then run nmcli connection modify to set the IP address.
Swap must be disabled:
sudo systemctl mask dev-zram0.swap
Configure networking
The firewall requirements are documented here. For the control plane:
sudo firewall-cmd --permanent --add-port=6443/tcp sudo firewall-cmd --permanent --add-port=2379-2380/tcp sudo firewall-cmd --permanent --add-port=10250-10252/tcp
And for the worker nodes:
sudo firewall-cmd --permanent --add-port=30000-32767/tcp
We also need to ensure that the br_netfilter module gets loaded, by adding the following line to /etc/modules-load.d/k8s.conf:
br_netfilter
To ensure that iptables can see bridged traffic, add the following to /etc/sysctl.d/k8s.conf:
net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1
Reboot the machine, to ensure that all our changes are applied.
Install a container runtime
Kubernetes supports several different container runtimes; we'll use Docker, since it's the most popular.
On Fedora, we first need to add the Docker repository:
sudo dnf -y install dnf-plugins-core sudo dnf config-manager \ --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Then install Docker:
sudo dnf install docker-ce docker-ce-cli containerd.io
Start Docker, and check that it's working by running the hello-world image:
sudo systemctl start docker sudo docker run hello-world
To be able to run Docker without having to use sudo, add yourself to the docker group:
sudo usermod -aG docker $USER
Log out and back in, and you should be able to run Docker without having to sudo.
Finally, we configure Docker to automatically start when the system comes up.
sudo systemctl enable docker.service sudo systemctl enable containerd.service
Install Kubernetes
We can now install the Kubernetes software. First, we need to configure the Kubernetes repository, by creating a /etc/yum.repos.d/kubernetes.repo file:
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
Unfortunately, we also need to disable SELinux
sudo setenforce 0 sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
We can now install the required software:
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes sudo systemctl enable --now kubelet