Skip to content

Commit

Permalink
only add default affinity when there are pvc labels known
Browse files Browse the repository at this point in the history
  • Loading branch information
PrivatePuffin committed Feb 7, 2025
1 parent 6c33096 commit 104d5f7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions charts/library/common/templates/lib/pod/_affinity.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ objectData: The object data to be used to render the Pod.

{{- $validTypes := (list "Deployment" "StatefulSet") -}}
{{/* TODO: We need to merge default with user input */}}
{{- if and (mustHas $objectData.type $validTypes) $rootCtx.Values.podOptions.defaultAffinity }}
{{- $pvcLabels := (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)) -}}
{{- if and (mustHas $objectData.type $validTypes) $pvcLabels $rootCtx.Values.podOptions.defaultAffinity }}
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)}}
- {{ $pvcLabels }}
topologyKey: "kubernetes.io/hostname"
{{- else -}}
{{- with $affinity -}} {{/* TODO: Template this, so we can add some validation around easy to make mistakes. Low Prio */}}
Expand Down

0 comments on commit 104d5f7

Please sign in to comment.