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 8807458 commit 0c32279
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 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 @@ -62,7 +68,7 @@ spec:
{{- end }}
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 12 }}
{{- toYaml .Values.envFrom | nindent 12 }}
{{- end }}
volumes:
- name: {{ include "revad.fullname" . }}-configfiles
Expand All @@ -78,13 +84,13 @@ spec:
name: {{ include "revad.fullname" . }}-datadir
{{- if .Values.persistentVolume.annotations }}
annotations:
{{- toYaml .Values.persistentVolume.annotations | indent 10 }}
{{- toYaml .Values.persistentVolume.annotations | nindent 10 }}
{{- end }}
spec:
accessModes:
{{- toYaml .Values.persistentVolume.accessModes | indent 10 }}
{{- toYaml .Values.persistentVolume.accessModes | nindent 10 }}
resources:
requests:
requests:
storage: "{{ .Values.persistentVolume.size }}"
{{- if (eq "-" .Values.persistentVolume.storageClass) }}
storageClassName: ""
Expand Down

0 comments on commit 0c32279

Please sign in to comment.