antonputra / tutorials

DevOps Tutorials
https://youtube.com/antonputra
MIT License
3.2k stars 2.5k forks source link

podAntiAffinity matchExpressions wrong Key #225

Closed omnix-aecheverry closed 5 months ago

omnix-aecheverry commented 7 months ago

I noticed that the pods were allocated on the same node. After investigating, I noticed that the key for matchExpressions should be 'name' instead of 'app' because the name of the app is 'my-mongodb-svc' not 'my-mongodb'. Even thought I also tried with 'my-mongodb-svc' and 'app', but it didn't work. When I changed the key to 'name', it worked because the replicaSet has the name 'my-mongodb'.

affinity:
  podAntiAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
    - labelSelector:
        matchExpressions:
        - key: app #This should be **name** instead of app
          operator: In
          values:
          - my-mongodb
antonputra commented 5 months ago

thanks :)

antonputra commented 5 months ago

I'll refresh this lesson at some point and update the code or you can create a PR. Thanks!