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)

Most upvoted comments

To resolve the issue I have edited the kubeadm-config configmap within kube-system to add the ControlPlaneKubeletLocalMode flag as below

apiVersion: v1
data:
  ClusterConfiguration: |
    apiServer:
      extraArgs:
      - name: authorization-mode
        value: Node,RBAC
    apiVersion: kubeadm.k8s.io/v1beta4
    caCertificateValidityPeriod: 87600h0m0s
    certificateValidityPeriod: 8760h0m0s
    certificatesDir: /etc/kubernetes/pki
    clusterName: kubernetes
    controlPlaneEndpoint: kubernetes.cluster.local:6443
    controllerManager: {}
    dns: {}
    encryptionAlgorithm: RSA-2048
    etcd:
      local:
        dataDir: /var/lib/etcd
++    featureGates:
++      ControlPlaneKubeletLocalMode: true
    imageRepository: registry.k8s.io

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.

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: 
      CLUSTER-CERTIFICATE-REMOVED
--    server: https://kubernetes.cluster.local:6443
++    server: https://10.0.0.12:6443
  name: default-cluster
contexts:
- context:
    cluster: default-cluster
    namespace: default
    user: default-auth
  name: default-context
current-context: default-context
kind: Config
preferences: {}
users:
- name: default-auth
  user:
    client-certificate: /var/lib/kubelet/pki/kubelet-client-current.pem
    client-key: /var/lib/kubelet/pki/kubelet-client-current.pem

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.clusterIP field 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?

cannot always be guaranteed to be lower than the k8s version. This has not been a problem with previous k8s versions, is there a way to fix it in 1.31.2 or so to allow the old behaviour?

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.

Sep 12 18:31:38 kubecontroller2 kubelet[2595]: I0912 18:31:38.133966    2595 reflector.go:296] Starting reflector *v1.Service (0s) from k8s.io/client-go/informers/factory.go:160
Sep 12 18:31:38 kubecontroller2 kubelet[2595]: I0912 18:31:38.134106    2595 reflector.go:332] Listing and watching *v1.Service from k8s.io/client-go/informers/factory.go:160
Sep 12 18:31:38 kubecontroller2 kubelet[2595]: I0912 18:31:38.134155    2595 round_trippers.go:463] GET https://kubernetes.cluster.local:6443/api/v1/services?limit=500&resourceVersion=0

My understanding from the comments above is that there is no single kubeadm config that works correctly without the feature gate turned on

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:

$ k get svc --field-selector='spec.clusterIP!=""'
NAME          TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)         AGE
hostnames     ClusterIP   10.0.102.14   <none>        80/TCP,81/TCP   167d
kubernetes    ClusterIP   10.0.0.1      <none>        443/TCP         167d

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.