Where will this pod be positioned?
apiVersion: v1
kind: Pod
metadata:
name: nginx-anti-pod
labels:
app: nginx-anti-pod
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginx-pod
topologyKey: kubernetes.io/zone
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80
this pod should be placed in the same zone of nginx-pod, right?
Note that zone label is typically used in cloud environment. You can check if your node has the necessary label first by kubectl get node <node name> --show-labels
. If you are running in local mode, you can add label to your node by kubectl label node <node name> topology.kubernetes.io/zone=<zone>
, then update your affinity spec to use topologyKey: topology.kubernetes.io/zone