fix label matching for worker and apps

Signed-off-by: Pascal Sthamer <pascal+github@sthamer.xyz>
This commit is contained in:
Pascal Sthamer
2025-12-03 11:58:46 +01:00
parent b6376cf967
commit 69c7c7bb06
8 changed files with 49 additions and 18 deletions
@@ -51,14 +51,14 @@ spec:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels: {{ include "shuffle.workerInstance.matchLabels" . | nindent 14 }}
matchLabels: {{ include "shuffle.worker.matchLabels" . | nindent 14 }}
# Allow traffic from apps
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels: {{ include "shuffle.appInstance.matchLabels" . | nindent 14 }}
matchLabels: {{ include "shuffle.app.matchLabels" . | nindent 14 }}
{{- end }}
{{- if .Values.backend.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.backend.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
@@ -48,7 +48,7 @@ spec:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels: {{ include "shuffle.workerInstance.matchLabels" . | nindent 14 }}
matchLabels: {{ include "shuffle.worker.matchLabels" . | nindent 14 }}
{{- if .Values.orborus.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.orborus.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
@@ -87,7 +87,7 @@ app.kubernetes.io/managed-by: {{ .context.Release.Service }}
app.kubernetes.io/part-of: shuffle
app.shuffler.io/name: {{ include "shuffle.appInstance.name" .app }}
app.shuffler.io/version: {{ .app.version | quote }}
{{- if .customValues }}
{{- if .customLabels }}
{{- range $key, $value := .customLabels }}
{{ $key }}: {{ $value }}
{{- end }}
@@ -95,12 +95,29 @@ app.shuffler.io/version: {{ .app.version | quote }}
{{- end -}}
{{/*
Return the match labels for apps.
These must match the labels of helm-deployed apps (shuffle.appInstance.labels),
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
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 -}}
{{/*
@@ -11,7 +11,7 @@ metadata:
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.app.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "shuffle.appInstance.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
matchLabels: {{- include "shuffle.app.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
policyTypes:
- Ingress
- Egress
@@ -48,7 +48,7 @@ spec:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels: {{ include "shuffle.workerInstance.matchLabels" . | nindent 14 }}
matchLabels: {{ include "shuffle.worker.matchLabels" . | nindent 14 }}
{{- if .Values.app.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.app.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
@@ -64,7 +64,7 @@ spec:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels: {{ include "shuffle.workerInstance.matchLabels" . | nindent 14 }}
matchLabels: {{ include "shuffle.worker.matchLabels" . | nindent 14 }}
{{- end }}
{{- if .Values.app.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.app.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
@@ -214,7 +214,6 @@ spec:
{{- if or $appValues.pdb.maxUnavailable ( not $appValues.pdb.minAvailable ) }}
maxUnavailable: {{ $appValues.pdb.maxUnavailable | default 1 }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $appValues.podLabels $.Values.commonLabels ) "context" $ ) }}
selector:
matchLabels: {{- include "shuffle.appInstance.matchLabels" ( dict "app" $app "customLabels" $podLabels "context" $ ) | nindent 6 }}
{{- end }}
@@ -76,7 +76,7 @@ app.kubernetes.io/part-of: shuffle
{{- with .context.Chart.AppVersion }}
app.kubernetes.io/version: {{ . | replace "+" "_" | quote }}
{{- end -}}
{{- if .customValues }}
{{- if .customLabels }}
{{- range $key, $value := .customLabels }}
{{ $key }}: {{ $value }}
{{- end }}
@@ -84,12 +84,27 @@ app.kubernetes.io/version: {{ . | replace "+" "_" | quote }}
{{- end -}}
{{/*
Return the match labels for workers.
These must match the labels of helm-deployed workers (shuffle.workerInstance.labels),
Return the labels to match ALL workers.
These match the labels of helm-deployed workers (shuffle.workerInstance.labels),
as well as orborus-deployed workers (deployk8sworker).
*/}}
{{- define "shuffle.worker.matchLabels" -}}
app.kubernetes.io/name: shuffle-worker
{{- end -}}
{{/*
Return the labels to match a helm-deployed worker.
Usage:
{{ include "shuffle.workerInstance.matchLabels" (dict "customLabels" .Values.commonLabels "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 }}
{{- end -}}
{{/*
@@ -9,9 +9,8 @@ metadata:
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.worker.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "shuffle.workerInstance.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
matchLabels: {{- include "shuffle.worker.matchLabels" . | nindent 6 }}
policyTypes:
- Ingress
- Egress
@@ -35,7 +34,7 @@ spec:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels: {{ include "shuffle.appInstance.matchLabels" . | nindent 14 }}
matchLabels: {{- include "shuffle.app.matchLabels" . | nindent 14 }}
{{- if .Values.worker.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.worker.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
@@ -57,7 +56,7 @@ spec:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels: {{ include "shuffle.appInstance.matchLabels" . | nindent 14 }}
matchLabels: {{- include "shuffle.app.matchLabels" . | nindent 14 }}
{{- end }}
{{- if .Values.worker.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.worker.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
@@ -17,5 +17,6 @@ spec:
targetPort: 33333
protocol: TCP
appProtocol: http
selector: {{- include "shuffle.workerInstance.matchLabels" $ | nindent 4 }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.worker.podLabels .Values.commonLabels ) "context" . ) }}
selector: {{- include "shuffle.workerInstance.matchLabels" (dict "customLabels" $podLabels "context" .) | nindent 4 }}
{{- end }}