4.3.4.2. Pod のアンチアフィニティー
以下の例は、一致するラベルとラベルセレクターを持つ Pod に関する Pod のアンチアフィニティーを示しています。
Pod pod-s1 にはラベル
security:s1が付けられています。apiVersion: v1 kind: Pod metadata: name: pod-s1 labels: security: s1 # ... spec: securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault containers: - name: ocp image: docker.io/ocpqe/hello-pod securityContext: allowPrivilegeEscalation: false capabilities: drop: [ALL] # ...Pod pod-s2 には、
podAntiAffinityの下にラベルセレクターsecurity:s1が付けられています。apiVersion: v1 kind: Pod metadata: name: pod-s2 # ... spec: securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: security operator: In values: - s1 topologyKey: kubernetes.io/hostname containers: - name: pod-antiaffinity image: docker.io/ocpqe/hello-pod securityContext: allowPrivilegeEscalation: false capabilities: drop: [ALL] # ...-
Pod pod-s2 は
pod-s1と同じノードにスケジュールできません。