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