Skip to content

Commit

Permalink
feat: add hostAliases for statefulset (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
eufebius authored Sep 18, 2023
1 parent c3b2b14 commit 3387881
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ spec:
{{ template "vault.volumes" . }}
- name: home
emptyDir: {}
{{- if .Values.server.hostAliases }}
hostAliases:
{{ toYaml .Values.server.hostAliases | nindent 8}}
{{- end }}
{{- if .Values.server.extraInitContainers }}
initContainers:
{{ toYaml .Values.server.extraInitContainers | nindent 8}}
Expand Down
22 changes: 22 additions & 0 deletions test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,28 @@ load _helpers
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# hostAliases

@test "server/StatefulSet: server.hostAliases not set" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.spec.hostAliases' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "server/StatefulSet: server.hostAliases is set" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.hostAliases[0]=foo' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.hostAliases[]' | tee /dev/stderr)
[ "${actual}" = "foo" ]
}

#--------------------------------------------------------------------
# extraPorts

Expand Down
3 changes: 3 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,9 @@
}
}
},
"hostAliases": {
"type": "array"
},
"image": {
"type": "object",
"properties": {
Expand Down
6 changes: 5 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,11 @@ server:
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

# hostAliases is a list of aliases to be added to /etc/hosts. Specified as a YAML list.
hostAliases: []
# - ip: 127.0.0.1
# hostnames:
# - chart-example.local
# OpenShift only - create a route to expose the service
# By default the created route will be of type passthrough
route:
Expand Down

0 comments on commit 3387881

Please sign in to comment.