You deploy Microk8s because you want lightweight Kubernetes on your laptop or edge node, not a weekend-long YAML safari. Then you add MongoDB for persistence, and suddenly you’re neck-deep in connection strings, persistent volumes, and weird DNS quirks. It should be simple. It can be simple.
Microk8s gives you fast, single-node Kubernetes with optional add-ons for storage, ingress, and observability. MongoDB provides flexible, document-based storage that scales horizontally with ease. Together they make a strong local or production-ready lab for stateful apps. The trick is wiring them so the pods talk the same language without drifting from dev to prod.
There are two parts: the cluster and the database. Microk8s handles the orchestration, while MongoDB manages the data layer. The integration hinges on three clean steps: expose stateful storage, configure credentials through Kubernetes Secrets, and verify connectivity using an internal service name. No port-forward gymnastics or mystery connection failures if DNS and namespaces are consistent.
Keep secrets where they belong. Use Kubernetes Secrets or external vault integrations rather than hardcoded credentials. When scaling Microk8s, use the built-in microk8s add-node flow to ensure new nodes share the same storage class and networking layer. MongoDB’s replica sets should detect and adapt automatically if persistent volumes are bound correctly.
Most “it doesn’t connect” errors in Microk8s MongoDB setups trace to DNS mismatches. Your pods try mongodb.default.svc.cluster.local while you configured a direct IP from a host machine. Keep it internal. Let Microk8s manage service discovery. You’ll sleep better.