限制每个节点的Pod数量 [英] Limit the number of pods per node

查看:544
本文介绍了限制每个节点的Pod数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试限制群集中每个节点的Pod数量. 我设法通过配置文件从kubeadm init中为每个节点添加了全局限制:

I'm trying to limit the number of pods per each node from my cluster. I managed to add a global limit per node from kubeadm init with config file:

apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
networking:
  podSubnet: <subnet>
---
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
maxPods: 10

这不是很好,因为该限制甚至适用于主节点(正在运行多个kube系统吊舱,并且吊舱的数量可能会增加10个以上). 我想将默认值保留在init处,并在每个节点的join处更改其值. 我发现了一些东西:

This is not quite well because the limit is applied even on master node (where multiple kube-system pods are running and the number of pods here may increase over 10). I would like to keep the default value at init and change the value at join on each node. I have found something:

apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
maxPods: 10
---
apiVersion: kubeadm.k8s.io/v1beta1
kind: JoinConfiguration
discovery:
  bootstrapToken:
    apiServerEndpoint: "<api_endpoint>"
    token: "<token>"
    unsafeSkipCAVerification: true

但是,即使没有错误/警告出现,似乎maxPods的值也被忽略了.我可以为该特定节点创建10个以上的Pod. 还有kubectl get node <node> -o yaml returns status.capacity.pods及其默认值(110). 我该如何进行操作才能使每个节点都应用此pod限制?

but, even if no error/warning appears, it seems that the value of maxPods is ignored. I can create more than 10 pods for that specific node. Also kubectl get node <node> -o yaml returns status.capacity.pods with its default value (110). How can I proceed in order to have this pods limit applied per each node?

我想提一下,我具有与Kubernetes相关的基本知识/有限知识.

I would like to mention that I have basic/limited knowledge related to Kubernetes.

谢谢!

推荐答案

/var/lib/kubelet处有一个config.yaml文件.当您运行kubeadm join时,此配置文件是从kube-system命名空间中的kubelet配置映射生成的.文件的部分内容如下.

There is a config.yaml file at /var/lib/kubelet. This config file is generated from kubelet config map in kube-system namespace when you run kubeadm join.Partial content of the file is as below.

apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
  anonymous:
    enabled: false
  webhook:
    cacheTTL: 0s
    enabled: true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook
  webhook:
    cacheAuthorizedTTL: 0s
    cacheUnauthorizedTTL: 0s
clusterDNS:
- 10.96.0.10
maxPods: 10

您可以更改该文件并添加maxPods参数,然后在节点上重新启动kubelet.

You can change that file and add maxPods parameter and then restart kubelet on the node.

sudo systemctl restart kubelet 

当前在kubeadm联接中无法传递kubelet配置文件.

Currently in kubeadm join there is no way to pass a kubelet config file.

这篇关于限制每个节点的Pod数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆