Step-by-Step Guide to Installing Kubernetes Using Microk8s on AlmaLinux 9
In this guide, we’ll show you how to install Kubernetes on AlmaLinux 9 using Microk8s. Microk8s is an easy and lightweight way to run Kubernetes on your local system. Let’s go through the steps in a simple and clear manner.
What You’ll Need:
Detailed Instructions to Install Kubernetes Using Microk8s on AlmaLinux 9
Step 1: Install EPEL (Extra Packages for Enterprise Linux)
First, you need to install the EPEL repository, which provides extra software packages. Open your terminal and run:
[root@bastion ~]# dnf install epel-release
This command will install the EPEL repository.
Step 2: Update Your System
Before installing anything new, it's good practice to update your system. Run the following command to update all the software:
[root@bastion ~]# dnf upgrade
This will make sure everything is up-to-date.
Step 3: Install Snap Package Manager
Next, we need to install Snap, which is a package manager used to install Microk8s. Type the following command:
[root@bastion ~]# dnf install snapd
Snap will allow us to easily install Microk8s.
Step 4: Enable Snapd
Now, we need to start Snapd so it can be used immediately. Run this command:
[root@bastion ~]# systemctl enable --now snapd.socket
This command enables Snapd and starts it right away.
Step 5: Create a Shortcut for Snap
We need to create a symbolic link (a shortcut) for Snap. This helps some systems find the Snap directory easily. Type:
[root@bastion ~]# ln -s /var/lib/snapd/snap /snap
This command creates a link to the Snap directory.
Step 6: Install Microk8s
Now, let’s install Microk8s using Snap. Type this command:
[root@bastion ~]# snap install microk8s --classic
After a short while, you should see a message like:
microk8s (1.27/stable) v1.27.2 from Canonical? installed
This means Microk8s is successfully installed.
Step 7: Add Snap to System Path
Next, we need to make sure your system can easily find Microk8s when you type the commands. To do this, we will add Snap to the system's PATH. Type:
领英推荐
[root@bastion ~]# sudo visudo
In the file that opens, add this line:
Defaults ? secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/snap/bin/
Then save and exit the file.
Step 8: Reload the Shell
For the changes to take effect, we need to reload the shell. Do this by running:
[root@bastion ~]# exec $SHELL
Now, your system will recognize Microk8s commands.
Step 9: Check Microk8s Status
To make sure Microk8s is running, check its status by typing:
[root@bastion ~]# microk8s status --wait-ready
You should see output like this:
microk8s is running
high-availability: no
datastore master nodes: 127.0.0.1:19001
datastore standby nodes: none
This means that Microk8s is up and running.
Step 10: Enable Add-ons
Microk8s comes with many add-ons to enhance Kubernetes. Let’s enable some important ones, like the dashboard, DNS, and registry. Run the command:
[root@bastion ~]# microk8s enable dashboard dns registry istio
This will enable these useful add-ons.
Step 11: Get Access to the Dashboard
To log in to the Kubernetes dashboard, you’ll need a token. To get the token, type the following command:
[root@bastion ~]# microk8s kubectl describe secret -n kube-system microk8s-dashboard-token
You’ll see a token in the output. Copy this token as you will need it to log in.
Step 12: Open the Dashboard
To access the Kubernetes dashboard, run this command:
[root@bastion ~]# microk8s dashboard-proxy
You’ll get a URL like this:
https://192.168.1.70:10443/#/login
Copy the URL and paste it into your browser. Use the token from Step 11 to log in to the dashboard.
Conclusion
Congratulations! You have successfully installed Kubernetes using Microk8s on AlmaLinux 9. Now, you can manage your Kubernetes cluster, enable add-ons, and use the dashboard to monitor and manage everything.
This setup gives you an easy way to run Kubernetes on your local machine, making it perfect for learning and experimenting with container management.