使用 CNI 增加 AKS 中每个节点的最大 Pods 数量有什么缺点?

What is the downside of increasing the maximum number of Pods per node in AKS with CNI?

在 Azure Kubernetes 服务中创建新节点池时,CNI 和 Kubenet(以及用于创建节点池的工具)每个节点的默认最大数量 Pods 不同。根据 docs,CNI 默认设置通常为 30,但 Kubenet 默认设置为 110。

为什么 CNI 的默认设置较低?增加实际值有什么缺点,例如,像 Kubenet 一样增加到 110?

110 是 Kubernetes 上游定义的默认大小。使用 Kubnet,只有节点在您的 Azure 子网上获得 IP。所有 pods 从节点上的逻辑网络获取 IP,并且它们使用 NAT (iptables) 与 Azure 网络通信。

当您使用 Azure CNI 时,Azure pre-allocates IP 在您的子网中。你可以在这里阅读:

Each node is configured with a primary IP address. By default, 30 additional IP addresses are pre-configured by Azure CNI that are assigned to pods scheduled on the node.

这意味着对于最大 pods 30 的每个节点,您的 subnet.If 中需要 31 个可用地址 您的子网太小,您无法添加任何新节点,因为 Azure 需要这 31 个 IP添加此节点的地址。

我认为最大 pods 30 更像是一个安全值,因为人们倾向于使用 /24 子网。使用 max pods 110,您只能向该子网添加 2 个节点。如果您的 AKS 是 运行,您不能更改子网或最大 pods 大小 - 这将需要创建一个新的 AKS。

在您的节点上使用最大 pods 110 没有任何缺点,只是您需要相应地调整子网的大小并且需要更多的规划。在我们的 AKS 集群上,我们主要使用 /16 vnet 和 /21 子网,最大 pods 110:

Clusters configured with Azure CNI networking require additional planning. The size of your virtual network and its subnet must accommodate the number of pods you plan to run and the number of nodes for the cluster.