siderolabs / talos

Talos Linux is a modern Linux distribution built for Kubernetes.
https://www.talos.dev
Mozilla Public License 2.0
5.76k stars 467 forks source link

Control plane static pod does not generate due to race condition #6888

Closed Gentoli closed 1 day ago

Gentoli commented 1 year ago

Bug Report

Description

If a user provided static pod mounts /system/secrets/kubernetes/kube-controller-manager/kubeconfig with out explicit type, control plane pods does not gets created due to

192.168.2.205: [talos] controller failed {"component": "controller-runtime", "controller": "k8s.RenderSecretsStaticPodController", "error": "error writing template \"kubeconfig\" for \"kube-controller-manager\": open /system/secrets/kubernetes/kube-controller-manager/kubeconfig: is a directory"}

I think is caused by the user provided static pods being supplied to kubelet before the control plane pods.

So the steps goes like this:

To protect the control plane startup, either

The workaround is to use type=Directory on the parent so the file is not created (also the kubeconfig is not visible to kubelet).

 - hostPath:
     path: /system/secrets/kubernetes/kube-controller-manager
     type: Directory

Logs

machined failed to write kubeconfig

192.168.2.205: [talos] controller failed {"component": "controller-runtime", "controller": "k8s.RenderSecretsStaticPodController", "error": "error writing template \"kubeconfig\" for \"kube-controller-manager\": open /system/secrets/kubernetes/kube-controller-manager/kubeconfig: is a directory"}

endpoint with no pods

talos-xmd-rtx:~# curl http://127.0.0.1:46817
kind: PodList
items: []

Environment

smira commented 1 year ago

yes, this is expected behavior - in general, not the best idea to re-use kubeconfig from other Talos static pods, as things might change in the future.

github-actions[bot] commented 6 days ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 day ago

This issue was closed because it has been stalled for 7 days with no activity.