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 Jan 13, 2022
1 parent 6f9942d commit bb340e6
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/pihole/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Installs pihole in kubernetes
home: https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole
name: pihole
appVersion: 2021.10.1
version: 2.5.4
version: 2.5.5
sources:
- https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole
- https://pi-hole.net/
Expand Down
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 bb340e6

Please sign in to comment.