Skip to content

Commit 4a1c6d4

Browse files
authored
Merge pull request #48 from clwluvw/hostport
feat: add support hostPort
2 parents d8a3e34 + 644dcf9 commit 4a1c6d4

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

charts/coredns/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: coredns
3-
version: 1.19.9
3+
version: 1.19.10
44
appVersion: 1.9.4
55
home: https://coredns.io
66
icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png

charts/coredns/templates/_helpers.tpl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ Generate the list of ports automatically from the server definitions
143143
{{- $innerdict := set $innerdict "istcp" true -}}
144144
{{- end -}}
145145

146+
{{- if .hostPort -}}
147+
{{- $innerdict := set $innerdict "hostPort" .hostPort -}}
148+
{{- end -}}
149+
146150
{{/* Write the dict back into the outer dict */}}
147151
{{- $ports := set $ports $port $innerdict -}}
148152

@@ -159,11 +163,20 @@ Generate the list of ports automatically from the server definitions
159163

160164
{{/* Write out the ports according to the info collected above */}}
161165
{{- range $port, $innerdict := $ports -}}
166+
{{- $portList := list -}}
162167
{{- if index $innerdict "isudp" -}}
163-
{{- printf "- {containerPort: %v, protocol: UDP, name: udp-%s}\n" $port $port -}}
168+
{{- $portList = append $portList (dict "containerPort" ($port | int) "protocol" "UDP" "name" (printf "udp-%s" $port)) -}}
164169
{{- end -}}
165170
{{- if index $innerdict "istcp" -}}
166-
{{- printf "- {containerPort: %v, protocol: TCP, name: tcp-%s}\n" $port $port -}}
171+
{{- $portList = append $portList (dict "containerPort" ($port | int) "protocol" "TCP" "name" (printf "tcp-%s" $port)) -}}
172+
{{- end -}}
173+
174+
{{- range $portDict := $portList -}}
175+
{{- if index $innerdict "hostPort" -}}
176+
{{- $portDict := set $portDict "hostPort" (get $innerdict "hostPort" | int) -}}
177+
{{- end -}}
178+
179+
{{- printf "- %s\n" (toJson $portDict) -}}
167180
{{- end -}}
168181
{{- end -}}
169182
{{- end -}}

charts/coredns/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ servers:
105105
port: 53
106106
# If serviceType is nodePort you can specify nodePort here
107107
# nodePort: 30053
108+
# hostPort: 53
108109
plugins:
109110
- name: errors
110111
# Serves a /health endpoint on :8080, required for livenessProbe

0 commit comments

Comments
 (0)