Skip to content

Commit

Permalink
Fetch the pod's HOSTNAME via downward API and pass it as env.var
Browse files Browse the repository at this point in the history
... 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.
  • Loading branch information
SamuAlfageme committed May 11, 2021
1 parent 52cedcf commit cecc3a9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions revad/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
args:
- "-c"
{{- if .Values.useStatefulSet }}
- "/etc/revad/${HOSTNAME}.toml"
- "/etc/revad/$(HOSTNAME).toml"
{{- else }}
- "/etc/revad/revad.toml"
{{- end }}
Expand All @@ -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 }}"
Expand All @@ -63,7 +69,6 @@ spec:
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 12 }}
{{- end }}
volumes:
- name: {{ include "revad.fullname" . }}-configfiles
configMap:
Expand All @@ -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: ""
Expand Down

0 comments on commit cecc3a9

Please sign in to comment.