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.

  1. 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

  2. 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 <pending> 80:30016/TCP 7d17h localhost must be there. and localhost could not be reached at that moment so I had to fix that by applying this answer from Stackoverflow
  3. The reason was that minikube doesn’t have LoadBalancer turned on by default without turning on the minikube tunnel!
  4. To turn on the minikube tunnel run: minikube tunnel
  5. After that, running kubectl get svc gives an IP address back which works in the browser! Another solution is to implement a Ingress Controller which I will try in the future.