Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add independent config for TCP/UDP for dnsService #262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions charts/pihole/templates/service-dns-tcp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if not .Values.serviceDns.mixedService }}
{{- if and (not .Values.serviceDns.mixedService) (.Values.serviceDns.tcp.enabled) }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -8,10 +8,15 @@ metadata:
chart: {{ template "pihole.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.serviceDns.annotations }}
{{- if or .Values.serviceDns.annotations .Values.serviceDns.tcp.annotations }}
annotations:
{{- if .Values.serviceDns.annotations }}
{{ toYaml .Values.serviceDns.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.tcp.annotations }}
{{ toYaml .Values.serviceDns.tcp.annotations | indent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
{{- if and (.Values.dualStack.enabled) (not (eq .Values.serviceDns.type "LoadBalancer")) }}
Expand All @@ -27,7 +32,7 @@ spec:
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.serviceDns.port }}
- port: {{ .Values.serviceDns.tcp.port | default .Values.serviceDns.port }}
targetPort: dns
{{- if and (.Values.serviceDns.nodePort) (eq .Values.serviceDns.type "NodePort") }}
nodePort: {{ .Values.serviceDns.nodePort }}
Expand All @@ -54,10 +59,15 @@ metadata:
chart: {{ template "pihole.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.serviceDns.annotations }}
{{- if or .Values.serviceDns.annotations .Values.serviceDns.tcp.annotations }}
annotations:
{{- if .Values.serviceDns.annotations }}
{{ toYaml .Values.serviceDns.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.tcp.annotations }}
{{ toYaml .Values.serviceDns.tcp.annotations | indent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
ipFamilies:
Expand All @@ -70,7 +80,7 @@ spec:
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.serviceDns.port }}
- port: {{ .Values.serviceDns.tcp.port | default .Values.serviceDns.port }}
targetPort: dns
protocol: TCP
name: dns
Expand Down
20 changes: 15 additions & 5 deletions charts/pihole/templates/service-dns-udp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if not .Values.serviceDns.mixedService }}
{{- if and (not .Values.serviceDns.mixedService) (.Values.serviceDns.udp.enabled) }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -8,10 +8,15 @@ metadata:
chart: {{ template "pihole.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.serviceDns.annotations }}
{{- if or .Values.serviceDns.annotations .Values.serviceDns.udp.annotations }}
annotations:
{{- if .Values.serviceDns.annotations }}
{{ toYaml .Values.serviceDns.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.udp.annotations }}
{{ toYaml .Values.serviceDns.upd.annotations | indent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
{{- if and (.Values.dualStack.enabled) (not (eq .Values.serviceDns.type "LoadBalancer")) }}
Expand All @@ -27,7 +32,7 @@ spec:
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.serviceDns.port }}
- port: {{ .Values.serviceDns.udp.port | default .Values.serviceDns.port }}
targetPort: dns-udp
{{- if and (.Values.serviceDns.nodePort) (eq .Values.serviceDns.type "NodePort") }}
nodePort: {{ .Values.serviceDns.nodePort }}
Expand All @@ -48,10 +53,15 @@ metadata:
chart: {{ template "pihole.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.serviceDns.annotations }}
{{- if or .Values.serviceDns.annotations .Values.serviceDns.udp.annotations }}
annotations:
{{- if .Values.serviceDns.annotations }}
{{ toYaml .Values.serviceDns.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.udp.annotations }}
{{ toYaml .Values.serviceDns.udp.annotations | indent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
ipFamilies:
Expand All @@ -64,7 +74,7 @@ spec:
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.serviceDns.port }}
- port: {{ .Values.serviceDns.udp.port | default .Values.serviceDns.port }}
targetPort: dns-udp
protocol: UDP
name: dns-udp
Expand Down
36 changes: 30 additions & 6 deletions charts/pihole/templates/service-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ metadata:
chart: {{ template "pihole.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.serviceDns.annotations }}
{{- if or (or (.Values.serviceDns.annotations) (.Values.serviceDns.udp.annotations)) (.Values.serviceDns.udp.annotations) }}
annotations:
{{- if .Values.serviceDns.annotations }}
{{ toYaml .Values.serviceDns.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.tcp.annotations }}
{{ toYaml .Values.serviceDns.tcp.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.udp.annotations }}
{{ toYaml .Values.serviceDns.upd.annotations | indent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
{{- if .Values.serviceDns.loadBalancerIP }}
Expand All @@ -21,20 +29,24 @@ spec:
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.serviceDns.port }}
{{- if (.Values.serviceDns.tcp.enabled | default true) }}
- port: {{ .Values.serviceDns.tcp.port | default .Values.serviceDns.port }}
targetPort: dns
{{- if .Values.serviceDns.nodePort }}
nodePort: {{ .Values.serviceDns.nodePort }}
{{- end }}
protocol: TCP
name: dns
- port: {{ .Values.serviceDns.port }}
{{- end }}
{{- if (.Values.serviceDns.udp.enabled | default true) }}
- port: {{ .Values.serviceDns.udp.port | default .Values.serviceDns.port }}
targetPort: dns-udp
{{- if and (.Values.serviceDns.nodePort) (eq .Values.serviceDns.type "NodePort") }}
nodePort: {{ .Values.serviceDns.nodePort }}
{{- end }}
protocol: UDP
name: dns-udp
{{- end }}
{{- if .Values.monitoring.sidecar.enabled }}
- port: {{ .Values.monitoring.sidecar.port }}
targetPort: prometheus
Expand All @@ -55,10 +67,18 @@ metadata:
chart: {{ template "pihole.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.serviceDns.annotations }}
{{- if or (or (.Values.serviceDns.annotations) (.Values.serviceDns.udp.annotations)) (.Values.serviceDns.udp.annotations) }}
annotations:
{{- if .Values.serviceDns.annotations }}
{{ toYaml .Values.serviceDns.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.tcp.annotations }}
{{ toYaml .Values.serviceDns.tcp.annotations | indent 4 }}
{{- end }}
{{- if .Values.serviceDns.udp.annotations }}
{{ toYaml .Values.serviceDns.upd.annotations | indent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.serviceDns.type }}
ipFamilies:
Expand All @@ -71,14 +91,18 @@ spec:
externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.serviceDns.port }}
{{- if (.Values.serviceDns.tcp.enabled | default true) }}
- port: {{ .Values.serviceDns.tcp.port | default .Values.serviceDns.port }}
targetPort: dns
protocol: TCP
name: dns
- port: {{ .Values.serviceDns.port }}
{{- end }}
{{- if (.Values.serviceDns.udp.enabled | default true) }}
- port: {{ .Values.serviceDns.udp.port | default .Values.serviceDns.port }}
targetPort: dns-udp
protocol: UDP
name: dns-udp
{{- end }}
{{- if .Values.monitoring.sidecar.enabled }}
- port: {{ .Values.monitoring.sidecar.port }}
targetPort: prometheus
Expand Down
17 changes: 17 additions & 0 deletions charts/pihole/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ serviceDns:
# -- The port of the DNS service
port: 53

# -- Configuration for TCP port mapping
tcp:
# -- Create a tcp port mapping
enabled: true
# -- External port to use for TCP only
port: 53
# -- Extra annotations for TCP service
annotations: {}
# -- Configuration for UDP port mapping
udp:
# -- Create a udp port mapping
enabled: true
# -- External port to use for UDP only
port: 53
# -- Extra annotations for UDP service
annotations: {}

# -- Optional node port for the DNS service
nodePort: ""

Expand Down