DEV Community

Metronom
Metronom

Posted on Edited on

Real Kubernetes on your laptop in ~2 minutes with k3d (and you can throw it away for free)

Chapter 5 of a local-Kubernetes series: the payoff chapter where you spin up an actual cluster. k3d gives you a real Kubernetes API, not an emulation, and it's so cheap to create and destroy that recreating from scratch is routine.

Key takeaways

  • k3s vs k3d: k3s is a certified, minimalist Kubernetes distro (whole control plane in one binary); k3d is a "lightweight wrapper to run k3s in Docker." Nodes are Docker containers.
  • Why it's fast: k3s defaults to embedded SQLite instead of etcd — no etcd cluster to stand up, so fast start and low memory. (Multiple server nodes auto-switch to embedded etcd.)
  • The one command to keep:
k3d cluster create dev \
  --servers 1 --agents 2 \
  --registry-create k3d-registry.localhost:5000 \
  -p "8081:80@loadbalancer"
Enter fullscreen mode Exit fullscreen mode

Built-in registry (the fix for chapter 1's ImagePullBackOff-from-local-Docker) + a forwarded port, in one line.

  • Context gotcha: k3d names the context k3d-dev, not dev. Always kubectl config current-context before anything destructive.
  • Registry naming: k3d prepends k3d-, so k3d registry create registry.localhost is referenced as k3d-registry.localhost:5000 in --registry-use and in image: fields. Push from host via localhost:5000.
  • Port-forwarding via serverlb with @loadbalancer (k3s ships Traefik) — but port forwards are fixed at creation time; to add one you recreate the cluster (cheap in k3d).
  • Honest "when to use kind or minikube instead": kind for strict upstream parity / conformance; minikube for learning + addons + VM isolation.

Full article: https://dorokhovich.com/blog/local-k8s-cluster-with-k3d?utm_source=devto&utm_medium=syndication&utm_campaign=local-k8s-cluster-with-k3d

Top comments (0)