TL;DR:NodeSelector 忽略来自另一个 NodePool 的节点。如何使用标签 nodeSelector 或其他技术在更多 NodePools 中分发 pod?
我有两个这样的节点池:
...
# Spot node pool
resource "azurerm_kubernetes_cluster_node_pool" "aks_staging_np_compute_spot" {
name = "computespot"
(...)
vm_size = "Standard_F8s_v2"
max_count = 2
min_count = 2
(...)
priority = "Spot"
eviction_policy = "Delete"
(...)
node_labels = {
"pool_type" = "compute"
}
# Regular node pool
resource "azurerm_kubernetes_cluster_node_pool" "aks_staging_np_compute_base" {
name = "computebase"
(...)
vm_size = "Standard_F8s_v2"
max_count = 2
min_count = 2
node_labels = {
"pool_type" = "compute"
}
两个池都部署在 AKS 中,并且所有节点都处于正常状态。请注意两点:
- 两者都有标签
pool_type: compute
- 两者的尺寸相同
Standard_F8s_v2
(我的集群中还有 20 个不同标签的其他节点并不重要。)
然后我有一个这样的部署(为了简洁省略了不相关的行):
apiVersion: apps/v1
kind: Deployment
metadata:
(...)
spec:
replicas: 4
selector:
matchLabels:
app: myapp
template:
(...)
spec:
nodeSelector:
pool_type: compute
(...)
containers:
(...)
还有一个tolerations
用于接受 Azure 现场实例的条目。它显然有效。
tolerations:
- key: "kubernetes.azure.com/scalesetpriority"
operator: "Equal"
value: "spot"
effect: "NoSchedule"
问题是应用程序仅部署在一个节点池上("computespot"
在这种情况下),并且从不接触另一个节点池( computebase
)。即使标签和单个节点的大小相同。
- 2 个 pod 在
computespot
节点上运行,每个节点一个。 - 第二个 2 pod 没有安排经典错误
0/24 nodes are available: 14 Insufficient cpu, 17 Insufficient memory, 4 node(s) didn't match node selector.
这绝对是一个谎言,因为我可以看到computebase
节点只是坐在那里完全是空的。
如何解决?