调整 Kubernetes 节点 Pod 上限:如何突破单节点 110 个限制
调整k8s node单节点可运行的pod突破110上限
- 官方文档: https://kubernetes.io/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/
使用 systemctl status kubelet 查看kubelet.service文件的路径
可以看到配置文件在 /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
[root@k8s-node1]# cat /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/sysconfig/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
此文件我们发现 KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml
直接在KUBELET_CONFIG_ARGS 中添加参数即可
修改 /var/lib/kubelet/config.yaml
配置文件,在最下面添加一行 maxPods: xxx
我们修改下maxPods的数值,增大到300(具体按照你node节点资源情况设置,不建议设置的过大)
修改完成之后重启下kubelet服务[不会影响正在运行的容器]
$ systemctl daemon-reload
$ systemctl restart kubelet
- 模拟调整pod 数量,运行500个pod;观察运行情况
#调整pod数量到500
[root@k8s-master01 system]# kubectl scale deployment my-nginx-test --replicas=500
deployment.apps/my-nginx-test scaled
#两个mode节点
[root@k8s-master01 system]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master01 Ready control-plane,master 24h v1.20.15
k8s-master02 Ready control-plane,master 24h v1.20.15
k8s-node1 Ready <none> 24h v1.20.15
k8s-node2 Ready <none> 53m v1.20.15
#查看run 的pod 数量
[root@k8s-master01 system]# kubectl get pods | grep -i run | wc -l
500
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 运维小弟
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果