K8s Installation On Rocky Linux
K8s Installation On Rocky Linux
9 | AlmaLinux 9
Table of Contents
$ sudo swapoff -a
$ sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
Step 3: Adjust SELinux and Firewall Rules for Kubernetes
Set SELinux mode as permissive on all the nodes using following commands,
$ sudo setenforce 0
$ sudo sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=permissive/g'
/etc/sysconfig/selinux
Next, add the following kernel parameters, create a file and with following content,
$ sudo vi /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward =1
net.bridge.bridge-nf-call-ip6tables = 1
(Containerd was already installed along with Docker in our case). However, some configuration
would be required here as below:
Configure containerd so that it will use systemdcgroup, execute the following commands on
each node.
After installing Kubernetes tools, start the kubelet service on each node.
To start interacting with Kubernetes cluster, run the following commands on the master node.
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
Next, join the worker nodes to the cluster, run following Kubeadm command from the worker
nodes.
kubeadm join dwl-lab-021.ncp.edu.pk:6443 --token v1h7k9.1i7tpph7toorw3ke \
--discovery-token-ca-cert-hash
sha256:f75461772dce97c06118e03bb4d76a12c44a4ef0c694edbb0213291ad97d8faf
Now, head back to master node and run kubectl command to verify the nodes status.
In order to install calico CNI (Container Network Interface) addon, run following kubectl
commands from the master node only.
$ kubectl apply -f
https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/calico.yaml
Next, verify the nodes status, this time nodes status should be in Ready State.
To test Kubernetes cluster installation, let’s try to deploy nginx based application using
deployment. Run following kubectl commands,
Try to access the application (via web browser) using nodeport such as “31121”, run following
curl command,
$ curl <worker_node_name>:31121