Kubernetes with microk8s on Hetzner Cloud

Allgemein

Set the correct IP of the node.

https://github.com/ubuntu/microk8s/issues/2402#issuecomment-950884240

microk8s stop

Add this to the bottom of /var/snap/microk8s/current/args/kubelet:
--node-ip=10.x.y.z

Add this to the bottom of /var/snap/microk8s/current/args/kube-apiserver:
--advertise-address=10.x.y.z

microk8s start

Now I see the correct values in the INTERNAL-IP column with microk8s kubectl get nodes -o wide

This is important. Sometimes the communication was not possible. This was due to the firewall, because the public IP address was used

Use RabbitMQ Cluster Kubernetes Operator

https://www.rabbitmq.com/kubernetes/operator/quickstart-operator.html

Can cause permission problems with the storage addon. Best is to use the Hetzner Cloud CSI Driver.

https://github.com/hetznercloud/csi-driver

To work with microk8s use this tipp:

https://github.com/hetznercloud/csi-driver/issues/213#issuecomment-900650971:

"replace every /var/lib/kubelet with /var/snap/microk8s/common/var/lib/kubelet"

After that, the cluster finally came up.
ASP.NET Core Config nutzt Sections. Um diese in der Konfiguration abzubilden muss __ verwendet werden.

"Note that I've used the double underscore __ in the environment variable name. The translates to a "section" in ASP.NET Core's configuration, so this would set the configuration value Runtime:IpAdress to the pod's IP address."

https://andrewlock.net/deploying-asp-net-core-applications-to-kubernetes-part-5-setting-environment-variables-in-a-helm-chart/

Hetzner Load Balancer

Zur ConfigMap nginx-load-balancer-microk8s-conf folgendes hinzufügen, damit dieser das Proxy-Protokoll des LB verarbeiten kann.

data:
  use-forwarded-headers: "true"
  compute-full-forwarded-for: "true"
  use-proxy-protocol: "true"

Im Hetzner Load Balancer den Proxy-Protokoll-Modus aktivieren. Ansonten kann es im Log des Ingress Controllers zur folgender Fehlermeldung kommen: 

" while reading PROXY protocol, client: 10.245.10.8, server: 0.0.0.0:80
2021/11/07 12:30:31 [error] 953#953: *1110021 broken header: "GET / HTTP/1.1
host: 49.12.22.218
user-agent: HCLB-HealthCheck
content-length: 0
connection: close

https://community.hetzner.com/tutorials/howto-k8s-authentication-with-load-balancer
https://github.com/ubuntu/microk8s/issues/661