From cecc3a9c43cead984fe51fc8dca1169814271c0e Mon Sep 17 00:00:00 2001 From: Samuel Alfageme Date: Fri, 18 Sep 2020 09:48:08 +0200 Subject: [PATCH] Fetch the pod's HOSTNAME via downward API and pass it as env.var ... when the pod is deployed as part of an StatefulSet, so it can determine its identity on startup and pick the right config file from the '*-configfiles' mount. --- revad/templates/deployment.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/revad/templates/deployment.yaml b/revad/templates/deployment.yaml index 2a0a111..1720abb 100644 --- a/revad/templates/deployment.yaml +++ b/revad/templates/deployment.yaml @@ -35,7 +35,7 @@ spec: args: - "-c" {{- if .Values.useStatefulSet }} - - "/etc/revad/${HOSTNAME}.toml" + - "/etc/revad/$(HOSTNAME).toml" {{- else }} - "/etc/revad/revad.toml" {{- end }} @@ -50,8 +50,14 @@ spec: {{- if .Values.extraVolumeMounts }} {{ toYaml .Values.extraVolumeMounts | nindent 12 }} {{- end }} - {{- if or .Values.env .Values.extraEnv }} + {{- if or .Values.useStatefulSet (or .Values.env .Values.extraEnv) }} env: + {{- if .Values.useStatefulSet }} + - name: HOSTNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + {{- end }} {{- range $name, $value := .Values.env }} - name: "{{ $name }}" value: "{{ $value }}" @@ -63,7 +69,6 @@ spec: {{- if .Values.envFrom }} envFrom: {{ toYaml .Values.envFrom | indent 12 }} - {{- end }} volumes: - name: {{ include "revad.fullname" . }}-configfiles configMap: @@ -84,7 +89,7 @@ spec: accessModes: {{- toYaml .Values.persistentVolume.accessModes | indent 10 }} resources: - requests: + requests: storage: "{{ .Values.persistentVolume.size }}" {{- if (eq "-" .Values.persistentVolume.storageClass) }} storageClassName: ""