K3s or k3d: the same Kubernetes in two very different places
Out of the box, K3s bundles an ingress controller, load balancer and storage class your production cluster probably lacks, so local K3s and k3d clusters pass what production rejects. Where each belongs, and why kind's bareness is a fidelity argument.
ON THIS PAGE
Out of the box, K3s is more than your production cluster. It brings its own ingress controller, load balancer and storage class, so an application developed on a local K3s or k3d cluster can lean on all three without anyone noticing, and production will reject what it never had. Between the two tools the choice is only where the cluster lives, because k3d is K3s running in Docker containers: K3s on a machine that will still be there next month, k3d on a laptop or in a CI job you create and delete per task. The gap that deserves your attention is the one between either of them and production.
This is part 1 of the Less than K8s series. Part 2 compares the throwaway clusters, kind and minikube; part 3, the distributions for machines that stay, k0s and MicroK8s.
K3s bundles more than production runs#
K3s is a fully conformant Kubernetes distribution packaged as a single binary, so manifests, Helm charts and kubectl habits carry over unchanged. To make a fresh install usable on its own, it adds what a bare cluster lacks. Three of those additions matter here: Traefik as the ingress controller; ServiceLB, which answers LoadBalancer Services by binding their ports on the nodes; and the local-path provisioner, which backs a local-path StorageClass with a directory on whichever node the pod lands on. Traefik is on unless you install with --disable=traefik. --disable=servicelb removes ServiceLB the same way.
A managed cluster usually brings a different ingress controller, a cloud load balancer and a network storage class, and the mismatch surfaces as an Ingress that works locally and fails in production. Say yours routes /api to a service that serves /users, and carries traefik.ingress.kubernetes.io/router.middlewares: default-strip-api@kubernetescrd, pointing at a Traefik StripPrefix middleware. Locally, Traefik strips the prefix and /api/users reaches the app as /users. Annotations belong to the controller that reads them, so production's controller ignores this one, the app receives /api/users, and it answers 404. The same Ingress probably has no ingressClassName either, like the ones in the examples below, because Traefik picks up class-less Ingresses on K3s. If no controller claims it, the Ingress is still accepted: it sits with no address, serves nothing and reports no error. Set ingressClassName so the answer never depends on whichever default production happens to have. Storage hides the same way: a StatefulSet on local-path never has to follow its volume to another node, so it tells you nothing about what happens when it must.
K3s: a cluster that lives somewhere#
Install K3s when the cluster is a place rather than a test fixture: a home lab of Raspberry Pis, a VM running a team's internal tools, an edge box that has to keep working when the uplink does not. It builds for arm64 and armhf as well as x86_64. A server is one line, and an agent joins with the server's address and token:
# On the server
curl -sfL https://get.k3s.io | sh -
sudo cat /var/lib/rancher/k3s/server/node-token
# On each agent, using the server's address and that token
curl -sfL https://get.k3s.io | K3S_URL=https://SERVER_IP:6443 K3S_TOKEN=NODE_TOKEN sh -
# Back on the server
sudo kubectl get nodesThe bundled kubectl reads /etc/rancher/k3s/k3s.yaml, hence the sudo; to work from your laptop, copy that file to ~/.kube/config and change its server field. With Traefik and ServiceLB already running, a workload is reachable on port 80 of any node:
kubectl create deployment hello --image=nginx
kubectl expose deployment hello --port=80
kubectl create ingress hello --rule="/*=hello:80"
curl http://SERVER_IP/Traefik's own Service is a LoadBalancer, and ServiceLB answers it by binding ports 80 and 443 on the nodes, so no cloud load balancer sits in the path. That is also why a second LoadBalancer Service that wants port 80 stays pending. The default datastore is SQLite, which cannot back more than one server: for a cluster anyone depends on, start the first server with --cluster-init for embedded etcd and run an odd number of servers, starting at three.
k3d: a cluster you throw away#
k3d is a community wrapper, not a SUSE product, that runs each K3s node as a Docker container behind one more container, the load balancer, through which every published port passes. Podman works through its Docker-compatible API, though k3d calls that support experimental.
k3d cluster create demo --servers 1 --agents 2 -p "8080:80@loadbalancer"
kubectl get nodes
kubectl create deployment hello --image=nginx
kubectl expose deployment hello --port=80
kubectl create ingress hello --rule="/*=hello:80"
curl http://localhost:8080/
k3d cluster delete demoThe middle of that block is the K3s example again: the same Traefik receives the same Ingress, reached through localhost:8080, and k3d cluster create merges the context into your kubeconfig. Decide your ports before you create the cluster, since k3d cluster edit is experimental and recreating is usually faster. The nodes are containers, so local-path volumes live inside them and go when the cluster does. --registry-create demo-registry adds a registry container the nodes pull from, keeping a build-push-deploy loop on your machine, and in CI each run gets a clean multi-node cluster whose deletion is the cleanup.
To close the gap with production, create the cluster without Traefik and install the controller production runs, passing the K3s flag through with --k3s-arg "--disable=traefik@server:*". The wildcard applies it to every server node, not only the first. Do only that and the hello Ingress above is accepted, gets no address and localhost:8080 answers nothing, with no error anywhere; we checked. Installing production's controller costs one extra step, and it catches the StripPrefix failure on your laptop rather than in staging.
The diagram#
Both places side by side, with the bundled parts in each: open it in archhy and make a copy to mark up your own cluster.
Where kind fits#
kind also runs nodes as Docker containers, but bootstraps upstream Kubernetes with kubeadm; it was built to test Kubernetes itself and is a CNCF-certified conformant installer. It adds no ingress controller and no load balancer, and LoadBalancer Services need its separate cloud-provider-kind binary on the host. If extras that production lacks are the risk, that bareness is a fidelity argument for application teams: nothing in kind quietly does work production will not. The argument stops once production adds its own ingress controller or load balancer, because kind lacks those as surely as K3s substitutes for them, and you install the real ones in either. Past that point, k3d is the quicker loop: a multi-node cluster and a local registry in one command, and gone with one more.
When K3s is production#
If your real clusters are K3s on edge hardware, the advice inverts. k3d stops being an approximation and becomes the most faithful development environment you can have: your production distribution and everything it bundles, on a laptop. Keep its defaults on, because they are your production defaults.
