fix affinity rules for worker and apps
Signed-off-by: Pascal Sthamer <pascal+github@sthamer.xyz>
This commit is contained in:
@@ -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 }}
|
||||
|
||||
@@ -62,27 +62,6 @@ imagePullSecrets:
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the labels for a specific worker instance deployed via helm.
|
||||
Usage:
|
||||
{{ include "shuffle.workerInstance.labels" (dict "customLabels" .Values.commonLabels "context" $) -}}
|
||||
*/}}
|
||||
{{- define "shuffle.workerInstance.labels" -}}
|
||||
app.kubernetes.io/name: shuffle-worker
|
||||
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
|
||||
{{- with .context.Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ . | replace "+" "_" | quote }}
|
||||
{{- end -}}
|
||||
{{- if .customLabels }}
|
||||
{{- range $key, $value := .customLabels }}
|
||||
{{ $key }}: {{ $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the labels to match ALL workers.
|
||||
These match the labels of helm-deployed workers (shuffle.workerInstance.labels),
|
||||
@@ -92,19 +71,34 @@ as well as orborus-deployed workers (deployk8sworker).
|
||||
app.kubernetes.io/name: shuffle-worker
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the labels for a specific worker instance deployed via helm.
|
||||
Usage:
|
||||
{{ include "shuffle.workerInstance.labels" (dict "customLabels" $podLabels "context" $) -}}
|
||||
*/}}
|
||||
{{- define "shuffle.workerInstance.labels" -}}
|
||||
{{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-worker" "app.kubernetes.io/part-of" "shuffle") $customLabels -}}
|
||||
{{ include "common.labels.standard" (dict "customLabels" $customLabels "context" $) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the labels to match a helm-deployed worker.
|
||||
Usage:
|
||||
{{ include "shuffle.workerInstance.matchLabels" (dict "customLabels" .Values.commonLabels "context" $) -}}
|
||||
{{ include "shuffle.workerInstance.matchLabels" (dict "customLabels" $podLabels "context" $) -}}
|
||||
*/}}
|
||||
{{- define "shuffle.workerInstance.matchLabels" -}}
|
||||
app.kubernetes.io/name: shuffle-worker
|
||||
app.kubernetes.io/instance: {{ .context.Release.Name }}
|
||||
{{- if .customLabels }}
|
||||
{{- range $key, $value := .customLabels }}
|
||||
{{ $key }}: {{ $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-worker" "app.kubernetes.io/part-of" "shuffle") $customLabels -}}
|
||||
{{ include "common.labels.matchLabels" (dict "customLabels" $customLabels "context" $) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return a podAffinity/podAntiAffinity definition.
|
||||
Usage:
|
||||
{{ include "shuffle.workerInstance.affinities.pods" (dict "type" "soft" "customLabels" $podLabels "context" $) -}}
|
||||
*/}}
|
||||
{{- define "shuffle.workerInstance.affinities.pods" -}}
|
||||
{{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-worker" "app.kubernetes.io/part-of" "shuffle") .customLabels -}}
|
||||
{{ include "common.affinities.pods" (dict "type" .type "customLabels" $customLabels "context" .context )}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
|
||||
+3
-3
@@ -36,8 +36,8 @@ spec:
|
||||
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.worker.affinity "context" $) | nindent 8 }}
|
||||
{{- else }}
|
||||
affinity:
|
||||
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.worker.podAffinityPreset "component" "orborus" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.worker.podAntiAffinityPreset "component" "orborus" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||
podAffinity: {{- include "shuffle.workerInstance.affinities.pods" (dict "type" .Values.worker.podAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||
podAntiAffinity: {{- include "shuffle.workerInstance.affinities.pods" (dict "type" .Values.worker.podAntiAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.worker.nodeAffinityPreset.type "key" .Values.worker.nodeAffinityPreset.key "values" .Values.worker.nodeAffinityPreset.values) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.worker.nodeSelector }}
|
||||
@@ -66,7 +66,7 @@ spec:
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.worker.initContainers "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: orborus
|
||||
- name: worker
|
||||
image: {{ template "shuffle.worker.image" . }}
|
||||
imagePullPolicy: {{ .Values.worker.image.pullPolicy }}
|
||||
{{- if .Values.worker.containerSecurityContext.enabled }}
|
||||
|
||||
Reference in New Issue
Block a user