antonputra/tutorials

podAntiAffinity matchExpressions wrong Key

omnix-aecheverry opened this issue · 2 comments

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

thanks :)

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