The key to using Helm charts rather than simply authoring Kubernetes YAML definitions is the use of templates. This way a deployment pattern can be defined once, with only the deploy time, application specific, values being changed.
From the Helm template the health probes are hard coded, replace these with shared definitions, .Values.service.port
& .Values.service.probeContext
.
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: {{ .Values.service.probeContext }}
port: {{ .Values.service.port }}
readinessProbe:
httpGet:
path: {{ .Values.service.probeContext }}
port: {{ .Values.service.port }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
The .Values.service.port
is already defined in the generated values file, but .Values.service.probeContext
is not, so add this to the values definition.
service:
type: ClusterIP
port: 8000
probeContext: /
Now replace single values file with a file for each application being deployed based on this pattern. Create additional app definitions in Helmsman
apps:
kestrel:
name: "kestrel"
description: "dotnet core Kestrel API"
namespace: "name_space"
enabled: true
chart: "public-ingress-0.1.3.tgz"
version: "0.1.3"
valuesFile: "dockerhub-public/kestrel.yaml"
fastapi:
name: "fastapi"
description: "Python Fast API"
namespace: "name_space"
enabled: true
chart: "public-ingress-0.1.1.tgz"
version: "0.1.1"
valuesFile: "dockerhub-public/fastapi.yaml"