Skip to content

Instantly share code, notes, and snippets.

@sudonewdev
Created February 9, 2022 01:08
Show Gist options
  • Save sudonewdev/37f006f855b9bef493e7bd63d5fd96f9 to your computer and use it in GitHub Desktop.
Save sudonewdev/37f006f855b9bef493e7bd63d5fd96f9 to your computer and use it in GitHub Desktop.
only .Release.Name values is being printed even after else-if condition is met.
{{/*
podAntiAffinity definition
*/}}
{{- define "pods.anti.affinities" -}}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
{{- if and ( default .Values.alpha true ) ( default .Values.beta false ) }}
values: {{ .Release.Name }}
{{- else if and ( default .Values.alpha false ) ( default .Values.beta true )}}
values: {{ .Values.extraLabels.nfname }}
{{- end }}
topologyKey: kubernetes.io/hostname
{{- end -}}
@sudonewdev
Copy link
Author

sudonewdev commented Feb 9, 2022

Applying podAntiAffinity
RELEASE-NAME is always executed even else-if condition is met.

the render template is always showing RELEASE-NAME

        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                - key: app.kubernetes.io/instance
                  operator: In
                  values:
                    - RELEASE-NAME
              topologyKey: kubernetes.io/hostname

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment