Rke2限制工作节点资源时出错

版本:rke2-agent-1.21.11或rke2-agent-1.21.10
操作系统:CentOS 8

问题描述:
在/etc/rancher/rke2/config.yaml中添加以下内容

kubelet-arg:
- "enforce-node-allocatable=pods,kube-reserved,system-reserved"
- "kube-reserved=cpu=1,memory=1G"
- "system-reserved=cpu=70,memory=225Gi"

启动agent后,日志重复出现下列错误信息:
Apr 19 16:28:03 gpu-10 rke2[908537]: time=“2022-04-19T16:28:03+08:00” level=error msg=“Kubelet exited: exit status 1”
注释kubelet-arg的内容后agent可以正常启动。

日志

Apr 19 16:28:03 gpu-10 systemd[1]: Started Rancher Kubernetes Engine v2 (agent).
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --volume-plugin-dir has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --file-check-frequency has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --sync-frequency has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --address has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --anonymous-auth has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --authentication-token-webhook has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --authorization-mode has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --client-ca-file has been deprecated, This parameter should be set via the config file specified by the Kubelet’s --config flag. See Set Kubelet parameters via a config file | Kubernetes for more information.
Apr 19 16:28:03 gpu-10 rke2[908537]: Flag --cloud-provider has been deprecated, will be removed in 1.23, in favor of removing cloud provider code from Kubelet.

Apr 19 16:28:03 gpu-10 rke2[908537]: time=“2022-04-19T16:28:03+08:00” level=error msg=“Kubelet exited: exit status 1”

看了下,格式是没问题的,我想确认下,你这些参数是从哪得到的?能否确认下这些参数是否正确。

参数来自https://v1-21.docs.kubernetes.io/zh/docs/tasks/administer-cluster/reserve-compute-resources和https://www.jianshu.com/p/703c3ad4991f。
另外RKE2有提供限制agent节点可使用资源的方法吗?

rke2 现在节点资源使用也是用的 kubelet,没啥特殊的。

你上面的参数使用了kube-reserved,system-reserved ,按照kubelet 参数说明,还需要设置其他的参数:
以下引用 你上面发的连接说明:

请注意,要想执行 kube-reserved 或者 system-reserved 约束, 需要对应设置 --kube-reserved-cgroup 或者 --system-reserved-cgroup

修改为上述内容后,kubelet可以正常运行。

1 个赞