apiVersion: v1
kind: Pod
metadata:
  name: pod-pa-1
  labels:
    app: hello-app
spec:
  containers:
  - name: hello-app
    image: gcriogooglesamples/hello-app:1.0
    ports:
    - name: http
      containerPort: 8080
---
apiVersion: v1
kind: Pod
metadata:
  name: pod-pa-2
  labels:
    app: hello-app
spec:
  containers:
  - name: hello-app
    image: gcriogooglesamples/hello-app:1.0
    ports:
    - name: http
      containerPort: 8080
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions:
          # - key: {key: app, operator: In, values: ["hello-app"]}
          - key: app
            operator: In
            values:
            - hello-app
        topologyKey: kubernetes.io/hostname  # Pod 亲和性的判断标志
        # topologyKey: rack
