我有以下的pod
NAME READY STATUS NODE LABELS
bss-a-0 5/5 Running aks-bss-0 tcb.segment=bss,tcb.zone=centralus-1
four-6mxdk 0/1 Pending <none> job-name=four
rat-a-0 7/7 Running aks-rat-1 tcb.segment=rat,tcb.zone=centralus-1
rat-b-0 7/7 Running aks-rat-2 tcb.segment=rat,tcb.zone=centralus-2
seagull-0 1/1 Running aks-bss-0 tcb.segment=ratfour-6mxdk是pod,包含以下pod亲和性部分:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: tcb.segment
operator: In
values:
- rat
- key: tcb.zone
operator: In
values:
- centralus-1
namespaces:
- default
topologyKey: k8s.io/hostname节点详细信息:
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
volumes.kubernetes.io/controller-managed-attach-detach: "true"
labels:
agentpool: rat
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/instance-type: Standard_D32s_v3
beta.kubernetes.io/os: linux
failure-domain.beta.kubernetes.io/region: centralus
failure-domain.beta.kubernetes.io/zone: centralus-1
kubernetes.azure.com/cluster: cluster
kubernetes.azure.com/role: agent
kubernetes.io/arch: amd64
kubernetes.io/hostname: aks-rat-1
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
storageprofile: managed
storagetier: Premium_LRS
name: aks-rat-1
allocatable:
attachable-volumes-azure-disk: "32"
cpu: 31580m
ephemeral-storage: "93492541286"
hugepages-1Gi: "0"
hugepages-2Mi: "0"
memory: 121466760Ki
pods: "30"
nodeInfo:
architecture: amd64
containerRuntimeVersion: docker://3.0.8
kernelVersion: 4.15.0-1069-azure
kubeProxyVersion: v1.15.7
kubeletVersion: v1.15.7
operatingSystem: linux
osImage: Ubuntu 16.04.6 LTS我的预期是: pod将被安排在node: aks-rat-1上,因为它是唯一一个两个标签都匹配的节点。
实际结果:3个节点不匹配pod亲和性/反亲和性。
是bug吗?还是我做错了什么?
发布于 2020-05-12 20:20:57
看起来aks使用kubernetes.io/hostname而不是k8s.io/hostname,或者由于某些版本的K8,它被更改了,并且大多数文档都没有更新。无论如何,topologyKey在这里是一个问题。
https://stackoverflow.com/questions/61750075
复制相似问题