MicroK8s Setup Guide: Run Kubernetes Locally in Minutes
Learn how to install and configure MicroK8s for local Kubernetes development. Step-by-step tutorial covering installation, addons, and cluster management.
CKA Certified Engineer
TL;DR
MicroK8s is a lightweight Kubernetes distribution perfect for local development. Install with snap, enable addons like DNS and dashboard, and start deploying pods in minutes.
Key Takeaways
- 1 MicroK8s is the fastest way to get a local Kubernetes cluster running
- 2 Use snap install on Linux or native installers for Mac/Windows
- 3 Enable essential addons: dns, storage, dashboard, and registry
- 4 MicroK8s works identically to production Kubernetes
- 5 Perfect for learning, development, and CI/CD pipelines
Setting up a local Kubernetes cluster is essential for development and learning. MicroK8s is one of the easiest ways to get started - it’s lightweight, fast, and provides a production-grade Kubernetes experience on your local machine.
What is MicroK8s?
MicroK8s is a lightweight, pure-upstream Kubernetes distribution developed by Canonical (the company behind Ubuntu). Unlike other local Kubernetes options, MicroK8s:
- Installs in seconds with a single command
- Uses minimal resources - runs on as little as 540MB RAM
- Stays up-to-date with the latest Kubernetes releases
- Includes optional addons for common functionality
- Works offline once installed
MicroK8s vs Other Local Kubernetes Options
| Feature | MicroK8s | Minikube | kind | k3s |
|---|---|---|---|---|
| Installation | Snap/installer | Binary + VM | Binary + Docker | Binary |
| Resource usage | Low | Medium | Low | Very low |
| Startup time | Fast | Slow | Fast | Fast |
| Addons | Built-in | Limited | None | Helm |
| Multi-node | Yes | Limited | Yes | Yes |
Prerequisites
Before installing MicroK8s, ensure you have:
- Linux: Ubuntu 18.04+ or any snap-enabled distro
- macOS: macOS 10.13+ with Homebrew
- Windows: Windows 10+ with Hyper-V or VirtualBox
- At least 4GB RAM (8GB recommended)
- 20GB free disk space
Installing MicroK8s
Linux Installation (Ubuntu/Debian)
The fastest installation is via snap:
sudo snap install microk8s --classic
Add your user to the microk8s group to avoid using sudo:
sudo usermod -a -G microk8s $USER
sudo chown -R $USER ~/.kube
newgrp microk8s
macOS Installation
Install using Homebrew:
brew install ubuntu/microk8s/microk8s
microk8s install
Or download the installer from the MicroK8s website.
Windows Installation
- Enable Hyper-V in Windows Features
- Download the installer from microk8s.io
- Run the installer and follow the prompts
Or use Chocolatey:
choco install microk8s
Verifying Your Installation
Check that MicroK8s is running:
microk8s status --wait-ready
You should see output like:
microk8s is running
high-availability: no
datastore master nodes: 127.0.0.1:19001
datastore standby nodes: none
Check the Kubernetes version:
microk8s kubectl version
Configuring Essential Addons
MicroK8s comes with optional addons that extend functionality. Enable the essential ones:
DNS (Required for Most Workloads)
microk8s enable dns
DNS allows pods to discover services by name - almost every application needs this.
Storage
microk8s enable hostpath-storage
Enables persistent volume claims for stateful applications.
Dashboard
microk8s enable dashboard
Provides a web UI for cluster management.
Container Registry
microk8s enable registry
Local Docker registry for pushing and pulling images.
Enable Multiple Addons at Once
microk8s enable dns storage dashboard registry
View All Available Addons
microk8s status
Popular addons include:
ingress- NGINX ingress controllercert-manager- TLS certificate managementprometheus- Monitoring and metricsistio- Service meshgpu- NVIDIA GPU support
Using kubectl with MicroK8s
MicroK8s includes its own kubectl. Use it with the microk8s prefix:
microk8s kubectl get nodes
microk8s kubectl get pods -A
Creating a kubectl Alias
For convenience, create an alias:
# Add to ~/.bashrc or ~/.zshrc
alias kubectl='microk8s kubectl'
Or export the kubeconfig:
microk8s config > ~/.kube/config
Now you can use standard kubectl commands:
kubectl get nodes
kubectl get pods -A
Deploying Your First Application
Let’s deploy a simple nginx pod to verify everything works. If you’re new to pods, check our Kubernetes Pods beginner guide for detailed explanations.
Create a Pod
microk8s kubectl run my-nginx --image=nginx:latest --port=80
Verify the Pod is Running
microk8s kubectl get pods
Expected output:
NAME READY STATUS RESTARTS AGE
my-nginx 1/1 Running 0 30s
Expose the Pod as a Service
microk8s kubectl expose pod my-nginx --type=NodePort --port=80
Access Your Application
microk8s kubectl get services my-nginx
Note the NodePort (e.g., 30123) and access the app at http://localhost:30123.
Accessing the Kubernetes Dashboard
After enabling the dashboard addon:
# Get the access token
microk8s kubectl describe secret -n kube-system microk8s-dashboard-token
Start the dashboard proxy:
microk8s dashboard-proxy
Open the URL shown (usually https://127.0.0.1:10443) and paste the token to log in.
Managing Your MicroK8s Cluster
Start and Stop
# Stop the cluster (saves resources)
microk8s stop
# Start the cluster
microk8s start
Check Cluster Status
microk8s status
microk8s inspect
View Logs
# Kubernetes API server logs
microk8s kubectl logs -n kube-system -l k8s-app=kube-apiserver
Reset the Cluster
Start fresh by removing all workloads:
microk8s reset
Configuring MicroK8s for Development
Increase Resource Limits
Edit the MicroK8s configuration:
sudo nano /var/snap/microk8s/current/args/kubelet
Add resource configurations as needed.
Configure Private Registry Access
To pull images from private registries:
# Create registry credentials
microk8s kubectl create secret docker-registry my-registry \
--docker-server=registry.example.com \
--docker-username=user \
--docker-password=password
Local Development Workflow
- Build your Docker image locally
- Push to the MicroK8s registry:
docker build -t localhost:32000/myapp:latest .
docker push localhost:32000/myapp:latest
- Deploy to MicroK8s:
microk8s kubectl create deployment myapp --image=localhost:32000/myapp:latest
Multi-Node Clusters
MicroK8s supports multi-node clusters for testing distributed scenarios:
On the Primary Node
microk8s add-node
This outputs a join command.
On Worker Nodes
Run the join command from the primary node:
microk8s join 192.168.1.100:25000/abc123...
Verify Nodes
microk8s kubectl get nodes
Troubleshooting Common Issues
MicroK8s Won’t Start
# Check system status
microk8s inspect
# View detailed logs
sudo journalctl -u snap.microk8s.daemon-kubelite
DNS Not Working
# Restart CoreDNS
microk8s kubectl rollout restart deployment/coredns -n kube-system
Pods Stuck in Pending
# Check events
microk8s kubectl describe pod <pod-name>
# Verify storage addon
microk8s enable hostpath-storage
Permission Denied Errors
# Ensure user is in microk8s group
sudo usermod -a -G microk8s $USER
newgrp microk8s
MicroK8s Command Reference
| Command | Description |
|---|---|
microk8s status | Show cluster status and addons |
microk8s start | Start the cluster |
microk8s stop | Stop the cluster |
microk8s enable <addon> | Enable an addon |
microk8s disable <addon> | Disable an addon |
microk8s kubectl | Run kubectl commands |
microk8s config | Output kubeconfig |
microk8s reset | Reset cluster to clean state |
microk8s inspect | Diagnose cluster issues |
microk8s add-node | Generate join token |
Next Steps
With your local MicroK8s cluster running, you’re ready to explore Kubernetes further:
- Deploy applications - Start with our Kubernetes Pods guide to learn pod basics
- Secure your cluster - Learn about Network Policies to control pod communication
- Add monitoring - Enable the Prometheus addon for metrics
- Practice for certification - MicroK8s is perfect for CKA/CKAD exam preparation
Conclusion
MicroK8s provides the fastest path to a fully functional Kubernetes cluster on your local machine. With its simple installation, built-in addons, and minimal resource requirements, it’s ideal for development, learning, and CI/CD environments.
At Fraway, we help teams adopt Kubernetes for development and production workloads. Our certified engineers can assist with cluster setup, development workflows, and best practices. Contact us to accelerate your Kubernetes adoption.
Written by
Francesco
CKA Certified Engineer