I have some questions and thoughts about common k8s labels and template defines in our helm charts. I mostly maintain the various eventgate deployments, so my perspective comes from running multiple deployment services all from the same Helm chart. I'll use eventgate in the examples below.
Perhaps we just need some good documentation of what these terms mean, or perhaps we should refactor some of them.
First, the wmf.* defines in _helpers.tpl:
{{- define "wmf.chartname" -}}
{{- default .Chart.Name .Values.chartName | trunc 63 | trimSuffix "-" -}}- Why do we need to support .Values.chartName?
{{- define "wmf.releasename" -}}
{{- $name := default .Chart.Name .Values.chartName -}}
{{- printf "%s-%s" $name .Release.Name | trunc 63 | trimSuffix "-" -}}- For eventgate, this makes wmf.releasename == 'eventgate-production' for each eventgate deployment. I learned that this is safe because each deployment is in its own namespace, e.g. eventgate-main. I assume that since this concats chart + release name, this is intended to fully identify the WMF deployed release. It doesn't. Perhaps this is just poorly named?
{{- define "wmf.chartid" -}}
{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}- If we support .Values.chartName, shouldn't wmf.chartid also use it?
- This probably needs normalized to 63 chars too, right?
{{- define "wmf.appbaseurl" -}}
http://{{ template "wmf.releasename" . }}:{{ .Values.main_app.port }}- Because wmf.releasename is e.g. eventgate-production, wmf.appbaseurl is probably useless, no? Or, perhaps I am misunderstanding what wmf.appbbaseurl is for. Maybe we just need more doc comments in _helpers.tpl?
And Service naming label question. From _tls_helpers.yaml:
apiVersion: v1
kind: Service
metadata:
name: {{ template "wmf.releasename" . }}-tls-service
labels:
app: {{ template "wmf.chartname" . }}
chart: {{ template "wmf.chartid" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: NodePort
selector:
app: {{ template "wmf.chartname" . }}
routed_via: {{ .Release.Name }}
ports:
- name: {{ template "wmf.releasename" . }}-https
protocol: TCP
port: {{ .Values.tls.public_port }}
nodePort: {{ .Values.tls.public_port }}- Calling the Service e.g. 'eventgate-production-tls-service' is confusing. For eventgate deployments: there will be 4 distinct Services named this in k8s (even though each one is in its own namespace). Is that ok / desired?
- app != wmf.chartname, unless...what is app supposed to mean in this case? Would it be more correct to name this label chart?
- If so, then the chart label would be more correctly named chartid.
- What is heritage?