kubernetes: kubelet fails to start pods after upgrade to 1.31.X
What happened?
After the first controller upgrade from 1.30.4 to 1.31.0 and later 1.31.1. The kubelet service fails to start the majority of pods running on the controller.
What did you expect to happen?
All pods should start as before the upgrade.
$ kubectl get pod -o wide --all-namespaces -w | grep controller2
calico-system calico-node-p4fzm 0/1 CreateContainerConfigError 0 153m 192.168.16.112 kubecontroller2 <none> <none>
calico-system calico-typha-685957f77b-k2xf8 0/1 CreateContainerConfigError 4 (122m ago) 40d 192.168.16.112 kubecontroller2 <none> <none>
calico-system csi-node-driver-b6jkc 0/2 CreateContainerConfigError 8 (122m ago) 40d 10.245.98.170 kubecontroller2 <none> <none>
default netdata-child-pctf4 0/2 CreateContainerConfigError 2 (122m ago) 11d 192.168.16.112 kubecontroller2 <none> <none>
kube-system etcd-kubecontroller2 1/1 Running 1 (122m ago) 122m 192.168.16.112 kubecontroller2 <none> <none>
kube-system kube-apiserver-kubecontroller2 1/1 Running 1 (122m ago) 122m 192.168.16.112 kubecontroller2 <none> <none>
kube-system kube-controller-manager-kubecontroller2 1/1 Running 1 (122m ago) 122m 192.168.16.112 kubecontroller2 <none> <none>
kube-system kube-proxy-q2drw 0/1 CreateContainerConfigError 0 17h 192.168.16.112 kubecontroller2 <none> <none>
kube-system kube-scheduler-kubecontroller2 1/1 Running 1 (122m ago) 122m 192.168.16.112 kubecontroller2 <none> <none>
kube-system kube-vip-kubecontroller2 1/1 Running 1 (122m ago) 122m 192.168.16.112 kubecontroller2 <none> <none>
monitoring kube-prometheus-stack-prometheus-node-exporter-gnwsj 0/1 CreateContainerConfigError 1 (122m ago) 5d1h 192.168.16.112 kubecontroller2 <none> <none>
How can we reproduce it (as minimally and precisely as possible)?
Basic Debian 12 VM used as a controller node. First controller upgraded from 1.30.4 to 1.31.0 and later to 1.31.1.
Anything else we need to know?
Reinstalling kubelet 1.30.4 allows pods to start correctly.
Kubernetes version
$ kubectl version
Client Version: v1.30.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.4
Cloud provider
Self hosted / metal
OS version
# On Linux:
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ uname -a
Linux kubecontroller2 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux
Install tools
kubeadm
Container runtime (CRI) and version (if applicable)
containerd containerd.io 1.7.22 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
Related plugins (CNI, CSI, …) and versions (if applicable)
calico v3.28.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 38 (21 by maintainers)
To resolve the issue I have edited the kubeadm-config configmap within kube-system to add the ControlPlaneKubeletLocalMode flag as below
After adding the flag and upgrading a control-plane node the /etc/kubernetes/kubelet.conf file is updated so the server field connects to the host itself rather then the cluster vip address.
So if a controller has already been upgraded and is now failing, changing the server address within kubelet.conf will return the node to service and adding the flag will make it permanent for future upgrades.
I don’t know what the official or recommended fix will be but this is working well for me.
/reopen
I also had this issue after upgrading from 1.30.4 to 1.31.1. I was able to resolve it by setting the server IP of the control plane itself in the Kubelet config. I had to do this because the other API servers did not yet know about the new
spec.clusterIPfield selector.Commits that have caused this issue: (both created by @aojea)
It should be communicated to the user that kubelet 1.31.* CAN NOT interact with a kube-apiserver that has a version lower than itself.
I’m not sure what “the OS packages on Alpine Linux” means here - do you mean kubelet?
The version skew policy has always existed - some folks may have “gotten away with” violating it before, but it exists for a reason. It’s not something that we can fix in a patch release.
If someone else has this issue with single node kubeadm clusters.
Make sure you upgraded the Cluster Version first! (
dnf update kubeadm,kubadm upgrade apply v1.31.1,dnf update)/close
I am not trying to be hard, just confirming again that the version skew policy is clearly articulated today.
I can confirm this issue is introduced in 1.31.X.
After rolling back kubelet to 1.30.4 with no other changes. The same service get request does not include the fieldSelector=spec.clusterIP parameter.
That’s my understanding as well. I think it was not intentional that kubeadm violated the policy. It was just noticed only recently when not following the skew policy for kubelet lead to actual problems.
Yeah I get the version skew policy, but I’m not sure how a cluster setup should look like so that it won’t need this feature gate since it’s turned off by default? If kubeadm always violates the skew policy and the feature gate is not turned on by default until 1.33, this will hit lots of people for quite some time. My understanding from the comments above is that there is no single kubeadm config that works correctly without the feature gate turned on (or it requires manual changes to /etc/kubernetes/kubelet.conf that are not driven by kubeadm itself).
@aojea I think this is “working as intended”, even if it is sniffing out cases where people violate skew rules. That said, we COULD revert the usage of the selector until 1.32 - it was your feature - do you think it is worthwhile? Given that it involves kubeadm I give it somewhat more weight than I would otherwise.
OK, in my own test env, I can say that it DOES work:
It looks like this was cited: https://github.com/kubernetes/kubernetes/pull/123905#issuecomment-2260639787
The fix is supposed to be kubeadm feature-gate “ControlPlaneKubeletLocalMode” (https://github.com/kubernetes/kubernetes/pull/125582)
@JumpMaster does that apply to you?
This is unfortunate - we probaly should have done it in two releases.