Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions chart/templates/webserver/webserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ spec:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
{{- if .Values.webserver.hostAliases }}
hostAliases:
{{ toYaml .Values.webserver.hostAliases | indent 8 }}
{{- end }}
restartPolicy: Always
securityContext: {{ $securityContext | nindent 8 }}
{{- if or .Values.registry.secretName .Values.registry.connection }}
Expand Down
22 changes: 22 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,28 @@
"$ref": "#/definitions/io.k8s.api.core.v1.TopologySpreadConstraint"
}
},
"hostAliases": {
"description": "Specify HostAliases for webserver.",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.HostAlias"
},
"type": "array",
"default": [],
"examples": [
{
"ip": "127.0.0.2",
"hostnames": [
"test.hostname.one"
]
},
{
"ip": "127.0.0.3",
"hostnames": [
"test.hostname.two"
]
}
]
},
"podAnnotations": {
"description": "Annotations to add to the webserver pods.",
"type": "object",
Expand Down
10 changes: 10 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,16 @@ webserver:
# weight: 100
tolerations: []
topologySpreadConstraints: []
# hostAliases to use in webserver pod.
# See:
# https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/
hostAliases: []
# - ip: "127.0.0.2"
# hostnames:
# - "test.hostname.one"
# - ip: "127.0.0.3"
# hostnames:
# - "test.hostname.two"

podAnnotations: {}

Expand Down
13 changes: 13 additions & 0 deletions tests/charts/test_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ def test_should_add_extra_init_containers(self):
"image": "test-registry/test-repo:test-tag",
} == jmespath.search("spec.template.spec.initContainers[-1]", docs[0])

def test_webserver_host_aliases(self):
docs = render_chart(
values={
"webserver": {
"hostAliases": [{"ip": "127.0.0.2", "hostnames": ["test.hostname"]}],
},
},
show_only=["templates/webserver/webserver-deployment.yaml"],
)

assert "127.0.0.2" == jmespath.search("spec.template.spec.hostAliases[0].ip", docs[0])
assert "test.hostname" == jmespath.search("spec.template.spec.hostAliases[0].hostnames[0]", docs[0])

def test_should_create_valid_affinity_tolerations_and_node_selector(self):
docs = render_chart(
values={
Expand Down