How to Install MicroK8s on Ubuntu
MicroK8s is a lightweight Kubernetes distribution designed for developers and small-scale deployments. This guide will walk you through the steps to install MicroK8s on Ubuntu.
Step 1: Update System Packages
Before installing MicroK8s, update your system to ensure all packages are up to date:
sudo apt update && sudo apt upgrade -yStep 2: Install MicroK8s
Install MicroK8s using Snap:
sudo snap install microk8s --classicStep 3: Add User to MicroK8s Group
To avoid using sudo for MicroK8s commands, add your user to the microk8s group:
sudo usermod -aG microk8s $USER
newgrp microk8sStep 4: Verify Installation
Check the status of MicroK8s:
microk8s status --wait-readyStep 5: Enable Essential Add-ons
MicroK8s provides various add-ons that enhance its functionality. Enable some essential ones:
microk8s enable dns storage dashboardStep 6: Access Kubernetes with MicroK8s
By default, MicroK8s uses its own version of kubectl. You can run:
microk8s kubectl get nodesIf you prefer using kubectl directly, create an alias:
alias kubectl='microk8s kubectl'To make this alias persistent, add it to your shell configuration file:
echo "alias kubectl='microk8s kubectl'" >> ~/.bashrc
source ~/.bashrcStep 7: Check Cluster Information
To verify cluster details, run:
microk8s kubectl cluster-infoOptional: Enable MicroK8s on System Startup
If you want MicroK8s to start automatically after a reboot, enable it:
sudo snap enable microk8sUninstalling MicroK8s
If you need to remove MicroK8s from your system, use:
sudo snap remove microk8s