98 lines
2.8 KiB
Smarty
98 lines
2.8 KiB
Smarty
{{/*
|
|
This is a builder for deployments
|
|
*/}}
|
|
{{- define "deployment.spec" }}
|
|
spec:
|
|
replicas: {{ .Values.workload.replicas }}
|
|
selector:
|
|
matchLabels:
|
|
{{ include "metadata.selectorLabels" . | indent 6 }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
{{ include "metadata.labels" . | indent 8 }}
|
|
spec:
|
|
{{/* Prepare the securityContext for the pod */}}
|
|
{{- include "lib.securityContext" . | indent 6 -}}
|
|
{{/* Add all the volues to pod */}}
|
|
{{- if or ( or .Values.storage .Values.extraVolumes) .Values.files }}
|
|
volumes:
|
|
{{- if .Values.storage }}
|
|
{{- range $k, $v := .Values.storage }}
|
|
- name: {{ $k }}-storage
|
|
persistentVolumeClaim:
|
|
claimName: " {{- printf "%s-%s" (include "chart.fullname" $) $k }}"
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if .Values.files }}-file
|
|
{{- range $k, $v := .Values.files }}
|
|
- name: {{ $k }}
|
|
{{- if $v.sensitive }}
|
|
secret:
|
|
defaultMode: 420
|
|
secretName: " {{- printf "%s-%s" (include "chart.fullname" $) $k }}"
|
|
{{- else }}
|
|
configMap:
|
|
name: "{{- printf "%s-%s" (include "chart.fullname" $) $k }}"
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end -}}
|
|
{{/* Define containers */}}
|
|
containers:
|
|
{{- range $k,$v := .Values.workload.containers }}
|
|
- name: {{ $k }}
|
|
{{/* Prepare the securityContext for the container */}}
|
|
{{- include "lib.containerSecurityContext" . | indent 8 -}}
|
|
{{/* Image fron chart's annotations */}}
|
|
image: {{ index $.Chart.Annotations "helm.badhouseplants.net/registry" }}:{{ $.Chart.AppVersion }}
|
|
{{- with $v.command }}
|
|
command:
|
|
{{. | toYaml | indent 10 }}
|
|
{{- end -}}
|
|
{{- with $v.args }}
|
|
args:
|
|
{{. | toYaml | indent 10 }}
|
|
{{- end -}}
|
|
{{- if $v.mounts }}
|
|
mounts:
|
|
{{- range $k ,$v := range $v.mounts }}
|
|
{{- if $k == "storage" }}
|
|
name: {{ $k }}-storage
|
|
{{- end }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
{{/* Ports */}}
|
|
{{- with $v.ports }}
|
|
ports:
|
|
{{- range $p := $v.ports}}
|
|
- containerPort: {{ index (index $.Values.service.ports $p) "targetPort" }}
|
|
{{/* If env should be set from a Configmap/Secret */}}
|
|
{{- if $v.envFrom }}
|
|
envFrom:
|
|
{{- range $k := $v.envFrom }}
|
|
{{/* If envFrom entry is a string, then refer to the env created by the library */}}
|
|
{{- if kindIs "string" $k }}
|
|
{{- if (index $.Values.env $k) }}
|
|
{{- if (index $.Values.env $k).sensitive }}
|
|
- secretRef:
|
|
{{- else }}
|
|
- configMapRef:
|
|
{{- end }}
|
|
name: {{ printf "%s-%s" (include "chart.fullname" $) $k }}
|
|
{{- end }}
|
|
{{/* Otherwise try to add references directly (if Secrets/ConfigMaps are not managed by the chart) */}}
|
|
{{- else }}
|
|
{{- range $k, $v := $k }}
|
|
- {{ $k }}:
|
|
{{ toYaml $v | indent 14 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|