diff --git a/charts/coredns/templates/_helpers.tpl b/charts/coredns/templates/_helpers.tpl index 1554dde..ade1523 100644 --- a/charts/coredns/templates/_helpers.tpl +++ b/charts/coredns/templates/_helpers.tpl @@ -63,17 +63,30 @@ Generate the list of ports automatically from the server definitions {{- $innerdict := set $innerdict "istcp" true -}} {{- end -}} + {{- if .nodePort -}} + {{- $innerdict := set $innerdict "nodePort" .nodePort -}} + {{- end -}} + {{/* Write the dict back into the outer dict */}} {{- $ports := set $ports $port $innerdict -}} {{- end -}} {{/* Write out the ports according to the info collected above */}} {{- range $port, $innerdict := $ports -}} + {{- $portList := list -}} {{- if index $innerdict "isudp" -}} - {{- printf "- {port: %v, protocol: UDP, name: udp-%s}\n" $port $port -}} + {{- $portList = append $portList (dict "port" ($port | int) "protocol" "UDP" "name" (printf "udp-%s" $port)) -}} {{- end -}} {{- if index $innerdict "istcp" -}} - {{- printf "- {port: %v, protocol: TCP, name: tcp-%s}\n" $port $port -}} + {{- $portList = append $portList (dict "port" ($port | int) "protocol" "TCP" "name" (printf "tcp-%s" $port)) -}} + {{- end -}} + + {{- range $portDict := $portList -}} + {{- if index $innerdict "nodePort" -}} + {{- $portDict := set $portDict "nodePort" (get $innerdict "nodePort" | int) -}} + {{- end -}} + + {{- printf "- %s\n" (toJson $portDict) -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/coredns/values.yaml b/charts/coredns/values.yaml index 3d321e5..5fe990b 100644 --- a/charts/coredns/values.yaml +++ b/charts/coredns/values.yaml @@ -102,6 +102,8 @@ servers: - zones: - zone: . port: 53 + # If serviceType is nodePort you can specify nodePort here + # nodePort: 30053 plugins: - name: errors # Serves a /health endpoint on :8080, required for livenessProbe