From 644dcf94a3ab134720b7e8713aaf9b17d1a831fa Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Sat, 18 Dec 2021 02:03:57 +0330 Subject: [PATCH] feat: add support hostPort Signed-off-by: Seena Fallah --- charts/coredns/Chart.yaml | 2 +- charts/coredns/templates/_helpers.tpl | 17 +++++++++++++++-- charts/coredns/values.yaml | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/charts/coredns/Chart.yaml b/charts/coredns/Chart.yaml index fe6e7f8..84cd52c 100644 --- a/charts/coredns/Chart.yaml +++ b/charts/coredns/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: coredns -version: 1.19.9 +version: 1.19.10 appVersion: 1.9.4 home: https://coredns.io icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png diff --git a/charts/coredns/templates/_helpers.tpl b/charts/coredns/templates/_helpers.tpl index f04044c..61732b3 100644 --- a/charts/coredns/templates/_helpers.tpl +++ b/charts/coredns/templates/_helpers.tpl @@ -143,6 +143,10 @@ Generate the list of ports automatically from the server definitions {{- $innerdict := set $innerdict "istcp" true -}} {{- end -}} + {{- if .hostPort -}} + {{- $innerdict := set $innerdict "hostPort" .hostPort -}} + {{- end -}} + {{/* Write the dict back into the outer dict */}} {{- $ports := set $ports $port $innerdict -}} @@ -159,11 +163,20 @@ Generate the list of ports automatically from the server definitions {{/* Write out the ports according to the info collected above */}} {{- range $port, $innerdict := $ports -}} + {{- $portList := list -}} {{- if index $innerdict "isudp" -}} - {{- printf "- {containerPort: %v, protocol: UDP, name: udp-%s}\n" $port $port -}} + {{- $portList = append $portList (dict "containerPort" ($port | int) "protocol" "UDP" "name" (printf "udp-%s" $port)) -}} {{- end -}} {{- if index $innerdict "istcp" -}} - {{- printf "- {containerPort: %v, protocol: TCP, name: tcp-%s}\n" $port $port -}} + {{- $portList = append $portList (dict "containerPort" ($port | int) "protocol" "TCP" "name" (printf "tcp-%s" $port)) -}} + {{- end -}} + + {{- range $portDict := $portList -}} + {{- if index $innerdict "hostPort" -}} + {{- $portDict := set $portDict "hostPort" (get $innerdict "hostPort" | int) -}} + {{- end -}} + + {{- printf "- %s\n" (toJson $portDict) -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/coredns/values.yaml b/charts/coredns/values.yaml index 7767426..4e6d6c2 100644 --- a/charts/coredns/values.yaml +++ b/charts/coredns/values.yaml @@ -105,6 +105,7 @@ servers: port: 53 # If serviceType is nodePort you can specify nodePort here # nodePort: 30053 + # hostPort: 53 plugins: - name: errors # Serves a /health endpoint on :8080, required for livenessProbe