Commands listed are required to install, configure, and start a basic Kubernetes cluster. Watch for where each command needs to be run. Some on the Kubernetes master, some on the nodes, most on both.
Reference:
https://github.com/relay70/Kubernetes-Install-Fedora
for the config files. There is also an Ansible script there if that executes these same commands.
Disable Swap / Disable Firewalld
Commands (Master and Nodes)
swapoff -a
systemctl stop dev-zram0.swap
dnf remove zram-generator
systemctl stop firewalld
systemctl disable firewalld
reboot
Explanation
- Turn swap off and disable the swap services.
- Disable firewalld if it’s running. You could also open the ports necessary for kubernets traffic. (6443, 10250, 10248)
- Reboot the system.
Install Support Packages
Commands (Master and Nodes)
dnf install containerd
dnf install jq
dnf install iproute-tc
Explanation
Install the necessary packages to get started with kubernetes.
- containerd: is the container runtime.
https://github.com/containerd/containerd/blob/main/docs/getting-started.md - jq: JSON command line parser. It’s helpfull
- iproute-tc: IP traffic control utility
https://packages.fedoraproject.org/pkgs/iproute/iproute-tc/
Copy Config Files
Commands (Master and Nodes)
dnf install git
git clone https://github.com/relay70/Kubernetes-Install-Fedora.git
cd Kubernetes-Install-Fedora/srcFiles
cp modules_load_containerd.conf /etc/modules-load.d/containerd.conf
cp sysctl_k8s.conf /etc/sysctl.d/k8s.conf
cp yum_repo_kubernetes.repo /etc/yum.repos.d/kubernetes.repo
cp containerd_config.toml /etc/containerd/config.toml
cp tmp_calico.yaml /tmp/calico.yaml
Explanation
Copy the configurations to their required loations.
Just in case install git.
This git repo contains some config files necessary for the manual installation.
- /etc/modules-load.d/containerd.conf – modprobem configs to load overlay and br_netfilter so networking will work.
- /etc/yum.repos.d/kubernetes.repo makes the kubernetes yum repo avaiable.
/etc/containerd/config.toml
– This is a basic, mostly empty containerd config./tmp/calico.yaml
– Calico manifest file for kubernetes. This will be used during the calico installation.
Load Kernel Modules / Configs
Commands (Master and Nodes)
modprobe overlay
modprobe br_netfilter
sysctl --system
Explanation
Load kernel modules and sysctl configs from the configs copied in the previous step.
Create CNI directory/Symlinks
Commands (Master and Nodes)
mkdir /opt/cni/
ln -s /usr/libexec/cni /opt/cni/bin
These fix the bug described here:
https://bugzilla.redhat.com/show_bug.cgi?id=1731597
Explanation
This fixes the issue described in the link above. 2 packages install cni libraries to 2 different places. This links the one from calico (/opt/cni) to the one from containerd (/usr/libexec/cni).
I'm sure there are other ways to fix this.
Start containerd
Commands (Master and Nodes)
systemctl enable containerd
systemctl start containerd
Explanation
Enable and start the containerd runtime
Install/Enable kubernetes packages
Commands (Master and Nodes)
dnf install kubeadm --disableexcludes=kubernetes
dnf install kubectl --disableexcludes=kubernetes
dnf install kubelet --disableexcludes=kubernetes
systemctl enable kubelet
Explanation
Installing the actual kubernets services and tools the
kubeadm - CLI tool for administering a Kubernetes cluster
kubectl - CLI tool for interacting with a Kubernetes cluster
kubelet - Node agent for Kubernetes clusters
Initialize Cluster/Create KubeConfig
Commands (Master only)
kubeadm init
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
Explanation
These command initialize your cluster.
Then create directories, and copy cluster configs to your home directory.
Alternatively you can enter a permanent export in your .bash_profile with this command:
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> $HOME/.bash_profile
*The copy, chown, and echo command can be run for any user that needs access to the cluster*
Install calico
Commands (Master only)
kubectl apply -f 'tmp_calico.yaml'
Explanation
This install calico is a popular CNI (Container network Interface). It does the networking inside your cluster. This config file was copied duing the Copy Config step.
Join Nodes
Commands (Nodes and Master)
###On your Kubernetes master
kubeadm token create --print-join-command
###(Copy the full output from the commnad)
###On your Kubernetes Nodes
###Execute the output on your nodes.
Explanation
kubeadm token create --print-join-command - Will display a command that needs to be executed on each of your nodes. This will join those nodes to your cluster.
This command can be executed at any time if you want to add more nodes to your cluster.
Verify Cluster
Commands (Master only)
kubectl cluster-info
kubectl get nodes
Explanation
kubectl cluster-info - Should show info about your control plane, and that CoreDNS is running.
kubectl get nodes - Should show a list of your nodes. Nodes be take some time (several minutes) to move to a "Ready" state.
Leave a Reply