kubernetes版本要求: 1.24+
找到对应的工作节点查看kubelet进程信息,查找Config文件所在目录。
systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: active (running) since Thu 2023-05-04 15:00:49 CST; 4min 45s ago
Docs: https://kubernetes.io/docs/
Main PID: 43623 (kubelet)
Tasks: 69
Memory: 192.0M
CGroup: /system.slice/kubelet.service
└─43623 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=unix:///va...
...
修改配置文件/var/lib/kubelet/config.yaml
,在配置文件最后一加上 maxPods: Number
。
vim /var/lib/kubelet/config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
...
kind: KubeletConfiguration
...
volumeStatsAggPeriod: 0s
maxPods: 150 # 添加的配置内容,默认为110个,设置成150个。
修改保存之后,重新加载配置和重启kubelet。
systemctl daemon-reload
systemctl restart kubelet
验证结果。(在master节点操作)
kubectl describe node node-name|grep -A6 "Capacity\|Allocatable"
Capacity:
...
pods: 150 # 已变成150个
Allocatable:
...
pods: 150 # 已变成150个
配置文件内容: