Running Kubernetes Locally
Working on the Kubernetes source on your own local machine can be rewarding:
- spinning up a “cluster” is very fast
- debugging is simple
- low-level tools, like netfilter logging and bpf, are close at hand
Of course, this is no substitute for real end-to-end tests, but when you want to work quickly, I’ve found it invaluable.
hack/run-locally
There is an existing Kubernetes script that starts a bare-bones cluster. However, it doesn’t work out-of-the-box on Fedora. Here’s what you have to do to enable it:
Get CRI-O and crun
sudo dnf module enable cri-o:1.19
sudo dnf install cri-o crun
sudo systemctl enable cri-o
Configure cri-o to use crun
This is needed (for now) to support cgroups v2. Edit the file /etc/crio/crio.conf
- Add the following section:
[crio.runtime.runtimes.crun]
runtime_path = "/usr/bin/crun"
runtime_root = "/run/crun"
- Edit the
default_runtime
directive:
default_runtime = "crun"
- Restart cri-o:
systemctl restart cri-o
Start kubernetes locally
In your kubernetes checkout, run
$ hack/install-etcd.sh
$ CGROUP_DRIVER=systemd CONTAINER_RUNTIME=remote \
CONTAINER_RUNTIME_ENDPOINT='unix:///var/run/crio/crio.sock' \
./hack/local-up-cluster.sh
It will spit out a KUBECONFIG for you to use - have fun!
Debugging
You can find more information in the logs:
journalctl -u crio
less /tmp/kubelet.log