Skip to main content

Configure MicroK8s Cluster

This document outlines the steps required to install and configure a MicroK8s cluster in an Ubuntu environment.

Installation

Follow these steps to install MicroK8s and prepare your environment:

  1. Install MicroK8s:
    MicroK8s will install a minimal, lightweight Kubernetes you can run and use on practically any machine. Run the following command to install MicroK8s via snap on the specified channel:

    sudo snap install microk8s --classic --channel=1.32
    sudo usermod -a -G microk8s $USER
    mkdir -p ~/.kube
    chmod 0700 ~/.kube
  2. Apply Changes: Close and reopen your session to apply the group changes.

Integrating OpenEBS CAS Storage

Please ensure that iSCSI is installed and enabled on all nodes. Please follow the below steps to verify and enable iSCSI on your system:

  • Check iSCSI Status:
    • Verify the status of the iscsid daemon, which manages iSCSI sessions:
  systemctl status iscsid
  • Enable iSCSI Service:
    • If the iSCSI service is not active, enable it using the below command:
    sudo systemctl enable --now iscsid

Required Add-ons

Enhance your MicroK8s cluster capabilities by enabling the following add-ons:

microk8s enable ingress
microk8s enable community
microk8s enable openebs

Set Up kubectl for MicroK8s Management

microk8s config > ~/.kube/config

Configure MicroK8s kubectl Alias

echo "alias kubectl='microk8s kubectl'" >> ~/.bashrc && source ~/.bashrc

Note: This alias ensures all kubectl commands target your MicroK8s cluster, simplifying management and avoiding potential configuration conflicts.

Setting Default Storage Class

For Single-Node Cluster

To set openebs-hostpath as the default storage class, run the following command:

kubectl annotate storageclass openebs-hostpath storageclass.kubernetes.io/is-default-class=true

For Multi-Node Cluster

To set openebs-jiva-csi-default as the default storage class, execute:

kubectl annotate storageclass openebs-jiva-csi-default storageclass.kubernetes.io/is-default-class=true

Install Metrics Server (Optional)

helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm upgrade --install --set args={--kubelet-insecure-tls} metrics-server metrics-server/metrics-server --namespace kube-system