Skip to content

Commit

Permalink
Merge pull request #375 from manuelbuil/coreDnsDS
Browse files Browse the repository at this point in the history
Fix clusterdns for dualStack
  • Loading branch information
manuelbuil authored Oct 2, 2023
2 parents 50850e1 + d13d091 commit 90bbbc4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{- end -}}

{{/*
@@ -191,3 +191,44 @@
@@ -191,3 +191,72 @@
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
Expand All @@ -27,9 +27,19 @@
+*/}}
+{{- define "clusterDNSServerIP" -}}
+{{- if .Values.service.clusterIP }}
+{{- .Values.service.clusterIP }}
+ {{- .Values.service.clusterIP }}
+{{ else }}
+{{- coalesce .Values.global.clusterDNS "10.43.0.10" }}
+ {{- $dnsIPs := split "," .Values.global.clusterDNS }}
+ {{- $dnsCount := len $dnsIPs }}
+ {{- if eq $dnsCount 1 }}
+ {{- .Values.global.clusterDNS }}
+ {{- else }}
+ {{- if gt $dnsCount 1 }}
+ {{- $dnsIPs._0 }}
+ {{ else }}
+ {{- "10.43.0.10" }}
+ {{- end }}
+ {{- end }}
+{{- end }}
+{{- end }}
+
Expand All @@ -54,3 +64,21 @@
+{{- printf ",%s" (include "clusterDNSServerIP" .) -}}
+{{- end }}
+{{- end }}
+
+{{/*
+Fill the ipFamily correctly
+*/}}
+{{- define "ipFamilyPolicy" -}}
+{{- if .Values.service.ipFamilyPolicy }}
+ {{- .Values.service.ipFamilyPolicy }}
+{{ else }}
+ {{- $dnsIPs := split "," .Values.global.clusterDNS }}
+ {{- $dnsCount := len $dnsIPs }}
+ {{- if gt $dnsCount 1 }}
+ {{- "PreferDualStack" }}
+ {{ else }}
+ {{- "SingleStack" }}
+ {{- end }}
+{{- end }}
+{{- end }}
+
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
--- charts-original/templates/service.yaml
+++ charts/templates/service.yaml
@@ -33,13 +33,7 @@
@@ -1,4 +1,6 @@
{{- if .Values.deployment.enabled }}
+{{- $dnsIPs := split "," .Values.global.clusterDNS }}
+{{- $dnsCount := len $dnsIPs }}
---
apiVersion: v1
kind: Service
@@ -33,12 +35,12 @@
k8s-app: {{ template "coredns.k8sapplabel" . }}
{{- end }}
app.kubernetes.io/name: {{ template "coredns.name" . }}
- {{- if .Values.service.clusterIP }}
- clusterIP: {{ .Values.service.clusterIP }}
- {{- end }}
- {{- if .Values.service.clusterIPs }}
- clusterIPs:
- {{ toYaml .Values.service.clusterIPs | nindent 4 }}
- {{- end }}
+ clusterIP: {{ template "clusterDNSServerIP" . }}
+ {{- if gt $dnsCount 1 }}
clusterIPs:
- {{ toYaml .Values.service.clusterIPs | nindent 4 }}
+ {{- range $dnsIP := $dnsIPs }}
+ - {{ $dnsIP }}
+ {{- end }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{- toYaml .Values.service.externalIPs | nindent 4 }}
@@ -53,7 +55,5 @@
ports:
{{ include "coredns.servicePorts" . | indent 2 -}}
type: {{ default "ClusterIP" .Values.serviceType }}
- {{- if .Values.service.ipFamilyPolicy }}
- ipFamilyPolicy: {{ .Values.service.ipFamilyPolicy }}
- {{- end }}
+ ipFamilyPolicy: {{ template "ipFamilyPolicy" . }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# externalIPs: []
# externalTrafficPolicy: ""
-# ipFamilyPolicy: ""
+ ipFamilyPolicy: "PreferDualStack"
+ ipFamilyPolicy: ""
# The name of the Service
# If not set, a name is generated using the fullname template
name: ""
Expand Down
2 changes: 1 addition & 1 deletion packages/rke2-coredns/package.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
url: https://github.com/coredns/helm/releases/download/coredns-1.24.0/coredns-1.24.0.tgz
packageVersion: 05
packageVersion: 06
# This repository does not use releaseCandidateVersions, so you can leave this as 00.
releaseCandidateVersion: 00

0 comments on commit 90bbbc4

Please sign in to comment.