Best Steps To Set up k3d on AlmaLinux 9

This guide intends to teach you to Set up k3d on AlmaLinux 9. k3d is a small program made for running a K3s cluster in Docker. K3s is a lightweight, CNCF-certified Kubernetes distribution and Sandbox project. Designed for low-resource environments, K3s is distributed as a single binary that uses under 512MB of RAM. 

k3d uses a Docker image built from the K3s repository to spin up multiple K3s nodes in Docker containers on any machine with Docker installed. That way, a single physical (or virtual) machine (let’s call it Docker Host) can run multiple K3s clusters, with multiple server and agent nodes each, simultaneously.

Now you can follow the guide steps below on the Orcacore website to set up k3d on AlmaLinux 9.

Steps To Set up k3d on AlmaLinux 9

To run the k3s cluster in Docker with k3d, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

K3d whole depends on docker. So you need to have Docker installed on your server. To do this, you can follow our guide on Install and Use Docker on AlmaLinux 9.

1. Install kubectl on AlmaLinux 9

At this point, you need to kubectl package to interact with the cluster we will be creating. To do this, run the commands below:

# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" 
# sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Then, verify your kubectl installation by checking its version:

kubectl version --output=yaml
Verify kubectl installation

2. Enable ip_tables module on AlmaLinux 9

K3d comes with traefik and it will need iptables to enable some routing. Now you need to use the command below to enable the ip_tables module:

# sudo modprobe ip_tables
# echo 'ip_tables' | sudo tee -a /etc/modules

3. Install k3d on AlmaLinux 9

At this point, you can use the following command to download and install k3d on your server:

wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
Output
Preparing to install k3d into /usr/local/bin
k3d installed into /usr/local/bin/k3d

4. How To Use k3d?

At this point, we want to show you to create a single-node cluster with k3d. To do this, you can use the following command. You can choose your desired name.

k3d cluster create orcacluster

You’ll see the following output as it creates your cluster:

create a single-node cluster with k3d

It will automatically create a KubeConfig file at “~/.kube/config” and hence you can immediately begin interacting with your cluster via the “kubectl” command. So let us check our cluster information:

kubectl cluster-info
Output
Kubernetes control plane is running at https://0.0.0.0:45135
CoreDNS is running at https://0.0.0.0:45135/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://0.0.0.0:45135/api/v1/namespaces/kube-system/services/https:metrics-server:https/proxy

Also, you can view the pods by using the command below:

kubectl get pods -n kube-system
Output
NAME                                      READY   STATUS      RESTARTS   AGE
coredns-597584b69b-654kg                  1/1     Running     0          4m33s
local-path-provisioner-79f67d76f8-pzlp8   1/1     Running     0          4m33s
helm-install-traefik-crd-bhqhh            0/1     Completed   0          4m33s
metrics-server-5f9f776df5-vtszz           1/1     Running     0          4m33s
helm-install-traefik-55rrs                0/1     Completed   2          4m33s
svclb-traefik-188963af-jhzbm              2/2     Running     0          3m57s
traefik-66c46d954f-k25gc                  1/1     Running     0          3m57s

At this point, you are ready to deploy your applications to test them locally or do your various playful escapades with them.

Conclusion

k3d is a lightweight tool used to run K3s cluster in Docker containers. It is commonly used for creating Kubernetes clusters for local development, testing, or CI/CD pipelines. At this point, you have learned to Set up k3d on AlmaLinux 9.

Hope you enjoy it. You may also interested in these articles:

Install and Use SQLite on AlmaLinux 9

Install and Use Podman on AlmaLinux 9

GNU Image Manipulation Program on AlmaLinux 9

Sendmail mail server setup AlmaLinux 9

Cinnamon Desktop For AlmaLinux 9

Add and Remove Users on AlmaLinux 9

AlmaLinux 9: Run Nginx in a Docker Container

Froxlor Server Management For AlmaLinux 9

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!