增加k8s节点的maxPods

时间:2020-07-30 19:26:16

标签: kubernetes

我正在尝试动态增加k8s节点的maxPods。目前将其设置为30,我想将其设置为50。我正在按照以下说明操作:https://kubernetes.io/docs/tasks/administer-cluster/reconfigure-kubelet/

在节点上,我添加了--dynamic-config-dir标志并重新启动了kubelet

然后我添加了一个maxPods设置为50的configmap,并将configSource部分添加到该节点:

configSource:
    configMap:
        name: my-node-name
        namespace: kube-system
        kubeletConfigKey: kubelet

我可以通过以下方式验证configmap是否已应用:

kubectl get no ${NODE_NAME} -o json | jq '.status.config'
{
  "active": {
    "configMap": {
      "kubeletConfigKey": "kubelet",
      "name": "my-node-config-c87h9fm782",
      "namespace": "kube-system",
      "resourceVersion": "54483288",
      "uid": "144bd26f-d290-11ea-bb9d-5e7d8d22eed0"
    }
  },
  "assigned": {
    "configMap": {
      "kubeletConfigKey": "kubelet",
      "name": "my-node-config-c87h9fm782",
      "namespace": "kube-system",
      "resourceVersion": "54483288",
      "uid": "144bd26f-d290-11ea-bb9d-5e7d8d22eed0"
    }
  },
  "lastKnownGood": {
    "configMap": {
      "kubeletConfigKey": "kubelet",
      "name": "my-node-config-c87h9fm782",
      "namespace": "kube-system",
      "resourceVersion": "54483288",
      "uid": "144bd26f-d290-11ea-bb9d-5e7d8d22eed0"
    }
  }
}

但是该节点仍仅运行30个Pod,并且在Pod处于Pending状态时,任何尝试部署另一个Pod的尝试都会失败。

我拉下configmap,并确认maxPods设置为50。

我想念什么?任何帮助将不胜感激

谢谢

杰里

2 个答案:

答案 0 :(得分:1)

每个节点的默认最大POD值为110

ubuntu@k8s-master-1:~$ kubectl describe nodes k8s-worker-1  | grep -i "Capacity\|Allocatable" -A 6
Capacity:
  cpu:                2
  ephemeral-storage:  12131484Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             4046184Ki
  pods:               110
Allocatable:
  cpu:                2
  ephemeral-storage:  11180375636
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             3943784Ki
  pods:               110

在工作节点上查找kubelet的配置文件路径

ubuntu@k8s-worker-1:~$ ps -ef | grep -i kubelet
ubuntu    5077  5005  0 20:07 pts/0    00:00:00 grep --color=auto -i kubelet
root     23930     1  1 06:42 ?        00:15:18 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=systemd --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.2

根据需要在/var/lib/kubelet/config.yaml上更新/添加maxPods字段,然后在工作节点上重新启动kubelet

ubuntu@k8s-worker-1:~$ sudo cat /var/lib/kubelet/config.yaml
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
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
rotateCertificates: true
runtimeRequestTimeout: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s
maxPods: 500

重新启动kubelet之后,现在应该更改“验证广告连播”的值

ubuntu@k8s-master-1:~$ kubectl describe nodes k8s-worker-1  | grep -i "Capacity\|Allocatable" -A 6
Capacity:
  cpu:                2
  ephemeral-storage:  12131484Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             4046184Ki
  pods:               500
Allocatable:
  cpu:                2
  ephemeral-storage:  12131484Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             3943784Ki
  pods:               500

答案 1 :(得分:1)

如果在创建新节点池时未指定maxPods,则Azure CNI的默认值为30

您可以在群集部署时或在添加新节点池时配置每个节点的最大Pod数。如果使用Azure CLI或资源管理器模板进行部署,则可以将每个节点的最大容器数设置为250。

您可以通过Azure CLI进行更改-使用az aks create命令部署群集时,请指定--max-pods参数。最大值为250。

使用Azure门户部署群集时,无法更改每个节点的最大Pod数量。

请在此处阅读如何更改现有群集中的值

Reference Doc