How To Install Kubernetes on Rocky Linux 9
In this tutorial, we will show you how to install Kubernetes on Rocky Linux 9. For those of you who didn’t know, Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF). Kubernetes simplifies the management of complex distributed systems and provides a scalable and resilient infrastructure for running containerized workloads.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Kubernetes on Rocky Linux. 9.
- A server running one of the following operating systems: Rocky Linux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Kubernetes.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install Kubernetes on Rocky Linux 9
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf check-update sudo dnf install dnf-utils sudo dnf install device-mapper-persistent-data lvm2
Step 2. Installing Docker on Rocky Linux 9.
By default, Docker is not available on Rocky Linux 9 base repository. Now run the following command below to add the Docker CE repository to your system:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
After the repositories have been added to the system, now run the following command to install Docker CE Rocky Linux:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin --allowerasing
Once the installation is completed, start the Docker service on your Rocky Linux and also enable it to run automatically with system boot:
sudo systemctl enable docker sudo systemctl start docker
Step 3. Add User to Docker Group.
Add user to Docker group using the command:
sudo usermod -aG docker $USER
Next, create a new group:
Verify the Docker version is installed:
For additional resources on installing and managing Docker, read the post below:
Step 4. Installing Kubernetes on your Rocky Linux 9.
Now we install Kubernetes and components. To install the necessary Kubernetes tools, execute the following steps. First, add the Kubernetes repository by running the command:
sudo dnf config-manager --add-repo=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
Next, install the Kubernetes tools by executing the command:
sudo dnf install kubectl kubelet kubeadm
In this step, we will initialize the Kubernetes master node:
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
After the Kubernetes cluster is set up, you can verify the installation using the following steps:
Step 5. Configuring Kubernetes.
To manage nodes and pods in your Kubernetes cluster, use the following commands:
- To view the nodes in the cluster:
kubectl get nodes
- To view the pods in the cluster:
kubectl get pods
- To scale the number of replicas for a deployment:
kubectl scale deployment <deployment-name> --replicas=<number-of-replicas>
Congratulations! You have successfully installed Kubernetes. Thanks for using this tutorial for installing Kubernetes on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Kubernetes website.