kubernetes: kube-proxy pods continuously CrashLoopBackOff

What happened?

I’m very new to k8s and having problem with kube-proxy pods. After I join worker node to control plane with command “kubeadm join ~” the worker node status has continuously restarting kube-proxy, weave-net, nvidia-device-plugin pods with worker node status ready.

kubectl get pods -n kube-system -o wide

NAME                                   READY   STATUS             RESTARTS         AGE    IP               NODE          NOMINATED NODE   READINESS GATES
kube-proxy-9v788                       1/1     Running            0                3d3h   192.168.136.42   ogremage-00   <none>           <none>
kube-proxy-r88js                       0/1     CrashLoopBackOff   8 (49s ago)      39m    192.168.136.45   ogremage-03   <none>           <none>

pod on ogremage-00 is Running without restart while pod os ogremage-03 is continuously restarting

kubectl describe node ogremage-03 (problematic worker node)

Name:               ogremage-03
Roles:              <none>
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=ogremage-03
                    kubernetes.io/os=linux
Annotations:        kubeadm.alpha.kubernetes.io/cri-socket: unix:///var/run/containerd/containerd.sock
                    node.alpha.kubernetes.io/ttl: 0
                    volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp:  Mon, 05 Jun 2023 21:35:17 +0900
Taints:             <none>
Unschedulable:      false
Lease:
  HolderIdentity:  ogremage-03
  AcquireTime:     <unset>
  RenewTime:       Mon, 05 Jun 2023 22:03:42 +0900
Conditions:
  Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----                 ------  -----------------                 ------------------                ------                       -------
  NetworkUnavailable   False   Mon, 05 Jun 2023 21:59:43 +0900   Mon, 05 Jun 2023 21:59:43 +0900   WeaveIsUp                    Weave pod has set this
  MemoryPressure       False   Mon, 05 Jun 2023 22:00:59 +0900   Mon, 05 Jun 2023 21:35:17 +0900   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure         False   Mon, 05 Jun 2023 22:00:59 +0900   Mon, 05 Jun 2023 21:35:17 +0900   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure          False   Mon, 05 Jun 2023 22:00:59 +0900   Mon, 05 Jun 2023 21:35:17 +0900   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready                True    Mon, 05 Jun 2023 22:00:59 +0900   Mon, 05 Jun 2023 21:35:17 +0900   KubeletReady                 kubelet is posting ready status. AppArmor enabled
Addresses:
  InternalIP:  192.168.136.45
  Hostname:    ogremage-03
Capacity:
  cpu:                40
  ephemeral-storage:  982862268Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             131879520Ki
  nvidia.com/gpu:     4
  pods:               110
Allocatable:
  cpu:                40
  ephemeral-storage:  905805864690
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             131777120Ki
  nvidia.com/gpu:     0
  pods:               110
System Info:
  Machine ID:                 56ec226a003349bf870f1d62bca55825
  System UUID:                7478a98b-d7be-b34e-f3ff-0c9d92c5385c
  Boot ID:                    f417c00f-ab0b-453b-be1b-4b05737d65ce
  Kernel Version:             5.15.0-67-generic
  OS Image:                   Ubuntu 22.04.2 LTS
  Operating System:           linux
  Architecture:               amd64
  Container Runtime Version:  containerd://1.6.21
  Kubelet Version:            v1.27.2
  Kube-Proxy Version:         v1.27.2
Non-terminated Pods:          (3 in total)
  Namespace                   Name                                    CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age
  ---------                   ----                                    ------------  ----------  ---------------  -------------  ---
  kube-system                 kube-proxy-r88js                        0 (0%)        0 (0%)      0 (0%)           0 (0%)         28m
  kube-system                 nvidia-device-plugin-daemonset-qtm8q    0 (0%)        0 (0%)      0 (0%)           0 (0%)         28m
  kube-system                 weave-net-sw7z8                         100m (0%)     0 (0%)      0 (0%)           0 (0%)         28m
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests   Limits
  --------           --------   ------
  cpu                100m (0%)  0 (0%)
  memory             0 (0%)     0 (0%)
  ephemeral-storage  0 (0%)     0 (0%)
  hugepages-1Gi      0 (0%)     0 (0%)
  hugepages-2Mi      0 (0%)     0 (0%)
  nvidia.com/gpu     0          0
Events:
  Type     Reason                   Age                From             Message
  ----     ------                   ----               ----             -------
  Normal   Starting                 23m                kube-proxy
  Normal   Starting                 6m23s              kube-proxy
  Normal   Starting                 14m                kube-proxy
  Normal   Starting                 16m                kube-proxy
  Normal   Starting                 21m                kube-proxy
  Normal   Starting                 23m                kube-proxy
  Normal   Starting                 23m                kube-proxy
  Normal   NodeHasSufficientMemory  28m (x2 over 28m)  kubelet          Node ogremage-03 status is now: NodeHasSufficientMemory
  Normal   NodeReady                28m                kubelet          Node ogremage-03 status is now: NodeReady
  Normal   NodeAllocatableEnforced  28m                kubelet          Updated Node Allocatable limit across pods
  Normal   NodeHasSufficientPID     28m (x2 over 28m)  kubelet          Node ogremage-03 status is now: NodeHasSufficientPID
  Normal   NodeHasNoDiskPressure    28m (x2 over 28m)  kubelet          Node ogremage-03 status is now: NodeHasNoDiskPressure
  Warning  InvalidDiskCapacity      28m                kubelet          invalid capacity 0 on image filesystem
  Normal   Starting                 28m                kubelet          Starting kubelet.
  Normal   RegisteredNode           28m                node-controller  Node ogremage-03 event: Registered Node ogremage-03 in Controller

kubectl describe -n kube-system kube-proxy-r88js

Name:                 kube-proxy-r88js
Namespace:            kube-system
Priority:             2000001000
Priority Class Name:  system-node-critical
Service Account:      kube-proxy
Node:                 ogremage-03/192.168.136.45
Start Time:           Mon, 05 Jun 2023 21:35:18 +0900
Labels:               controller-revision-hash=8bdf7b6c
                      k8s-app=kube-proxy
                      pod-template-generation=1
Annotations:          <none>
Status:               Running
IP:                   192.168.136.45
IPs:
  IP:           192.168.136.45
Controlled By:  DaemonSet/kube-proxy
Containers:
  kube-proxy:
    Container ID:  containerd://037a86b009a2de95c01d650143dcb41794300eddf833c955d650a04d4e8dbf95
    Image:         registry.k8s.io/kube-proxy:v1.27.2
    Image ID:      registry.k8s.io/kube-proxy@sha256:1e4f13f5f5c215813fb9c9c6f56da1c0354363f2a69bd12732658f79d585864f
    Port:          <none>
    Host Port:     <none>
    Command:
      /usr/local/bin/kube-proxy
      --config=/var/lib/kube-proxy/config.conf
      --hostname-override=$(NODE_NAME)
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    2
      Started:      Mon, 05 Jun 2023 22:05:23 +0900
      Finished:     Mon, 05 Jun 2023 22:08:08 +0900
    Ready:          False
    Restart Count:  7
    Environment:
      NODE_NAME:   (v1:spec.nodeName)
    Mounts:
      /lib/modules from lib-modules (ro)
      /run/xtables.lock from xtables-lock (rw)
      /var/lib/kube-proxy from kube-proxy (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-b8wgt (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-proxy:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      kube-proxy
    Optional:  false
  xtables-lock:
    Type:          HostPath (bare host directory volume)
    Path:          /run/xtables.lock
    HostPathType:  FileOrCreate
  lib-modules:
    Type:          HostPath (bare host directory volume)
    Path:          /lib/modules
    HostPathType:
  kube-api-access-b8wgt:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              kubernetes.io/os=linux
Tolerations:                 op=Exists
                             node.kubernetes.io/disk-pressure:NoSchedule op=Exists
                             node.kubernetes.io/memory-pressure:NoSchedule op=Exists
                             node.kubernetes.io/network-unavailable:NoSchedule op=Exists
                             node.kubernetes.io/not-ready:NoExecute op=Exists
                             node.kubernetes.io/pid-pressure:NoSchedule op=Exists
                             node.kubernetes.io/unreachable:NoExecute op=Exists
                             node.kubernetes.io/unschedulable:NoSchedule op=Exists
Events:
  Type     Reason                  Age                  From               Message
  ----     ------                  ----                 ----               -------
  Normal   Scheduled               35m                  default-scheduler  Successfully assigned kube-system/kube-proxy-r88js to ogremage-03
  Warning  FailedCreatePodSandBox  35m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/ebff3b35580201e0a65c177160290b982066fcab1336cca3458d7ed37f6b7de4/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  35m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/b573ce033f9fda87ebf157156b40a4b9df464b918b5851b617631ca29fc81e2d/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  34m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/e0a149ff2acf917780e65e50eac08219b9e5a660fe0af70c61150cc8ddf82ddd/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  34m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/e557b08e9b57ecd2a33e098ab519a54f682ac027d3576e6f3308e69b4de1b197/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  34m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/155263a41df79bafca243969690abc66048dc2609d02c3a543a1e10a12c3a071/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  34m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/d975b24b3a0f1863aab1e67de23cf402b0f72d39ad914f1765ef89a9d32c3d9a/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  33m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/dafafd5a5bc5b8cf2146ab60322809d02868fca1ee611675898b87599c13ed60/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  33m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/69a16fdc7627a9493d08f98f3c57513eb6be26fbb6aa235d41edba7561f82fd9/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  33m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/e03e11b36be09c08482c1c614df85e1aa0565755e17e8d25f3bd6639f87d77fa/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Warning  FailedCreatePodSandBox  30m (x14 over 33m)   kubelet            (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/containerd/io.containerd.runtime.v2.task/k8s.io/8f8060843d59d94cd47a317858b4992a0e7b6790f356ce47809448e2c7e8c19d/log.json: no such file or directory): fork/exec /usr/bin/nvidia-container-runtime: no such file or directory: unknown
  Normal   Pulling                 30m                  kubelet            Pulling image "registry.k8s.io/kube-proxy:v1.27.2"
  Normal   Pulled                  30m                  kubelet            Successfully pulled image "registry.k8s.io/kube-proxy:v1.27.2" in 5.902758247s (5.902854866s including waiting)
  Normal   Created                 30m                  kubelet            Created container kube-proxy
  Normal   Killing                 15m (x6 over 30m)    kubelet            Stopping container kube-proxy
  Normal   Pulled                  5m11s (x7 over 30m)  kubelet            Container image "registry.k8s.io/kube-proxy:v1.27.2" already present on machine
  Warning  BackOff                 12s (x70 over 29m)   kubelet            Back-off restarting failed container kube-proxy in pod kube-proxy-r88js_kube-system(b6e90912-84f1-482f-b117-0f1e3535f749)

kubectl logs -n kube-system pods/kube-proxy-r88js

I0605 13:05:23.587082       1 node.go:141] Successfully retrieved node IP: 192.168.136.45
I0605 13:05:23.587186       1 server_others.go:110] "Detected node IP" address="192.168.136.45"
I0605 13:05:23.587231       1 server_others.go:551] "Using iptables proxy"
I0605 13:05:23.608891       1 server_others.go:190] "Using iptables Proxier"
I0605 13:05:23.608916       1 server_others.go:197] "kube-proxy running in dual-stack mode" ipFamily=IPv4
I0605 13:05:23.608926       1 server_others.go:198] "Creating dualStackProxier for iptables"
I0605 13:05:23.608939       1 server_others.go:465] "Detect-local-mode set to ClusterCIDR, but no cluster CIDR defined"
I0605 13:05:23.608955       1 server_others.go:521] "Defaulting to no-op detect-local" detectLocalMode="ClusterCIDR"
I0605 13:05:23.608994       1 proxier.go:253] "Setting route_localnet=1 to allow node-ports on localhost; to change this either disable iptables.localhostNodePorts (--iptables-localhost-nodeports) or set nodePortAddresses (--nodeport-addresses) to filter loopback addresses"
I0605 13:05:23.611013       1 server.go:657] "Version info" version="v1.27.2"
I0605 13:05:23.611030       1 server.go:659] "Golang settings" GOGC="" GOMAXPROCS="" GOTRACEBACK=""
I0605 13:05:23.627078       1 conntrack.go:52] "Setting nf_conntrack_max" nfConntrackMax=1310720
I0605 13:05:23.627318       1 config.go:188] "Starting service config controller"
I0605 13:05:23.627334       1 shared_informer.go:311] Waiting for caches to sync for service config
I0605 13:05:23.627441       1 config.go:315] "Starting node config controller"
I0605 13:05:23.627479       1 shared_informer.go:311] Waiting for caches to sync for node config
I0605 13:05:23.627498       1 config.go:97] "Starting endpoint slice config controller"
I0605 13:05:23.627519       1 shared_informer.go:311] Waiting for caches to sync for endpoint slice config
I0605 13:05:23.728342       1 shared_informer.go:318] Caches are synced for service config
I0605 13:05:23.728393       1 shared_informer.go:318] Caches are synced for node config
I0605 13:05:23.728409       1 shared_informer.go:318] Caches are synced for endpoint slice config

What did you expect to happen?

kube-proxy pods with status Running

How can we reproduce it (as minimally and precisely as possible)?

It’s hard to tell. On the same OS and installation, this bug occurs on some machines but not others.

Anything else we need to know?

Please let me know if any additional information is needed to delve deeper into the problem.

Kubernetes version

version of control plane Client Version: v1.27.2 Kustomize Version: v5.0.1 Server Version: v1.27.2

version of worker node Client Version: v1.27.2 Kustomize Version: v5.0.1 Server Version: v1.27.2

Cloud provider

on local machine

OS version

control plane $ cat /etc/os-release PRETTY_NAME=“Ubuntu 22.04.2 LTS” NAME=“Ubuntu” VERSION_ID=“22.04” VERSION=“22.04.2 LTS (Jammy Jellyfish)” VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL=“https://www.ubuntu.com/” SUPPORT_URL=“https://help.ubuntu.com/” BUG_REPORT_URL=“https://bugs.launchpad.net/ubuntu/” PRIVACY_POLICY_URL=“https://www.ubuntu.com/legal/terms-and-policies/privacy-policy” UBUNTU_CODENAME=jammy

$ uname -a Linux ogremage-00 5.15.0-73-generic #80-Ubuntu SMP Mon May 15 15:18:26 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

worker node $ cat /etc/os-release PRETTY_NAME=“Ubuntu 22.04.2 LTS” NAME=“Ubuntu” VERSION_ID=“22.04” VERSION=“22.04.2 LTS (Jammy Jellyfish)” VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL=“https://www.ubuntu.com/” SUPPORT_URL=“https://help.ubuntu.com/” BUG_REPORT_URL=“https://bugs.launchpad.net/ubuntu/” PRIVACY_POLICY_URL=“https://www.ubuntu.com/legal/terms-and-policies/privacy-policy” UBUNTU_CODENAME=jammy

$ uname -a Linux ogremage-03 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Install tools

follow the official document https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (7 by maintainers)

Most upvoted comments

I had a similar problem, coredns and flannel were constantly restarting on the node where the kubeadm join was performed on the node worker with kubernetes v1.29. The problem disappeared after I copied the /etc/containerd/config.toml file from the master node deployed on ubuntu 22.04 and kubernetes version 1.28 to the worker node and restarted containerd. After this, coredns and flannel reboots stopped. Later, I tested another case - connecting a worker node (ubuntu 22.04 kubernetes 1.29) to a master node (Rocky Linux release 8.9 kubernetes 1.29) on which CrashLoopBackOff had previously been similarly repeated for coredns and kube-flannel and the problem disappeared, the reboots stopped. My config.toml is attached. Perhaps this will help someone. This idea was inspired by a post from reddit (https://www.reddit.com/r/kubernetes/comments/yjtv7q/flannel_and_kubeproxy_are_crashing/). config.txt

Your solution (i.e. copy /etc/containerd/config.toml from master node to worker node) works for me. Cheers.

my master, worker nodes are both ubuntu 22.04, kubernetes 1.29.

I head back to the official guideline for setting the systemd cgroup driver for containerd (i.e. https://kubernetes.io/docs/setup/production-environment/container-runtimes/#containerd-systemd). There is actually a “note” mentioning this issue

If you experience container crash loops after the initial cluster installation or after installing a CNI, the containerd configuration provided with the package might contain incompatible configuration parameters. Consider resetting the containerd configuration with containerd config default > /etc/containerd/config.toml as specified in getting-started.md and then set the configuration parameters specified above accordingly.

I tried to followed this instruction to reset the containerd configuration before updating the cgroup in another worker node. This also works.

TLDR @1qzxc Still present on version 1.27 … I tried a lot of things. The only thing that worked was to revert back to the version you suggested. For future reference, here’s everything I tried.

I managed to install kubernetes following the steps documented in _readme/vps-kubernetes.md. I was attempting to get nginx and certbot started in k8s. However there was a lingering issue with kube-proxy restarting. I tried checking the events log and with the help of GPT and StackOverflow found the issue is stemming from duplicate DNS entries. They show up immediatly after droplet init.

Summary

  • /etc/resolv.conf - old file, gang banged by everyone
  • /run/systemd/resolve/resolv.conf - new file, which avoids the gang bang problem so as not to lose the system settings - Generated at runtime. Changes are overwritten
  • sudo nano /etc/netplan/50-cloud-init.yaml' - this generates the one from /run - this has double entries for eth0andeth1`. It comes by default from DO droplet.
  • Generates 6 DNS entries
  • DNS ubuntu only supports 3
  • Everything above 3 is ignored by legacy programs
  • K8S kube-proxy panics when it sees this
  • I forced kube-proxy to use etc/resolv.conf
  • Problem is no longer there, however the kube-proxy pod still keeps dying.
  • I tried digging in all possible logs even increasing verbosity. Nothing
  • Tried one last thing, rollback to an older version, this worked.

Detailed Log

  • Inspect Events - kubectl get events --all-namespaces - Checking events I found an error on multiple pods. Nameserver limits were exceeded, some nameservers have been omitted, the applied nameserver line is: xx.xxx.xx.2 xx.xxx.xx.3 xx.xxx.xx.2
  • Adjust kubelet flags - You can pass the --resolv-conf flag to kubelet to specify an alternative resolv.conf file if needed. K8s coredns and flannel nameserver limit exceeded [closed]
    • Some Linux distributions (e.g. Ubuntu), use a local DNS resolver by default (systemd-resolved). Systemd-resolved moves and replaces /etc/resolv.conf with a stub file that can cause a fatal forwarding loop when resolving names in upstream servers. This can be fixed manually by using kubelet’s --resolv-conf flag to point to the correct resolv.conf (With systemd-resolved, this is /run/systemd/resolve/resolv.conf). kubeadm (>= 1.11) automatically detects systemd-resolved, and adjusts the kubelet flags accordingly. Debugging DNS Resolution.
    • Not the first time I see this page. I had similar troubles when attempting to understand why minikube wont start. That time it was an issue with the default values and the only solution was a complete reinstall. This time it does not work.
  • Edit the kubelet config file GPT: The kubelet configuration is typically controlled by a file located at /var/lib/kubelet/config.yaml. You will need to edit this file to change the DNS settings.
sudo nano /var/lib/kubelet/config.yaml
  • Add the following line under the kubelet configuration to specify the alternative resolv.conf:
Copy code
resolvConf: /run/systemd/resolve/resolv.conf
  • I inspected already fixed - Then I checked /run/systemd/resolve/resolv.conf. Found:
nameserver xx.xxx.xx.2
nameserver xx.xxx.xx.3
nameserver xx.xxx.xx.2
# Too many DNS servers configured, the following entries may be ignored.
nameserver xx.xxx.xx.3
nameserver xx.xxx.xx.2
nameserver xx.xxx.xx.3
search .
nameserver xx.xxx.xx.2
nameserver xx.xxx.xx.3
search .
  • Restart kubelet - sudo systemctl restart kubelet
  • Inspec events again - New issues - kubectl get events --all-namespaces - Tried, seemed to work but I have new issues
  • Full Restart Not Helping - Changes get overwritten - Did a full restart. Edited the /run/systemd/resolve/resolv.conf. Removed dupes. Started resintalling everything. Same issue. Checked again on /run/systemd/resolve/resolv.conf. It was overwritten.
  • Edit /etc/systemd/resolved.conf as well - GPT: It’s important to note that if systemd-resolved is actively managing your resolv.conf, these changes might be overwritten by systemd-resolved. In such cases, you would need to configure systemd-resolved to use the correct DNS servers. This typically involves editing /etc/systemd/resolved.conf and setting the DNS= line to the desired nameservers, then restarting systemd-resolved:
  • sudo nano /etc/systemd/resolved.conf
DNS=xx.xxx.xx.2 xx.xxx.xx.3
  • sudo systemctl restart systemd-resolved - Restart
  • /run/systemd/resolve/resolv.conf still overwriten - Even with no K8s installed. It’s enough to restart systemd-resolved and we get the file overwritten.
sudo systemctl restart systemd-resolved
kubectl get events --all-namespaces | grep kube-proxy
kubectl get events --all-namespaces --sort-by='.lastTimestamp'
  • Ideas, More Research - Seems like a very well known issue.
    • Rollback - Yet it works, found out later Someone suggested: This problem appears on k8s v1.26 however it was absent on v1.23 kube-proxy pods continuously CrashLoopBackOff
    • Add flags to kubelet config - Another from here: my current workaround is to have a /etc/resolv-static.conf and add --resolv-conf=/etc/resolv-static.conf to /var/snap/microk8s/current/args/kubelet but this is really not very satisfying. Not directly related. We don’t use microk8s. Nameserver limits exceeded with more than three DNS servers in /etc/resolv.conf
    • dnsmasq to increase 3 DNS limit - GPT: Use dnsmasq to increase nameserver records: If you’re hitting the limit of 3 nameserver records, setting up dnsmasq on your nodes can help. It acts as a local DNS cache and allows you to specify additional nameservers. Here’s a brief on how to set it up. Same as here: Nameserver limits exceeded with more than three DNS servers in /etc/resolv.conf - For now I don’t want to use this approach. Super complicated prone to failure.
      • Install dnsmasq on your nodes.
      • Configure dnsmasq to include your cluster DNS and any other nameservers you need.
      • Point your kubelet’s --resolv-conf to the dnsmasq managed resolv.conf.
    • Known Issue, not so clear fix here - K8s coredns and flannel nameserver limit exceeded
  • Netplan Duplicate DNS entries - Some of the duplication can be caused by sudo nano /etc/netplan/50-cloud-init.yaml. GPT: The configuration snippet you’ve found in /etc/netplan provides a critical clue to the behavior you’re experiencing with the DNS settings being reset upon restart. Netplan is a network configuration abstraction renderer used by Ubuntu and some other Linux distributions, which allows for easy configuration of networking through YAML files. When your system boots, netplan applies these configurations, including DNS server settings, to the system’s network interfaces.
    • Understanding the Duplication Issue - The duplication of DNS servers in /run/systemd/resolve/resolv.conf after reboot or restarting systemd-resolved is likely due to the way netplan processes the network configuration and interacts with systemd-resolved. Given that both eth0 and eth1 interfaces have the same DNS servers specified, and these settings are applied to the system’s DNS resolver, this could lead to the observed duplication.
    • Not sure if changing is ok - I don’t like changing DO droplet defaults. I’ll try smth else.
  • Why K8s cares - Becasue it’s own DNS could be lost after the 3 entries - GPT: The warning from Kubernetes about exceeding nameserver limits is due to the inherent limitation in the Linux kernel’s DNS resolver, which, by default, only considers up to three nameserver entries in the /etc/resolv.conf file for DNS resolution. When Kubernetes (specifically, the kubelet) sets up pods, it configures their DNS settings based on the node’s /etc/resolv.conf or another resolver configuration specified by the --resolv-conf kubelet flag. Kubernetes tries to merge the cluster’s internal DNS service (e.g., CoreDNS or kube-dns) with the existing nameservers specified in the node’s DNS configuration. If the node’s DNS configuration already specifies three nameservers, adding the cluster’s DNS service would exceed this limit, leading to the warning you’re seeing.
  • Pointing Kube to //etc/resolv.conf instead of /run/systemd/resolve/resolv.conf - GPT: Pointing kubelet’s --resolv-conf flag to /etc/resolv.conf instead of /run/systemd/resolve/resolv.conf is a viable approach, especially if /etc/resolv.conf contains DNS configurations that are more suitable for your Kubernetes pods’ DNS resolution needs. This method can be particularly effective if /etc/resolv.conf is stable, correctly configured, and not subject to undesirable automatic updates that might interfere with Kubernetes operations.
    • sudo nano /var/lib/kubelet/config.yaml
    • Change: resolvConf: /run/systemd/resolve/resolv.conf to resolvConf: /etc/resolv.conf - We should not be doing this if we want to keep things “modern” but as long as we don’t rely on many automatic DNS changes then we should be fine.
    • sudo systemctl restart kubelet - Finally restart
  • New issue - Unclear what, logs don’t indicate the issue - The previous one fixed the nameservers limit exceeded error. Now we have smth new.
    • kubectl describe pod kube-proxy-qv47n -n kube-system - Nothing useful here. Just indication that it dies.
    • kubectl logs kube-proxy-mg49v --previous -n kube-system - Nothing here either.
    • No entries in either of these:
journalctl -u kubelet
journalctl -u docker
journalctl -u containerd
journalctl -p err
  • Edit Verbosity of kube-proxy - Still no findings - kubectl edit daemonset kube-proxy -n kube-system - Save and Exit: After adding the verbosity flag, save the changes and exit the editor. Kubernetes will automatically update the DaemonSet and restart the kube-proxy pods to apply the new log level. :wq - vim write and quit.
containers:
- command:
  - kube-proxy
  - --config=/var/lib/kube-proxy/config.conf
  - -v=8
  • Even with level 8 verbosity, GPT can’t find anything wrong…
  • Install older version 1.23.17-00 - This is the answer - Complete reinstall - sudo apt-get install -y kubelet=1.23.17 kubeadm=1.23.17 kubectl=1.23.17 - Someone suggested: This problem appears on k8s v1.26 however it was absent on v1.23 kube-proxy pods continuously CrashLoopBackOff
    • [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 24.0.5. Latest validated version: 20.10

I had a similar problem, coredns and flannel were constantly restarting on the node where the kubeadm join was performed on the node worker with kubernetes v1.29. The problem disappeared after I copied the /etc/containerd/config.toml file from the master node deployed on ubuntu 22.04 and kubernetes version 1.28 to the worker node and restarted containerd. After this, coredns and flannel reboots stopped. Later, I tested another case - connecting a worker node (ubuntu 22.04 kubernetes 1.29) to a master node (Rocky Linux release 8.9 kubernetes 1.29) on which CrashLoopBackOff had previously been similarly repeated for coredns and kube-flannel and the problem disappeared, the reboots stopped. My config.toml is attached. Perhaps this will help someone. This idea was inspired by a post from reddit (https://www.reddit.com/r/kubernetes/comments/yjtv7q/flannel_and_kubeproxy_are_crashing/). config.txt

Same problem here, I have a k8s created with vagrant, kubeadm, with gpu being passthrough inside and other vms without. The one with gpu, node-1, is having a bad time with flannel, kube-proxy and metallb pods - they keep restarting however there’re no sensible errors other than “exit code 2”

This problem appears on k8s v1.26 however it was absent on v1.23

Screenshot 2023-12-10 at 19 00 58 Screenshot 2023-12-10 at 19 15 02 Screenshot 2023-12-10 at 19 04 35 Screenshot 2023-12-10 at 19 04 48 Screenshot 2023-12-10 at 19 08 40 Screenshot 2023-12-10 at 19 10 55

Same thing happens to another VM with a different gpu being passthrough so it’s not something specific to only this one VM or gpu. I did try to install nvidia-container-runtime with no luck. Nothing has changed.

UPD: it looks like a connectivity problem in my case. Some of the nodes live on a separate host and having trouble routing traffic properly inside LAN. I booted up master node on a host with gpu virtual machines and it works like a charm. Still investigating, my bet is on the vagrant default interface that messes things up. No proof just yet tho.

UPD2: So supposedly I had two default gateways configured and that messed the iptables for kube-proxy. I have removed extra default gw that was pre-made by vagrant and edited configs accordingly, now it seems everything is fine.

Screenshot 2023-12-12 at 22 08 53

On-Prem Kubernetes Cluster Setup – My Contribution & Troubleshooting Experience Hey everyone,

I recently configured a Kubernetes cluster on-premises in my personal datacenter, and I wanted to share my experience and the challenges I faced — hoping this helps others who are doing the same!

Infrastructure Overview 1 Master Server (Running KVM hypervisor)

2 Bare-metal Worker Nodes

1 Dedicated server for Object/NAS Storage (MinIO/NFS)

KVM-based Virtual Machines:

3 Master VMs (Master1 - Active, Master2 & Master3 - Passive)

Kubernetes initialized using kubeadm

CNI Plugin: Calico (installed using the official Tigera website)

Issues & Troubleshooting 1️⃣ Kube-proxy Crashing (CrashLoopBackOff) Issue: kube-proxy was continuously failing on both master and worker nodes.

Steps to Resolve:

Checked logs: Observed issues related to container runtime sandbox instability.

Root Cause: The container runtime version was incompatible with the Kubernetes version.

Solution:

Referenced the official Kubernetes compatibility matrix.

Reinstalled a stable container runtime version matching the Kubernetes version.

Restarted the containers and rejoined nodes.

Result: kube-proxy is now running smoothly on both master and worker nodes.

2️⃣ Calico Node CrashLoopBackOff Issue: calico-node pods were failing due to BGP peering issues.

Steps to Resolve:

Verified logs: BGP sessions were not establishing.

Confirmed:

Firewall rules were open.

Nodes were reachable.

Discovered that Calico was binding to the wrong interface/IP. (Each server had 4 NICs, but only eth1 had the correct static IP.)

Fix:

Removed the affected node from the cluster.

Edited the Calico configuration:

Disabled auto-detection.

Explicitly defined the IP_AUTODETECTION_METHOD=interface=eth1 in Calico DaemonSet.

Rejoined the node.

Checked BGP peering — still failing.

Entered the container, and discovered missing peer.config file.

Manually created the BGP peer configuration inside both Calico containers.

Restarted the pods.

Result: BGP peering successfully established. All Calico nodes are healthy now

Pro Tips Always use the official source: https://www.tigera.io for Calico documentation and installation manifests.

Set static IPs on each node and explicitly specify the correct network interface to avoid CNI binding issues.

Verify version compatibility between Kubernetes, container runtimes (like containerd/Docker), and kube-proxy.

Image

I guess this might also solve your problem sudo apt install nvidia-container-runtime