Skip to content

Commit

Permalink
adding the ability to define extraLabels for the kubernetes Service o…
Browse files Browse the repository at this point in the history
…bject
  • Loading branch information
bjoernw committed Aug 17, 2023
1 parent 9116fa6 commit ef917b4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions helm/chart/router/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ extraLabels:
```
*/}}
{{- define "common.templatizeExtraLabels" -}}
{{- range $key, $value := .Values.extraLabels }}
{{ printf "%s: %s" $key (include "common.tplvalues.render" ( dict "value" $value "context" $))}}
{{- $extraLabels := .extraLabels -}}
{{- $ctx := .context -}}
{{- range $key, $value := $extraLabels }}
{{ printf "%s: %s" $key (include "common.tplvalues.render" (dict "value" $value "context" $ctx)) }}
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions helm/chart/router/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
{{- include "router.labels" . | nindent 4 }}
{{- if .Values.extraLabels }}
{{- include "common.templatizeExtraLabels" . | nindent 4 }}
{{ include "common.templatizeExtraLabels" (dict "extraLabels" .Values.extraLabels "context" $) | nindent 4 }}
{{- end }}
{{/* There may not be much configuration so check that there is something */}}
{{- if (((((.Values.router).configuration).telemetry).metrics).prometheus).enabled }}
Expand Down Expand Up @@ -35,7 +35,7 @@ spec:
labels:
{{- include "router.selectorLabels" . | nindent 8 }}
{{- if .Values.extraLabels }}
{{- include "common.templatizeExtraLabels" . | nindent 8 }}
{{ include "common.templatizeExtraLabels" (dict "extraLabels" .Values.extraLabels "context" $) | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
Expand Down
3 changes: 3 additions & 0 deletions helm/chart/router/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ metadata:
name: {{ include "router.fullname" . }}
labels:
{{- include "router.labels" . | nindent 4 }}
{{- if .Values.service.extraLabels }}
{{ include "common.templatizeExtraLabels" (dict "extraLabels" .Values.service.extraLabels "context" $) | indent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions helm/chart/router/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ service:
type: ClusterIP
port: 80
annotations: {}
extraLabels: {}

serviceMonitor:
enabled: false
Expand Down

0 comments on commit ef917b4

Please sign in to comment.