DEV Community

Cover image for Part 2: Installing MicroK8s on Ubuntu 24.04+ (4-Core, 8GB RAM, 120GB Storage VPS)
kamlesh merugu
kamlesh merugu

Posted on

Part 2: Installing MicroK8s on Ubuntu 24.04+ (4-Core, 8GB RAM, 120GB Storage VPS)

MicroK8s is a powerful yet lightweight Kubernetes distribution perfect for:

  • πŸš€ Developers testing Kubernetes locally
  • πŸ§ͺ CI/CD environments
  • 🏠 Homelabs
  • πŸ› οΈ Edge and IoT systems
  • 🧩 Single-node or small clusters

This configuration is ideal for running MicroK8s with multiple workloads, monitoring tools, and CI/CD pipelines.


πŸ“‹ What You'll Learn

In this guide, you will:

  • ✨ Install MicroK8s
  • πŸ”’ Configure user permissions
  • 🧰 Enable essential add-ons
  • πŸ§ͺ Verify the cluster is running
  • πŸŽ‰ Deploy a test application
  • πŸ”„ Ensure services autostart on boot

❓ Why MicroK8s?

MicroK8s is:

  • Lightweight πŸͺΆ β€” Minimal resource footprint
  • Easy to install ⚑ β€” One command setup
  • Zero external dependencies 🎯 β€” Everything bundled
  • Production-ready πŸ”₯ β€” Enterprise-grade
  • Beginner-friendly and pro-friendly πŸ‘¨β€πŸ’» β€” Great for learning and production

It includes core Kubernetes components and plug-and-play add-ons like DNS, Ingress, Helm, and the Dashboard.


πŸ“¦ Install MicroK8s

Update your system

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

Install MicroK8s via Snap

sudo snap install microk8s --classic
Enter fullscreen mode Exit fullscreen mode

This will take a few minutes. MicroK8s installs the latest stable Kubernetes release.

Verify installation

sudo microk8s status --wait-ready
Enter fullscreen mode Exit fullscreen mode

Expected output:

microk8s is running
high-availability: no
  datastore master nodes: 127.0.0.1:19001
  datastore standby nodes: none
Enter fullscreen mode Exit fullscreen mode

πŸŽ‰ Kubernetes is up and running!


πŸ‘₯ Add Your User to the MicroK8s Group

MicroK8s has its own Unix group for permissions. Add your user to avoid using sudo every time:

sudo usermod -a -G microk8s $USER
sudo chown -R $USER ~/.kube
Enter fullscreen mode Exit fullscreen mode

Apply group changes immediately (or log out and back in):

newgrp microk8s
Enter fullscreen mode Exit fullscreen mode

Now you can run microk8s commands without sudo!


πŸ”§ Enable Essential Kubernetes Add-ons

Recommended add-ons

Enable DNS for service discovery:

microk8s enable dns
Enter fullscreen mode Exit fullscreen mode

Enable storage for persistent volumes:

microk8s enable storage
Enter fullscreen mode Exit fullscreen mode

Enable Ingress for external access:

microk8s enable ingress
Enter fullscreen mode Exit fullscreen mode

Optional but useful add-ons

Enable Helm package manager:

microk8s enable helm
Enter fullscreen mode Exit fullscreen mode

Enable Kubernetes Dashboard:

microk8s enable dashboard
Enter fullscreen mode Exit fullscreen mode

Enable Metrics Server (for monitoring):

microk8s enable metrics-server
Enter fullscreen mode Exit fullscreen mode

Check status

microk8s status
Enter fullscreen mode Exit fullscreen mode

You should see all enabled add-ons listed as active.


πŸ§ͺ Test Your Kubernetes Cluster

Check node status

microk8s kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

Expected output:

NAME       STATUS   ROLES   AGE   VERSION
hostname   Ready    <none>  5m    v1.31.3
Enter fullscreen mode Exit fullscreen mode

STATUS should be Ready βœ…

Check system pods

microk8s kubectl get pods --all-namespaces
Enter fullscreen mode Exit fullscreen mode

All components should show Running or Completed status:

NAMESPACE     NAME                                     READY   STATUS    RESTARTS   AGE
kube-system   calico-node-xxxxx                        1/1     Running   0          5m
kube-system   coredns-xxxxx                            1/1     Running   0          4m
ingress       nginx-ingress-microk8s-controller-xxxxx  1/1     Running   0          3m
Enter fullscreen mode Exit fullscreen mode

If everything shows Running, your cluster is healthy! πŸŽ‰


🐳 Deploy a Test NGINX App

Let's deploy a simple NGINX workload to verify everything works:

Create deployment

microk8s kubectl create deployment nginx --image=nginx
Enter fullscreen mode Exit fullscreen mode

Expose the deployment

microk8s kubectl expose deployment nginx --port=80 --type=NodePort
Enter fullscreen mode Exit fullscreen mode

Get service details

microk8s kubectl get svc nginx
Enter fullscreen mode Exit fullscreen mode

You'll see output like:

NAME    TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
nginx   NodePort   10.152.183.45   <none>        80:31234/TCP   10s
Enter fullscreen mode Exit fullscreen mode

Note the NodePort (e.g., 31234).

Access the application

Open your browser and visit:

http://your-server-ip:31234
Enter fullscreen mode Exit fullscreen mode

If you see the NGINX welcome page β†’ πŸŽ‰ Your Kubernetes cluster is working perfectly!

Check deployment status

microk8s kubectl get deployments
Enter fullscreen mode Exit fullscreen mode
microk8s kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Both should show your nginx deployment running.


πŸ”„ Ensuring MicroK8s Auto-Starts on Boot

Since MicroK8s is installed via Snap, systemctl cannot be used directly. Snap manages startup behavior automatically, but let's verify.

βœ”οΈ Step 1: Check Service Autostart

sudo snap services microk8s
Enter fullscreen mode Exit fullscreen mode

You should see:

Service                              Status   Startup  Notes
microk8s.daemon-apiserver            active   enabled  -
microk8s.daemon-kubelet              active   enabled  -
microk8s.daemon-scheduler            active   enabled  -
microk8s.daemon-controller-manager   active   enabled  -
microk8s.daemon-containerd           active   enabled  -
Enter fullscreen mode Exit fullscreen mode

If all services show Startup: enabled, MicroK8s is set to autostart βœ…

βœ”οΈ Step 2: Enable Autostart Manually (If Needed)

If any services show disabled, run:

sudo snap start --enable microk8s.daemon-apiserver
sudo snap start --enable microk8s.daemon-kubelet
sudo snap start --enable microk8s.daemon-scheduler
sudo snap start --enable microk8s.daemon-controller-manager
sudo snap start --enable microk8s.daemon-containerd
Enter fullscreen mode Exit fullscreen mode

Then verify again:

sudo snap services microk8s
Enter fullscreen mode Exit fullscreen mode

βœ”οΈ Step 3: Reboot & Validate

Reboot the server to test autostart:

sudo reboot
Enter fullscreen mode Exit fullscreen mode

After logging back in, run:

microk8s status --wait-ready
Enter fullscreen mode Exit fullscreen mode

If you see:

microk8s is running
Enter fullscreen mode Exit fullscreen mode

Then autostart is confirmed! πŸŽ‰

Verify your NGINX app survived the reboot

microk8s kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Your nginx pod should still be running.


πŸ’Ύ Resource Usage Check

Check how much of your 8GB RAM MicroK8s is using:

free -h
Enter fullscreen mode Exit fullscreen mode

Check disk usage (out of 120GB):

df -h
Enter fullscreen mode Exit fullscreen mode

MicroK8s typically uses:

  • ~500MB-1GB RAM at idle
  • ~2-3GB storage for base installation

This leaves plenty of resources for your workloads! πŸš€


πŸ› οΈ Troubleshooting Tools

Check cluster health

sudo microk8s inspect
Enter fullscreen mode Exit fullscreen mode

This generates a detailed report and tarball for debugging.

Restart MicroK8s

sudo microk8s stop
sudo microk8s start
Enter fullscreen mode Exit fullscreen mode

Check kubelet logs

journalctl -u snap.microk8s.daemon-kubelet -f
Enter fullscreen mode Exit fullscreen mode

Check API server logs

journalctl -u snap.microk8s.daemon-apiserver -f
Enter fullscreen mode Exit fullscreen mode

View all MicroK8s logs

sudo microk8s inspect | grep -i error
Enter fullscreen mode Exit fullscreen mode

🎨 (Optional) Access Kubernetes Dashboard

If you enabled the dashboard, get the access token:

microk8s kubectl describe secret -n kube-system microk8s-dashboard-token
Enter fullscreen mode Exit fullscreen mode

Copy the token, then access the dashboard:

microk8s dashboard-proxy
Enter fullscreen mode Exit fullscreen mode

This will output a URL like:

https://127.0.0.1:10443
Enter fullscreen mode Exit fullscreen mode

Use SSH tunneling to access it from your local machine:

ssh -L 10443:127.0.0.1:10443 username@your-server-ip
Enter fullscreen mode Exit fullscreen mode

Then visit https://127.0.0.1:10443 in your browser and paste the token.


πŸ“‹ Summary Checklist

Step Purpose Status
βœ… Install MicroK8s Kubernetes runtime Done
βœ… Add user to group Non-root access Done
βœ… Enable add-ons DNS, storage, ingress Done
βœ… Test with kubectl Validate cluster Done
βœ… Deploy NGINX Confirm workload scheduling Done
βœ… Enable autostart Ensure services start on boot Done
βœ… Verify resources Check RAM/CPU/disk usage Done

🧹 Clean Up Test Deployment (Optional)

Once you've verified everything works, you can remove the test NGINX deployment:

microk8s kubectl delete deployment nginx
microk8s kubectl delete service nginx
Enter fullscreen mode Exit fullscreen mode

🎯 Final Thoughts

Congratulations! πŸŽ‰ Your 4-core, 8GB RAM, 120GB Ubuntu server is now running a fully functional MicroK8s cluster!

πŸ”™ Previous Guide

πŸ‘ˆ Back to Part 1: Prerequisites & Basic Ubuntu Setup


πŸ”œ What's Next?

Ready to deploy production applications? πŸš€

πŸ‘‰ Continue to Part 3: Production Namespace, App Deployment, Backups & Restore

In Part 3, you'll learn how to:

  • πŸ—οΈ Create production namespaces for workload isolation
  • πŸš€ Deploy real applications with proper configurations
  • πŸ“¦ Set up persistent storage for databases and stateful apps

Top comments (0)