This is the second blog in a series of blogs for setting up Microk8s. Link to part 1
MicroK8s simplifies the deployment of Kubernetes on Linux (Red Hat and Ubuntu). The blog explores how to install MicroK8s on Red Hat and Ubuntu.
Microk8s Linux Setup
Update the server with the latest updates and install Snap:
- Run all commands as root
- Clone or download files from GitHub link: https://github.com/arysdev/microk8s.git
When running Microk8s on Red Hat Linux, SELinux can prevent the proper functioning of the Microk8s components by blocking network communications or preventing access to specific files or directories.
Run the below command to disable SELinux.
Run the command below for Microk8s to use full memory resources.
Firewall Setup for microk8s
Open the ports below if the firewall is running.
You may need to configure your firewall to allow pod-to-pod and pod-to-internet communication:
For Red Hat:
The command below is for Red Hat Linux. This will install snapd in Red Hat Linux. Please refer to the documentation of your Linux flavor and the operating system.
Add a repo if you are using RHEL9 for Snapd installation.
Once the package has finished installing, the systemd unit that manages the main snap communication socket needs to be enabled as follows:
Furthermore, to enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap and /snap, then add snap to the PATH variable.
Use the below command to update the Ubuntu server before installing microk8s. Once the system is back, install microk8s.
Installation Steps for Installing MicroK8s.
For Red Hat:
Run the below command.
Log out and log in from the server.
Check the status by using the below command:
Check nodes by using the below command:
Check pods by using the below command:
Check services by using the below command:
Check resource utilization for nodes or pods by using the below command:
Change the type from ClusterIP to NodePort. Change the last line from type: ClusterIp to NodePort. Run the below in cmd.
Save and close.
You can get the nodeport from the below command it starts with a higher number port from 30000.
Allow firewall rule to access Microk8s Dashboard.
Check for the Port on which Dashboard is listening. Access it using https://<ipaddress>:<nodeport>.
Copy and paste the token into the browser to access the Kubernetes Dashboard.
Add a policy to the metric server. Run the below command.
Deploy the Nginx pod in microk8s and access it via ingress.
Create a deployment for the nginx webserver. Run the below command.
Expose service for nginx webserver as nodeport.
Go to your Web browser to access http://IPaddress:<nodeport>. You will see the nginx welcome page.
Great! You have successfully installed MicroK8s on your Linux system, deployed the nginx web server, and exposed it via ingress.
MicroK8s provides a lightweight and simplified way to deploy Kubernetes clusters on Red Hat and Ubuntu distributions, with its ease of installation and convenient management of essential Kubernetes.