大家在k8s实际的使用中或许会碰到这个现象,就是pod到达一定的数量,明明节点内存还有很多但是为什么就是不让新建pod了呢,我来和大家说下
默认情况下k8s 一个node最多起110个pod.
那么如何修改一个node中起的pod数量呢?
在Node上 设置打开文件/var/lib/kubelet/config.yaml
修改参数maxPods为指定的值,这里我们把它修改为230:
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
logging: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
resolvConf: /run/systemd/resolve/resolv.conf
rotateCertificates: true
runtimeRequestTimeout: 0s
shutdownGracePeriod: 0s
shutdownGracePeriodCriticalPods: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s
maxPods: 230
修改完之后重启下面的服务
systemctl daemon-reload
systemctl restart kubelet
查询状态:
$ kubectl describe node host07 | grep -i “Capacity|Allocatable” -A 6
Capacity:
cpu: 192
ephemeral-storage: 9298787068Ki
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 1056273036Ki
pods: 230
Allocatable:
cpu: 192
ephemeral-storage: 8569762147680
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 1056170636Ki
pods: 230
从上面可以清晰的看到pods限制的数量已经被修改为230个了,问题解决