Skip to content

Commit cf3d141

Browse files
committed
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.
1 parent 8807458 commit cf3d141

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

revad/templates/deployment.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
args:
3636
- "-c"
3737
{{- if .Values.useStatefulSet }}
38-
- "/etc/revad/${HOSTNAME}.toml"
38+
- "/etc/revad/$(HOSTNAME).toml"
3939
{{- else }}
4040
- "/etc/revad/revad.toml"
4141
{{- end }}
@@ -50,8 +50,14 @@ spec:
5050
{{- if .Values.extraVolumeMounts }}
5151
{{ toYaml .Values.extraVolumeMounts | nindent 12 }}
5252
{{- end }}
53-
{{- if or .Values.env .Values.extraEnv }}
53+
{{- if or .Values.useStatefulSet (or .Values.env .Values.extraEnv) }}
5454
env:
55+
{{- if .Values.useStatefulSet }}
56+
- name: HOSTNAME
57+
valueFrom:
58+
fieldRef:
59+
fieldPath: metadata.name
60+
{{- end }}
5561
{{- range $name, $value := .Values.env }}
5662
- name: "{{ $name }}"
5763
value: "{{ $value }}"
@@ -63,7 +69,6 @@ spec:
6369
{{- if .Values.envFrom }}
6470
envFrom:
6571
{{ toYaml .Values.envFrom | indent 12 }}
66-
{{- end }}
6772
volumes:
6873
- name: {{ include "revad.fullname" . }}-configfiles
6974
configMap:
@@ -84,7 +89,7 @@ spec:
8489
accessModes:
8590
{{- toYaml .Values.persistentVolume.accessModes | indent 10 }}
8691
resources:
87-
requests:
92+
requests:
8893
storage: "{{ .Values.persistentVolume.size }}"
8994
{{- if (eq "-" .Values.persistentVolume.storageClass) }}
9095
storageClassName: ""

0 commit comments

Comments
 (0)