Learn how to install and configure a Kubernetes runtime on Alma Linux in order to deploy the EJBCA container for testing.

MicroK8s is a Kubernetes distribution designed to be small and responsive and to include required components only. It is fast and efficient to use, with several useful tools that can be activated via the command line.

In this tutorial, you will learn how to:

  • Install Microk8s on Alma Linux using Snap
  • Configure the account logged into the server to interact with Kubernetes
  • Configure supporting Kubernetes services (such as DNS, Ingress, MetalLB, HELM, and Persistent Storage Claims)

Prerequisites

Before you begin, you need an Alma Linux server or virtual machine, SSH access, and root or sudo access for installing the software used in this tutorial.

Step 1 - Setup server

To configure the server to interact with Kubernetes, follow these steps:

  1. Use SSH to access the server.
  2. In your terminal, enter the following:

    $ sudo hostnamectl set-hostname microk8-01
    $ sudo bash -c 'echo "$(hostname -I) microk8-01" >> /etc/hosts'
    $ sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
    $ sudo setenforce Permissive
    $ sudo systemctl stop firewalld
    $ sudo systemctl disable firewalld
    $ sudo dnf install -y epel-release vim
    CODE

    This sets the hostname of the server, updates the hosts file, sets the SELinux mode to permissive, and stops and disables the FirewallD service. This will also install the Extra Packages for Enterprise Linux (EPEL) library needed.

The server is now configured and you can install MicroK8s next.

Step 2 - Install MicroK8s using Snap

MicroK8s installs as a snap package and deploys on the server using the sudo snap install microk8s --classic command.

Snap is a software packaging and deployment system developed by Canonical. Snaps are applications packaged with all their dependencies to run on all popular Linux distributions from a single build and snapd is the background service that manages and maintains your snap environment. 

To install MicroK8s and configure the current user to interact with MicroK8s:

  • In your terminal, run the following:

    $ sudo dnf install -y snapd jq
    $ sudo systemctl enable --now snapd.socket
    $ sudo ln -s /var/lib/snapd/snap /snap
    
    # Pause for 10 seconds before running the next command
    
    $ sudo snap install microk8s --classic
    $ sudo snap alias microk8s.kubectl kubectl
    $ source /etc/profile.d/snapd.sh
    $ sudo usermod -a -G microk8s user
    $ newgrp microk8s
    $ mkdir ~/.kube
    $ sudo chown -f -R user ~/.kube
    $ cd ~/.kube
    $ microk8s config > config
    $ cd
    $ kubectl get all,ingress,secret,no --all-namespaces
    CODE

MicroK8s is now installed and is ready to be configured with supporting services.

Step 3 - Deploy supporting Kubernetes services

Now that MicroK8s is installed, deploy supporting Kubernetes services  to make the containers accessible.

To deploy supporting services, such as DNS, Ingress, MetalLB, Helm, and Persistent Storage Claims:

  • In your terminal, enter the following:

    $ microk8s enable dns ingress hostpath-storage helm
    $ microk8s enable metallb
    $ sudo snap alias microk8s.helm helm
    $ kubectl get all,ingress,secret,no --all-namespaces
    CODE

    Enabling MetalLB on MicroK8s provides external access and allows EJBCA enrollment outside of the Kubernetes environment.

Next steps

In this tutorial, you learned how to install Microk8s using Snap and deploy supporting Kubernetes services.

To learn how to deploy the EJBCA container in the MicroK8s environment, you can follow the tutorial Deploy EJBCA container in MicroK8s.