How To Install Kubernetes on Linux Mint 21
In this tutorial, we will show you how to install Kubernetes on Linux Mint 21. For those of you who didn’t know, Kubernetes, often referred to as K8s, is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It has become the industry standard for container orchestration, and its adoption has skyrocketed in recent years, thanks to its ability to simplify the management of containerized applications.
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 a Linux Mint 21.2 (Victoria).
Prerequisites
- A server running one of the following operating systems: Linux Mint 21.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- While we’ll guide you through the process, a basic understanding of the command line will be beneficial. If you’re new to the CLI, you might want to acquaint yourself with some fundamental commands.
- An active internet connection.
- Administrative privileges are essential for installing and configuring software on your system. Ensure that you have superuser or sudo access.
Install Kubernetes on Linux Mint 21
Step 1. It’s essential to have your system up to date before installing Kubernetes. Open a terminal and run the following commands:
sudo apt update sudo apt upgrade
Step 2. Installing Docker.
To install Docker on Linux Mint 21, you’ll need to install some dependencies. Run the following commands:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Next, add the Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Now, you can install Docker:
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io
Start the Docker service and enable it to start on boot:
sudo systemctl start docker sudo systemctl enable docker
You can verify that Docker is installed correctly by running:
docker --version
Step 3. Installing kubeadm, kubelet, and kubectl.
Kubeadm, kubelet, and kubectl are the essential tools required for setting up a Kubernetes cluster.
To add the Kubernetes repository, run the following commands:
sudo su curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list exit
Install the Kubernetes components with the following commands:
sudo apt update sudo apt install kubeadm kubelet kubectl
You can verify the installation by checking the versions of the installed components:
kubeadm version kubelet --version kubectl version
Step 4. Initializing the Kubernetes Master Node.
Now that we have Docker and the necessary Kubernetes tools installed, it’s time to initialize the Kubernetes master node.
On your Linux Mint 21 machine, run the following command to initialize the Kubernetes master node:
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
This command will take some time to complete and will generate a token that you’ll need to join worker nodes to the cluster. Make sure to note it down.
After initialization, configure kubectl for your user:
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
To enable networking for your cluster, you can use a network plugin. We’ll use Calico in this example:
kubectl apply -f https://docs.projectcalico.org/v3.16/manifests/calico.yaml
Step 5. Joining Worker Nodes to the Kubernetes Cluster.
Now that your master node is up and running, it’s time to add worker nodes to your Kubernetes cluster.
On each worker node, run the following command with the token generated during the master node initialization:
sudo kubeadm join <master-node-ip>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>
Replace <master-node-ip>
, <token>
, and <hash>
with the values specific to your cluster.
To verify that the worker node has successfully joined the cluster, go back to the master node and run:
kubectl get nodes
You should see the worker node listed and in the “Ready” state.
Step 6. Testing the Kubernetes Installation.
To ensure that your Kubernetes cluster is functioning correctly, let’s perform some basic tests.
To deploy a simple NGINX web server pod, run:
kubectl create deployment nginx --image=nginx
Expose the NGINX pod as a service:
kubectl expose deployment nginx --port=80 --type=NodePort
You can access the NGINX service using the worker node’s IP address and the NodePort:
kubectl get service nginx
Now, open your web browser and navigate to <worker-node-IP>:<NodePort>
. You should see the NGINX welcome page.
Congratulations! You have successfully installed Kubernetes. Thanks for using this tutorial for installing the latest version of Kubernetes on the Linux Mint system. For additional help or useful information, we recommend you check the official Kubernetes website.