mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-05 11:26:22 -03:00
add host aliases
This commit is contained in:
@@ -248,3 +248,78 @@ tests:
|
||||
- name: ndots
|
||||
value: "2"
|
||||
- name: edns0
|
||||
|
||||
- it: should fail without ip in hostAliases
|
||||
set:
|
||||
hostAliases:
|
||||
- hostnames:
|
||||
- hostname1
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
documentIndex: *deploymentDoc
|
||||
errorMessage: <ip> field is required in hostAliases
|
||||
|
||||
- it: should fail without hostnames in hostAliases
|
||||
set:
|
||||
hostAliases:
|
||||
- ip: 1.1.1.1
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
documentIndex: *deploymentDoc
|
||||
errorMessage: At least one <hostnames> is required in hostAliases
|
||||
|
||||
- it: should pass with hostAliases defined
|
||||
set:
|
||||
hostAliases:
|
||||
- ip: 1.1.1.1
|
||||
hostnames:
|
||||
- hostname1
|
||||
- hostname2
|
||||
- ip: 8.8.8.8
|
||||
hostnames:
|
||||
- hostname3
|
||||
- hostname4
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.hostAliases
|
||||
value:
|
||||
- ip: 1.1.1.1
|
||||
hostnames:
|
||||
- hostname1
|
||||
- hostname2
|
||||
- ip: 8.8.8.8
|
||||
hostnames:
|
||||
- hostname3
|
||||
- hostname4
|
||||
|
||||
- it: should pass with hostAliases defined from tpl
|
||||
set:
|
||||
ip1: 1.1.1.1
|
||||
ip2: 8.8.8.8
|
||||
host1: hostname1
|
||||
host2: hostname2
|
||||
host3: hostname3
|
||||
host4: hostname4
|
||||
hostAliases:
|
||||
- ip: "{{ .Values.ip1 }}"
|
||||
hostnames:
|
||||
- "{{ .Values.host1 }}"
|
||||
- "{{ .Values.host2 }}"
|
||||
- ip: "{{ .Values.ip2 }}"
|
||||
hostnames:
|
||||
- "{{ .Values.host3 }}"
|
||||
- "{{ .Values.host4 }}"
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.hostAliases
|
||||
value:
|
||||
- ip: 1.1.1.1
|
||||
hostnames:
|
||||
- hostname1
|
||||
- hostname2
|
||||
- ip: 8.8.8.8
|
||||
hostnames:
|
||||
- hostname3
|
||||
- hostname4
|
||||
|
||||
14
library/common/1.0.0/templates/lib/chart/_hostAliases.tpl
Normal file
14
library/common/1.0.0/templates/lib/chart/_hostAliases.tpl
Normal file
@@ -0,0 +1,14 @@
|
||||
{{/* Returns host aliases */}}
|
||||
{{- define "ix.v1.common.hostAliases" -}}
|
||||
{{- range .Values.hostAliases }}
|
||||
- ip: {{ (tpl (required "<ip> field is required in hostAliases" .ip) $ | quote) }}
|
||||
{{- if .hostnames }}
|
||||
hostnames:
|
||||
{{- range .hostnames }}
|
||||
- {{ tpl . $ }}
|
||||
{{- end}}
|
||||
{{- else -}}
|
||||
{{- fail "At least one <hostnames> is required in hostAliases" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -17,6 +17,10 @@ dnsPolicy: {{ . }}
|
||||
dnsConfig:
|
||||
{{- . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with (include "ix.v1.common.hostAliases" . | trim) }}
|
||||
hostAliases:
|
||||
{{- . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with .Values.termination.gracePeriodSeconds }}
|
||||
terminationGracePeriodSeconds: {{ . }}
|
||||
{{- end }}
|
||||
@@ -30,5 +34,5 @@ containers:
|
||||
{{- with (include "ix.v1.common.controller.volumes" . | trim) }}
|
||||
volumes:
|
||||
{{- . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -53,6 +53,8 @@ dnsPolicy: ""
|
||||
|
||||
dnsConfig: {}
|
||||
|
||||
hostAliases: []
|
||||
|
||||
# TODO: docs
|
||||
podSecurityContext:
|
||||
runAsUser: 568
|
||||
|
||||
Reference in New Issue
Block a user