0

I want to make sure that pods of my deployment are schedules across the nodes. To do so, I'm using preferred pod anti affinity. However, I observe that pods are not equally distributed among the nodes. For instance, there are still some available nodes with enough spaces, but I don't see any pods schedules to that nodes (they do not have any toleration either)

Deployment manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-name
spec:
  template:
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: name
                  operator: In
                  values:
                  - service-name
              topologyKey: kubernetes.io/hostname 
            weight: 100

PodDisruptionBudget manifest

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: service-name
spec:
  maxUnavailable: "50%"
  selector:
    matchLabels:
      name: service-name

Do you happen to know what might lay under this issue? Thanks

cosmos-1905-14
  • 783
  • 2
  • 12
  • 23
  • `preferred...` is best-effort. if you want them to strictly be on separate nodes, use `requiredDuringSchedulingIgnoredDuringExecution`. – Roddy of the Frozen Peas Oct 19 '22 at 20:25
  • 1
    @RoddyoftheFrozenPeas if required is used, I think pods won't be scheduled if there's no nodes more than pods. I also want all pods are scheduled, too. – cosmos-1905-14 Oct 20 '22 at 13:32

0 Answers0