kubernetes: Cannot set kubelet config `resolvConf` with drop-in config files
What happened?
I created a kubernetes cluster with kubeadm and created a drop-in directory for kubelet configuration at /etc/kubernetes/kubelet.conf.d.
I created a config file within the directory to change the value of resolvConf. After restarting kubelet, the value of resolvConf stayed same.
What did you expect to happen?
The value of resolvConf is updated.
How can we reproduce it (as minimally and precisely as possible)?
# Create custom resolv.conf
echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.kubelet.conf
# Create drop-in config directory
sudo mkdir /etc/kubernetes/kubelet.conf.d
sudo chmod 700 /etc/kubernetes/kubelet.conf.d
# Create drop-in config file
cat <<EOF | sudo tee /etc/kubernetes/kubelet.conf.d/99-resolv-conf.conf
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
resolvConf: /etc/resolv.kubelet.conf
EOF
sudo chmod 600 /etc/kubernetes/kubelet.conf.d/99-resolv-conf.conf
# Add --config-dir flag
echo 'KUBELET_EXTRA_ARGS=--config-dir=/etc/kubernetes/kubelet.conf.d' | sudo tee /etc/default/kubelet
sudo systemctl daemon-reload
sudo systemctl restart kubelet
# Check if the value of resolvConf is changed.
kubectl get --raw "/api/v1/nodes/<node name>/proxy/configz" | jq
Anything else we need to know?
I think this issue is particular to the drop-in config and resolvConf option because:
- I can configure
resolvConfby editing/var/lib/kubelet/config.yaml - I can update another option like
streamingConnectionIdleTimeoutwith drop-in config.
Kubernetes version
$ kubectl version
Client Version: v1.30.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.3
Cloud provider
No cloud provider
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 vm-1aefb131-31 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux
Install tools
kubeadm
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, …) and versions (if applicable)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 26 (23 by maintainers)
Before fixing it, or if we don’t plan to fix it, specifically handling the resolvConf field in https://github.com/kubernetes/kubernetes/blob/0f095cf0ba5156a972b446a5f65c963fe2a7919c/cmd/kubelet/app/server.go#L306-L312 seems like a reasonable option.
I believe they are the same issue (because the subsequent discussion in #79421 deviated from its original topic). At least from https://github.com/kubernetes/kubernetes/issues/79421#issuecomment-2198462046 onwards , the issue aligns with what’s being discussed here.
The root cause is that the
ResolverConfigfield ofKubeletConfigurationdoes not match its json key https://github.com/kubernetes/kubernetes/blob/0f095cf0ba5156a972b446a5f65c963fe2a7919c/staging/src/k8s.io/kubelet/config/v1beta1/types.go#L443-L448If we use the
resolverConfigfield in the drop-in config file, it will be correctly configured in the kubelet’s configuration.However, in the main kubelet config file, only the
resolvConffield will be correctly configured into the kubelet’s configuration.