Skip to content

Commit

Permalink
Merge pull request #48 from clwluvw/hostport
Browse files Browse the repository at this point in the history
feat: add support hostPort
  • Loading branch information
hagaibarel authored Mar 23, 2023
2 parents d8a3e34 + 644dcf9 commit 4a1c6d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/coredns/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 15 additions & 2 deletions charts/coredns/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

Expand All @@ -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 -}}
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a1c6d4

Please sign in to comment.