Skip to content

Commit

Permalink
service: add support nodePort for service ports
Browse files Browse the repository at this point in the history
This will add support to specify nodePort when serviceType is nodePort

Co-authored-by: Yasin Lachini <yasin.lachiny@gmail.com>
Signed-off-by: Seena Fallah <seenafallah@gmail.com>
Signed-off-by: Yasin Lachini <yasin.lachiny@gmail.com>
  • Loading branch information
2 people authored and mrueg committed Dec 16, 2021
1 parent 4f13be4 commit 203e46a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions charts/coredns/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
2 changes: 2 additions & 0 deletions charts/coredns/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 203e46a

Please sign in to comment.