Skip to content

Commit c93148a

Browse files
abaguasaba_osag
authored and
aba_osag
committed
Support different service and container ports
Signed-off-by: Andre Baptista Aguas <[email protected]>
1 parent c04e952 commit c93148a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

charts/coredns/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: coredns
3-
version: 1.33.0
3+
version: 1.34.0
44
appVersion: 1.11.3
55
home: https://coredns.io
66
icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png
@@ -20,4 +20,4 @@ type: application
2020
annotations:
2121
artifacthub.io/changes: |
2222
- kind: added
23-
description: Add support for specifying the service loadBalancerClass.
23+
description: Support different service and container ports

charts/coredns/templates/_helpers.tpl

+5-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ Generate the list of ports automatically from the server definitions
7070
{{- range .Values.servers -}}
7171
{{/* Capture port to avoid scoping awkwardness */}}
7272
{{- $port := toString .port -}}
73+
{{- $serviceport := default .port .servicePort -}}
7374

7475
{{/* If none of the server blocks has mentioned this port yet take note of it */}}
7576
{{- if not (hasKey $ports $port) -}}
76-
{{- $ports := set $ports $port (dict "istcp" false "isudp" false) -}}
77+
{{- $ports := set $ports $port (dict "istcp" false "isudp" false "serviceport" $serviceport) -}}
7778
{{- end -}}
7879
{{/* Retrieve the inner dict that holds the protocols for a given port */}}
7980
{{- $innerdict := index $ports $port -}}
@@ -116,10 +117,10 @@ Generate the list of ports automatically from the server definitions
116117
{{- range $port, $innerdict := $ports -}}
117118
{{- $portList := list -}}
118119
{{- if index $innerdict "isudp" -}}
119-
{{- $portList = append $portList (dict "port" ($port | int) "protocol" "UDP" "name" (printf "udp-%s" $port)) -}}
120+
{{- $portList = append $portList (dict "port" (get $innerdict "serviceport") "protocol" "UDP" "name" (printf "udp-%s" $port) "targetPort" ($port | int)) -}}
120121
{{- end -}}
121122
{{- if index $innerdict "istcp" -}}
122-
{{- $portList = append $portList (dict "port" ($port | int) "protocol" "TCP" "name" (printf "tcp-%s" $port)) -}}
123+
{{- $portList = append $portList (dict "port" (get $innerdict "serviceport") "protocol" "TCP" "name" (printf "tcp-%s" $port) "targetPort" ($port | int)) -}}
123124
{{- end -}}
124125

125126
{{- range $portDict := $portList -}}
@@ -234,4 +235,4 @@ Create the name of the service account to use
234235
{{- else -}}
235236
{{ template "coredns.fullname" . }}
236237
{{- end -}}
237-
{{- end -}}
238+
{{- end -}}

charts/coredns/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ servers:
103103
- zones:
104104
- zone: .
105105
port: 53
106+
# -- expose the service on a different port
107+
# servicePort: 5353
106108
# If serviceType is nodePort you can specify nodePort here
107109
# nodePort: 30053
108110
# hostPort: 53

0 commit comments

Comments
 (0)