How to Install Kubernetes on Manjaro

Kubernetes is a popular open-source container orchestration system used for automating deployment, scaling, and management of containerized applications. In this tutorial, we will guide you on how to install Kubernetes on Manjaro.

Prerequisites

Before we proceed, make sure that you have the following prerequisites:

Step 1: Install Docker

Kubernetes requires a container runtime to work correctly. Therefore, we need to install Docker on the Manjaro system first. The following command will help to do that:

sudo pacman -S docker

After the installation, start and enable the Docker service by running the following command:

sudo systemctl start docker
sudo systemctl enable docker

Step 2: Install Kubernetes

Now, let's install Kubernetes on Manjaro by following these steps:

Step 2.1: Add Kubernetes Repository to pacman

Since Kubernetes is not available in the Manjaro Linux official repository, we have to add it manually.

sudo pacman-mirrors --api --set-branch unstable
echo "[metallb_unstable]" | sudo tee -a /etc/pacman.conf
echo "Server = https://builds.metalsoft.io/arch/metallb_unstable/\$repo/\$arch" | sudo tee -a /etc/pacman.conf

Step 2.2: Install Kubernetes Components

Now that we have added the GitHub repository, let’s install Kubernetes components using the pacman package manager. Run the following command:

sudo pacman -S kubectl kubeadm kubelet

Step 2.3: Enable Kubernetes Services

Once we have installed Kubernetes, we need to start and enable its services to use.

sudo systemctl enable kubelet.service
sudo systemctl start kubelet.service

Step 3: Configure Kubernetes

Before configuring Kubernetes master and worker nodes, we need to swap off and disable the swap memory. Kubernetes requires memory management and doesn’t support swap memory.

sudo swapoff -a
sudo sed -i '/ swaps/ s/^\(.*\)$/#\1/g' /etc/fstab

Step 4: Initialize Kubernetes

Now, let’s initialize Kubernetes on the master node using the kubeadm utility. Run the following command:

sudo kubeadm init --pod-network-cidr=192.168.0.0/16

This command initializes a single Kubernetes control-plane node in the cluster. Configurations of both Master and Kubectl are saved in /etc/kubernetes/.

After a successful initialization, you will get a command at the end of the output to deploy the pod network add-on.

Step 5: Deploy a Pod Network Addon

A pod network add-on is required for communicating between different nodes and pods. We will deploy Calico CNI (Container Network Interface), which is commonly used with Kubernetes.

sudo kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

Once we deploy the pod network add-on successfully, all worker nodes join the cluster automatically.

Step 6: Join Kubernetes Nodes

If you have worker nodes, you need to join them to the Kubernetes cluster. We assume that the worker nodes have a network connection to the master node.

Run the following command on each worker node:

sudo kubeadm join <MASTER_NODE_IP_ADDRESS>:6443 --token <TOKEN> \ 
--discovery-token-ca-cert-hash <CERT-HASH>

Conclusion

In conclusion, Kubernetes is an open-source platform for managing containerized applications. By following this tutorial, you have now learned how to install Kubernetes on Manjaro. We hope that this guide has provided you with essential knowledge and steps to get started with Kubernetes installation.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!