Kubernetes:编辑节点配置时没有错误,但更改未反映出来

Kubernetes:编辑节点配置时没有错误,但更改未反映出来

我正在关注这个教程kubernetes 站点重新配置我的节点,以便我可以gracefullshutdown从 0 秒更改为 30 秒。

从生成 configz 文件后kubectl proxy,我进行了更改并将其推送到控制平面 kube-system 配置位置。

运行:k get configmap -n kube-system产生以下结果:

NAME                                 DATA   AGE
coredns                              1      113d
extension-apiserver-authentication   6      113d
kube-flannel-cfg                     2      113d
kube-proxy                           2      113d
kube-root-ca.crt                     1      113d
kubeadm-config                       1      113d
kubelet-config-1.22                  1      113d
my-config-v1-ttk6dmhmmk              1      55m

查看后my-config-v1-ttkxxxxxx发现,经过我的修改后,它的格式确实正确gracefullshutdown

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
  kubelet: |
    {
      "enableServer": true,
      "staticPodPath": "/etc/kubernetes/manifests",
      "syncFrequency": "1m0s",
       ...
      "enableSystemLogHandler": true,
      "shutdownGracePeriod": "30s",
      "shutdownGracePeriodCriticalPods": "10s",
      "enableProfilingHandler": true,
      "enableDebugFlagsHandler": true,
      "seccompDefault": false,
      "memoryThrottlingFactor": 0.8,
      "registerNode": true,
      "kind": "KubeletConfiguration",
      "apiVersion": "kubelet.config.k8s.io/v1beta1"
    }
kind: ConfigMap
metadata:
  creationTimestamp: "2022-03-26T09:52:34Z"
  name: my-config-v1-ttk6dmhmmk
  namespace: kube-system
  resourceVersion: "168825"
  uid: 09876a0a-fadd-4bc4-b80a-6a058304f304

这就是问题所在

我正在尝试将此配置图应用到节点。我没有收到任何错误,但更改也没有应用...

NODE_NAME=my-node-1
CONFIG_MAP_NAME=my-config-v1-ttk6dmhmmk
kubectl patch node ${NODE_NAME} -p "{\"spec\":{\"configSource\":{\"configMap\":{\"name\":\"${CONFIG_MAP_NAME}\",\"namespace\":\"kube-system\",\"kubeletConfigKey\":\"kubelet\"}}}}"

# result:
node/my-node-1 patched

最后,当我回头检查时,kubectl get no ${NODE_NAME} -o json | jq '.status.config'结果是null......

知道发生什么事了吗?

相关内容