Skip to content

Commit

Permalink
[Monochart] Feature: deployment.yaml volume mounts (#273)
Browse files Browse the repository at this point in the history
* update chart to allow volumes

* update chart for more conditionals, fixes Volumes, Volume Mounts, Pull Secrets, ENV
  • Loading branch information
Benbentwo authored Aug 21, 2023
1 parent 5bf2ddd commit 61ffa1b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
5 changes: 5 additions & 0 deletions incubator/monochart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ env:
value: {{ default "" $value | quote }}
{{- end }}
{{- end }}

{{/*
https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-pod-fields-as-values-for-environment-variables
*/}}
{{- with $root.Values.envFromFieldRefFieldPath }}

{{/* Only add env block if not used by above .Values.env */}}
{{- if not $root.Values.env}}
env:
{{- end }}
{{- range $name, $value := . }}
- name: {{ $name }}
valueFrom:
Expand Down
27 changes: 20 additions & 7 deletions incubator/monochart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,33 +96,44 @@ spec:
protocol: {{ default "TCP" $port.protocol }}
{{- end }}
{{- end }}
{{- if or .Values.deployment.pod.volumeMounts .Values.persistence.enabled .Values.configMaps.enabled .Values.secrets.enabled }}
volumeMounts:
{{- if .Values.deployment.pod.volumeMounts }}
{{- toYaml .Values.deployment.pod.volumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.persistence.enabled }}
- mountPath: {{ .Values.persistence.mountPath | quote }}
name: storage
{{- end }}
{{- include "monochart.files.volumeMounts" . | nindent 8 }}
{{- end }}
{{- with .Values.probes }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{ toYaml . | indent 10 }}
{{- end }}
{{- with .Values.deployment.pod.hostAliases }}
{{- with .Values.deployment.pod.hostAliases }}
hostAliases:
{{ toYaml . | indent 8 }}
{{- end }}
{{- toYaml . | indent 8 }}
{{- end }}
{{- if or .Values.dockercfg.enabled .Values.image.pullSecrets }}
imagePullSecrets:
{{- if .Values.dockercfg.enabled }}
{{- end }}
{{- if .Values.dockercfg.enabled }}
- name: {{ include "common.fullname" . }}
{{- end }}
{{- with .Values.image.pullSecrets }}
{{- end }}
{{- with .Values.image.pullSecrets }}
{{- range . }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- if or .Values.deployment.volumes .Values.persistence.enabled .Values.configMaps.enabled .Values.secrets.enabled }}
volumes:
{{- if .Values.deployment.volumes }}
{{- toYaml .Values.deployment.volumes | nindent 6 }}
{{- end }}
{{- if .Values.persistence.enabled }}
- name: storage
{{- if .Values.persistence.enabled }}
Expand All @@ -133,4 +144,6 @@ spec:
{{- end }}
{{- end }}
{{- include "monochart.files.volumes" . | nindent 6 }}
{{- end }}

{{- end -}}
10 changes: 10 additions & 0 deletions incubator/monochart/test/full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ deployment:
## https:/jtblin/kube2iam
# iam.amazonaws.com/role: role-arn
labels: {}

## Directly attach Volume
volumeMounts:
- name: apmsocketpath
mountPath: /var/run/datadog
volumes:
- hostPath:
path: /var/run/datadog/
name: apmsocketpath

affinity:
# use of simple rule
affinityRule: "ShouldBeOnDifferentNode"
Expand Down
9 changes: 9 additions & 0 deletions incubator/monochart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ deployment:
labels: {}
# command:
args: []

volumeMounts: []
# - name: apmsocketpath
# mountPath: /var/run/datadog

volumes: []
# - name: apmsocketpath
# hostPath:
# path: /var/run/datadog/

statefulset:
enabled: false
Expand Down

0 comments on commit 61ffa1b

Please sign in to comment.