DEV Community

Cover image for 🧱 Part 1 β€” Production-Ready MicroK8s Installation on Debian 12 (with snapd)
kamlesh merugu
kamlesh merugu

Posted on • Edited on

🧱 Part 1 β€” Production-Ready MicroK8s Installation on Debian 12 (with snapd)

This guide sets up a secure, production-grade MicroK8s Kubernetes cluster on Debian 12, ready for deploying:

  • n8n workflows
  • Postgres & Redis
  • Observabilit y stack (Prometheus, Grafana, Loki)
  • Centralized secrets (Doppler, in Part 2)

⚠️ Follow every step carefullyβ€”skipping steps can break the cluster.


βœ… Supported Systems

  • Debian 12 (Bookworm) LTS
  • VPS, VM, or bare-metal
  • Minimum: 2 vCPU, 4 GB RAM

πŸ”§ Step 1 β€” Update & Prepare the Server

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

Reconnect after reboot. Install essential tools:

sudo apt install -y \
  curl wget git vim htop neofetch \
  apt-transport-https ca-certificates gnupg lsb-release
Enter fullscreen mode Exit fullscreen mode

βœ… System updated and ready for Kubernetes.


πŸ‘€ Step 2 β€” Create a Deployment User (Optional but Recommended)

Kubernetes should never run as root.

sudo adduser deploy
sudo usermod -aG sudo deploy
echo "deploy ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/deploy
sudo chmod 440 /etc/sudoers.d/deploy
su - deploy
Enter fullscreen mode Exit fullscreen mode

πŸ” Step 3 β€” Disable Swap

sudo swapoff -a
sudo sed -i '/\sswap\s/s/^/#/' /etc/fstab
free -h
Enter fullscreen mode Exit fullscreen mode

Swap should show 0B.


🌐 Step 4 β€” Kernel Modules & Networking

sudo tee /etc/modules-load.d/k8s.conf <<EOF
br_netfilter
EOF

sudo modprobe br_netfilter

sudo tee /etc/sysctl.d/99-k8s.conf <<EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF

sudo sysctl --system
sysctl net.ipv4.ip_forward
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ Step 5 β€” Install snapd

MicroK8s is distributed as a Snap package.

sudo apt install -y snapd
sudo systemctl enable --now snapd
sudo systemctl enable --now snapd.socket
Enter fullscreen mode Exit fullscreen mode

Verify snap:

snap version
Enter fullscreen mode Exit fullscreen mode

πŸš€ Step 6 β€” Install Latest MicroK8s

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

Adjust the channel to the desired stable version.


🧠 Step 7 β€” Add Deploy User to MicroK8s Group

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

Important: Log out and back in, or use:

newgrp microk8s
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 8 β€” Enable Core Addons

MicroK8s includes essential production addons:

microk8s status --wait-ready
microk8s enable dns storage ingress metrics-server
Enter fullscreen mode Exit fullscreen mode
  • dns β€” service discovery
  • storage β€” dynamic persistent volumes
  • ingress β€” NGINX ingress controller
  • metrics-server β€” node & pod metrics

🧰 Step 9 β€” Setup kubectl for Deploy User

MicroK8s ships its own kubectl. To avoid typing microk8s.kubectl:

sudo snap alias microk8s.kubectl kubectl
Enter fullscreen mode Exit fullscreen mode

Optional: export kubeconfig for scripts/CI:

mkdir -p $HOME/.kube
microk8s config > $HOME/.kube/config
chmod 600 $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
echo 'export KUBECONFIG=$HOME/.kube/config' >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

🌍 Step 10 β€” Optional: Remote kubectl Access

microk8s config > kubeconfig.yaml
scp kubeconfig.yaml user@localmachine:~/.kube/config
Enter fullscreen mode Exit fullscreen mode

Adjust server: IP if needed for external access.


βž• Step 11 β€” Add Worker Nodes (Optional)

microk8s add-node
Enter fullscreen mode Exit fullscreen mode

Follow instructions on worker nodes. Verify:

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

πŸ”Ž Step 12 β€” Verify Cluster Health

microk8s status --wait-ready
kubectl get nodes
kubectl get pods -A
kubectl cluster-info
Enter fullscreen mode Exit fullscreen mode

All kube-system pods should be Running.


βœ… What You’ve Achieved

  • MicroK8s installed via Snap on Debian 12
  • Deploy user configured with group membership
  • Kernel & networking configured for Kubernetes
  • Swap disabled, core addons enabled
  • kubectl working for non-root deploy user
  • Ready for n8n, Postgres, Redis, observability, and secrets

πŸš€ Next Steps (Part 2)

  • Setup centralized secrets with Doppler
  • Install External Secrets Operator
  • Prepare namespaces & secret sync for workloads

Top comments (0)