fix affinity rules for worker and apps

Signed-off-by: Pascal Sthamer <pascal+github@sthamer.xyz>
This commit is contained in:
Pascal Sthamer
2025-12-03 12:43:29 +01:00
parent e3d78fbf0c
commit d63db15c42
4 changed files with 53 additions and 61 deletions
@@ -55,6 +55,16 @@ imagePullSecrets:
{{- end }}
{{- end -}}
{{/*
Return the match labels for ALL apps.
These match the labels of helm-deployed apps (shuffle.appInstance.labels),
as well as worker-deployed apps (deployK8sApp).
*/}}
{{- define "shuffle.app.matchLabels" -}}
app.kubernetes.io/name: shuffle-app
{{- end -}}
{{/*
Return the sanitized name of a shuffle app.
Usage:
@@ -79,45 +89,33 @@ Usage:
{{ include "shuffle.appInstance.labels" (dict "app" $app "customLabels" .Values.commonLabels "context" $) }}
*/}}
{{- define "shuffle.appInstance.labels" -}}
app.kubernetes.io/name: shuffle-app
app.kubernetes.io/instance: {{ include "shuffle.appInstance.fullname" .app }}
helm.sh/chart: {{ include "common.names.chart" .context }}
app.kubernetes.io/instance: {{ .context.Release.Name }}
app.kubernetes.io/managed-by: {{ .context.Release.Service }}
app.kubernetes.io/part-of: shuffle
{{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-app" "app.kubernetes.io/part-of" "shuffle") $customLabels -}}
{{ include "common.labels.standard" (dict "customLabels" $customLabels "context" $) }}
app.shuffler.io/name: {{ include "shuffle.appInstance.name" .app }}
app.shuffler.io/version: {{ .app.version | quote }}
{{- if .customLabels }}
{{- range $key, $value := .customLabels }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
Return the match labels for ALL apps.
These match the labels of helm-deployed apps (shuffle.appInstance.labels),
as well as worker-deployed apps (deployK8sApp).
*/}}
{{- define "shuffle.app.matchLabels" -}}
app.kubernetes.io/name: shuffle-app
{{- end -}}
{{/*
Return the match labels of a single app, deployed via helm.
Usage:
{{ include "shuffle.appInstance.matchLabels" (dict "app" $app "customLabels" .Values.commonLabels "context" $) }}
*/}}
{{- define "shuffle.appInstance.matchLabels" -}}
app.kubernetes.io/name: shuffle-app
{{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-app" "app.kubernetes.io/part-of" "shuffle") $customLabels -}}
{{ include "common.labels.matchLabels" (dict "customLabels" $customLabels "context" $) }}
app.shuffler.io/name: {{ include "shuffle.appInstance.name" .app }}
app.shuffler.io/version: {{ .app.version | quote }}
{{- if .customLabels }}
{{- range $key, $value := .customLabels }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
Return a podAffinity/podAntiAffinity definition.
Usage:
{{ include "shuffle.appInstance.affinities.pods" (dict "type" "soft" "app" $app "customLabels" $podLabels "context" $) -}}
*/}}
{{- define "shuffle.appInstance.affinities.pods" -}}
{{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-app" "app.kubernetes.io/part-of" "shuffle") .customLabels -}}
{{- $extraMatchLabels := dict "app.shuffler.io/name" (include "shuffle.appInstance.name" .app) "app.shuffler.io/version" (.app.version | quote) }}
{{ include "common.affinities.pods" (dict "type" .type "customLabels" $customLabels "context" .context "extraMatchLabels" $extraMatchLabels )}}
{{- end -}}
{{/*
@@ -73,8 +73,8 @@ spec:
affinity: {{- include "common.tplvalues.render" ( dict "value" $appValues.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" $appValues.podAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" $appValues.podAntiAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
podAffinity: {{- include "shuffle.appInstance.affinities.pods" (dict "app" $app "type" $appValues.podAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "shuffle.appInstance.affinities.pods" (dict "app" $app "type" $appValues.podAntiAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" $appValues.nodeAffinityPreset.type "key" $appValues.nodeAffinityPreset.key "values" $appValues.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if $appValues.nodeSelector }}