apiVersion: v1
kind: Pod
metadata:
  generateName: preferred-affinity-pod-
  labels:
    color: red
spec:
  affinity:
    podAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
        - podAffinityTerm:
            labelSelector:
              matchLabels:
                color: red
            topologyKey: kubernetes.io/hostname
            namespaceSelector:
              matchLabels:
                team: devops
          weight: 1
  containers:
    - image: k8s.gcr.io/pause:3.4.1
      name: pause
      ports:
        - containerPort: 80
      resources:
        limits:
          cpu: 100m
          memory: 500Mi
        requests:
          cpu: 100m
          memory: 500Mi
