Skip to content

Commit

Permalink
Feature: Add support for dualstack loadbalancers
Browse files Browse the repository at this point in the history
Add config value `dualStack.loadBalancer` to toggle dualstack support
for loadbalancers (LB need to support this feature).
  • Loading branch information
AlexanderLieret committed Dec 25, 2021
1 parent 4948313 commit 12a545d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 9 deletions.
12 changes: 10 additions & 2 deletions charts/pihole/templates/service-dhcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ metadata:
{{- end }}
spec:
type: {{ .Values.serviceDhcp.type }}
{{- if and (.Values.dualStack.enabled) (not (eq .Values.serviceDhcp.type "LoadBalancer")) }}
{{- if and (.Values.dualStack.enabled) (or (not (eq .Values.serviceDhcp.type "LoadBalancer")) (.Values.dualStack.loadBalancer)) }}
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: PreferDualStack
{{- if and (.Values.serviceDhcp.loadBalancerIP) (.Values.serviceDhcp.loadBalancerIPv6) }}
loadBalancerIP: {{ .Values.serviceDhcp.loadBalancerIP }},{{ .Values.serviceDhcp.loadBalancerIPv6 }}
{{- else if .Values.serviceDhcp.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDhcp.loadBalancerIP }}
{{- else if .Values.serviceDhcp.loadBalancerIPv6 }}
loadBalancerIP: {{ .Values.serviceDhcp.loadBalancerIPv6 }}
{{- end }}
{{- else }}
{{- if .Values.serviceDhcp.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDhcp.loadBalancerIP }}
{{- end }}
{{- end }}
{{- if or (eq .Values.serviceDhcp.type "NodePort") (eq .Values.serviceDhcp.type "LoadBalancer") }}
externalTrafficPolicy: {{ .Values.serviceDhcp.externalTrafficPolicy }}
{{- end }}
Expand All @@ -35,7 +43,7 @@ spec:
app: {{ template "pihole.name" . }}
release: {{ .Release.Name }}
---
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDhcp.type "LoadBalancer") -}}
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDhcp.type "LoadBalancer") (not .Values.dualStack.loadBalancer) -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
12 changes: 10 additions & 2 deletions charts/pihole/templates/service-dns-tcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ metadata:
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
{{- if and (.Values.dualStack.enabled) (not (eq .Values.serviceDns.type "LoadBalancer")) }}
{{- if and (.Values.dualStack.enabled) (or (not (eq .Values.serviceDns.type "LoadBalancer")) (.Values.dualStack.loadBalancer)) }}
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: PreferDualStack
{{- if and (.Values.serviceDns.loadBalancerIP) (.Values.serviceDns.loadBalancerIPv6) }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }},{{ .Values.serviceDns.loadBalancerIPv6 }}
{{- else if .Values.serviceDns.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }}
{{- else if .Values.serviceDns.loadBalancerIPv6 }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIPv6 }}
{{- end }}
{{- else }}
{{- if .Values.serviceDns.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }}
{{- end }}
{{- end }}
{{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }}
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
Expand All @@ -44,7 +52,7 @@ spec:
app: {{ template "pihole.name" . }}
release: {{ .Release.Name }}
---
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDns.type "LoadBalancer") -}}
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDns.type "LoadBalancer") (not .Values.dualStack.loadBalancer) -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
12 changes: 10 additions & 2 deletions charts/pihole/templates/service-dns-udp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ metadata:
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
{{- if and (.Values.dualStack.enabled) (not (eq .Values.serviceDns.type "LoadBalancer")) }}
{{- if and (.Values.dualStack.enabled) (or (not (eq .Values.serviceDns.type "LoadBalancer")) (.Values.dualStack.loadBalancer)) }}
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: PreferDualStack
{{- if and (.Values.serviceDns.loadBalancerIP) (.Values.serviceDns.loadBalancerIPv6) }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }},{{ .Values.serviceDns.loadBalancerIPv6 }}
{{- else if .Values.serviceDns.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }}
{{- else if .Values.serviceDns.loadBalancerIPv6 }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIPv6 }}
{{- end }}
{{- else }}
{{- if .Values.serviceDns.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }}
{{- end }}
{{- end }}
{{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }}
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
Expand All @@ -38,7 +46,7 @@ spec:
app: {{ template "pihole.name" . }}
release: {{ .Release.Name }}
---
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDns.type "LoadBalancer") -}}
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDns.type "LoadBalancer") (not .Values.dualStack.loadBalancer) -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
16 changes: 15 additions & 1 deletion charts/pihole/templates/service-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,23 @@ metadata:
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
{{- if and (.Values.dualStack.enabled) (.Values.dualStack.loadBalancer) }}
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: PreferDualStack
{{- if and (.Values.serviceDns.loadBalancerIP) (.Values.serviceDns.loadBalancerIPv6) }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }},{{ .Values.serviceDns.loadBalancerIPv6 }}
{{- else if .Values.serviceDns.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }}
{{- else if .Values.serviceDns.loadBalancerIPv6 }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIPv6 }}
{{- end }}
{{- else }}
{{- if .Values.serviceDns.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }}
{{- end }}
{{- end }}
{{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }}
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
Expand Down Expand Up @@ -45,7 +59,7 @@ spec:
app: {{ template "pihole.name" . }}
release: {{ .Release.Name }}
---
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDns.type "LoadBalancer") -}}
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceDns.type "LoadBalancer") (not .Values.dualStack.loadBalancer) -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
12 changes: 10 additions & 2 deletions charts/pihole/templates/service-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@ metadata:
{{- end }}
spec:
type: {{ .Values.serviceWeb.type }}
{{- if and (.Values.dualStack.enabled) (not (eq .Values.serviceWeb.type "LoadBalancer")) }}
{{- if and (.Values.dualStack.enabled) (or (not (eq .Values.serviceWeb.type "LoadBalancer")) (.Values.dualStack.loadBalancer)) }}
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: PreferDualStack
{{- if and (.Values.serviceWeb.loadBalancerIP) (.Values.serviceWeb.loadBalancerIPv6) }}
loadBalancerIP: {{ .Values.serviceWeb.loadBalancerIP }},{{ .Values.serviceWeb.loadBalancerIPv6 }}
{{- else if .Values.serviceWeb.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceWeb.loadBalancerIP }}
{{- else if .Values.serviceWeb.loadBalancerIPv6 }}
loadBalancerIP: {{ .Values.serviceWeb.loadBalancerIPv6 }}
{{- end }}
{{- else }}
{{- if .Values.serviceWeb.loadBalancerIP }}
loadBalancerIP: {{ .Values.serviceWeb.loadBalancerIP }}
{{- end }}
{{- end }}
{{- if or (eq .Values.serviceWeb.type "NodePort") (eq .Values.serviceWeb.type "LoadBalancer") }}
externalTrafficPolicy: {{ .Values.serviceWeb.externalTrafficPolicy }}
{{- end }}
Expand All @@ -47,7 +55,7 @@ spec:
app: {{ template "pihole.name" . }}
release: {{ .Release.Name }}
---
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceWeb.type "LoadBalancer") -}}
{{- if and (.Values.dualStack.enabled) (eq .Values.serviceWeb.type "LoadBalancer") (not .Values.dualStack.loadBalancer) -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
2 changes: 2 additions & 0 deletions charts/pihole/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ image:
dualStack:
# -- set this to true to enable creation of DualStack services or creation of separate IPv6 services if `serviceDns.type` is set to `"LoadBalancer"`
enabled: false
# -- set this to true to create a single loadbalancer service. Some loadbalancer implementations do not work well with separate services for IPv4 and IPv6, i.e. klipper-lb (k3s)
loadBalancer: false

dnsHostPort:
# -- set this to true to enable dnsHostPort
Expand Down

0 comments on commit 12a545d

Please sign in to comment.