I had some trouble in setting up Docker images in Kubernetes. I will share the mistakes I made while experimenting and what I learned from it.
I’m following the video from That Devops Guy to set up a docker directory. Here are my findings:
My first experimentation was to use the a Debian Buster Slim image and not a Alpine Linux image because this website says that Alpine can introduce obscure runtime bugs and actually make images bigger and not smaller.
The latest SLIM Buster (python:3.8-slim) doesn’t seem to work because the cgroup mount destination cannot be found. This can by the writing of this post be fixed by issuing the following two commands from this comment on Github Issues. Although I don’t run this on Arch Linux and not in WSL this still works.
sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
- Now to the next step: running the container in a local Kubernetes cluster via minikube.
Here I turned on the Pod load balancer. The external IP was constantly on pending like this:
example-service LoadBalancer 10.111.214.145 <pending> 80:30016/TCP 7d17hlocalhost must be there. and localhost could not be reached at that moment so I had to fix that by applying this answer from Stackoverflow
- The reason was that minikube doesn’t have LoadBalancer turned on by default without turning on the minikube tunnel!
- To turn on the minikube tunnel run:
- After that, running
kubectl get svcgives an IP address back which works in the browser! Another solution is to implement a Ingress Controller which I will try in the future.