Skip to content

podAntiAffinity throws error when topologyKey for zones are used #390

@anthr76

Description

@anthr76

Which version of kube-score are you using?

kube-score version: 1.12.0, commit: 82810c4, built: 2021-08-28T20:47:35Z

Wrote a deployment with

      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app.kubernetes.io/name
                  operator: In
                  values:
                  - secret-app
              topologyKey: topology.kubernetes.io/zone
            weight: 60

Got told:

apps/v1/Deployment secret-app in secret-app                              🤔                                             
    [WARNING] Deployment has host PodAntiAffinity                                                                            
        · Deployment does not have a host podAntiAffinity set                                                                
            It's recommended to set a podAntiAffinity that stops multiple pods                                               
            from a deployment from being scheduled on the same node. This                                                    
            increases availability in case the node becomes unavailable.                                                     

Though if I change the topologyKey to hostname it works..

      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app.kubernetes.io/name
                  operator: In
                  values:
                  - secret-app
              topologyKey: topology.kubernetes.io/hostname
            weight: 60

Commands used to invoke kubescore

kustomize build . | kube-score score --ignore-test container-image-pull-policy --ignore-test pod-networkpolicy --ignore-tes
t deployment-has-poddisruptionbudget -                                                                                       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions