From 507bfb4f495bcd390c6891c756c1880c223b8a01 Mon Sep 17 00:00:00 2001 From: Rafael Gaspar Date: Sun, 30 Oct 2022 20:29:37 +0100 Subject: [PATCH 1/4] Support for ClusterIP --- charts/pihole/Chart.yaml | 2 +- charts/pihole/templates/service-dhcp.yaml | 11 ++- charts/pihole/templates/service-dns-tcp.yaml | 10 +++ charts/pihole/templates/service-dns-udp.yaml | 10 +++ charts/pihole/templates/service-dns.yaml | 15 +++- charts/pihole/templates/service-web.yaml | 10 +++ charts/pihole/values.yaml | 79 ++++++++++++++------ 7 files changed, 110 insertions(+), 27 deletions(-) diff --git a/charts/pihole/Chart.yaml b/charts/pihole/Chart.yaml index c9097e07..9c54ef83 100644 --- a/charts/pihole/Chart.yaml +++ b/charts/pihole/Chart.yaml @@ -3,7 +3,7 @@ description: Installs pihole in kubernetes home: https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole name: pihole appVersion: "2022.09.1" -version: 2.9.3 +version: 2.9.4 sources: - https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole - https://pi-hole.net/ diff --git a/charts/pihole/templates/service-dhcp.yaml b/charts/pihole/templates/service-dhcp.yaml index 3df2ad93..7ea5929b 100644 --- a/charts/pihole/templates/service-dhcp.yaml +++ b/charts/pihole/templates/service-dhcp.yaml @@ -23,6 +23,13 @@ spec: {{- if .Values.serviceDhcp.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceDhcp.loadBalancerIP }} {{- end }} + {{- if .Values.serviceDhcp.clusterIP }} + clusterIP: {{ .Values.serviceDhcp.clusterIP }} + {{- end }} + {{- if .Values.serviceDhcp.clusterIPs }} + clusterIPs: + {{- toYaml .Values.serviceDhcp.clusterIPs | indent 4 }} + {{- end }} {{- if or (eq .Values.serviceDhcp.type "NodePort") (eq .Values.serviceDhcp.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDhcp.externalTrafficPolicy }} {{- end }} @@ -57,8 +64,8 @@ spec: ipFamilies: - IPv6 ipFamilyPolicy: SingleStack - {{- if .Values.serviceDhcp.loadBalancerIPv6 }} - loadBalancerIP: {{ .Values.serviceDhcp.loadBalancerIPv6 }} + {{- if .Values.serviceDhcp.clusterIPv6 }} + clusterIP: {{ .Values.serviceDhcp.clusterIPv6 }} {{- end }} {{- if or (eq .Values.serviceDhcp.type "NodePort") (eq .Values.serviceDhcp.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDhcp.externalTrafficPolicy }} diff --git a/charts/pihole/templates/service-dns-tcp.yaml b/charts/pihole/templates/service-dns-tcp.yaml index 92062601..a15175bb 100644 --- a/charts/pihole/templates/service-dns-tcp.yaml +++ b/charts/pihole/templates/service-dns-tcp.yaml @@ -23,6 +23,13 @@ spec: {{- if .Values.serviceDns.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }} {{- end }} + {{- if .Values.serviceDns.clusterIP }} + clusterIP: {{ .Values.serviceDns.clusterIP }} + {{- end }} + {{- if .Values.serviceDns.clusterIPs }} + clusterIPs: + {{- toYaml .Values.serviceDns.clusterIPs | indent 4 }} + {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} {{- end }} @@ -66,6 +73,9 @@ spec: {{- if .Values.serviceDns.loadBalancerIPv6 }} loadBalancerIP: {{ .Values.serviceDns.loadBalancerIPv6 }} {{- end }} + {{- if .Values.serviceDns.clusterIPv6 }} + clusterIP: {{ .Values.serviceDns.clusterIPv6 }} + {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} {{- end }} diff --git a/charts/pihole/templates/service-dns-udp.yaml b/charts/pihole/templates/service-dns-udp.yaml index 34835d46..9c45dc8e 100644 --- a/charts/pihole/templates/service-dns-udp.yaml +++ b/charts/pihole/templates/service-dns-udp.yaml @@ -23,6 +23,13 @@ spec: {{- if .Values.serviceDns.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }} {{- end }} + {{- if .Values.serviceDns.clusterIP }} + clusterIP: {{ .Values.serviceDns.clusterIP }} + {{- end }} + {{- if .Values.serviceDns.clusterIPs }} + clusterIPs: + {{- toYaml .Values.serviceDns.clusterIPs | indent 4 }} + {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} {{- end }} @@ -60,6 +67,9 @@ spec: {{- if .Values.serviceDns.loadBalancerIPv6 }} loadBalancerIP: {{ .Values.serviceDns.loadBalancerIPv6 }} {{- end }} + {{- if .Values.serviceDns.clusterIPv6 }} + clusterIP: {{ .Values.serviceDns.clusterIPv6 }} + {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} {{- end }} diff --git a/charts/pihole/templates/service-dns.yaml b/charts/pihole/templates/service-dns.yaml index 0772138e..7c4328a1 100644 --- a/charts/pihole/templates/service-dns.yaml +++ b/charts/pihole/templates/service-dns.yaml @@ -17,6 +17,13 @@ spec: {{- if .Values.serviceDns.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }} {{- end }} + {{- if .Values.serviceDns.clusterIP }} + clusterIP: {{ .Values.serviceDns.clusterIP }} + {{- end }} + {{- if .Values.serviceDns.clusterIPs }} + clusterIPs: + {{- toYaml .Values.serviceDns.clusterIPs | indent 4 }} + {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} {{- end }} @@ -64,8 +71,12 @@ spec: ipFamilies: - IPv6 ipFamilyPolicy: SingleStack - {{- if .Values.serviceDns.loadBalancerIPv6 }} - loadBalancerIP: {{ .Values.serviceDns.loadBalancerIPv6 }} + {{- if .Values.serviceDns.clusterIPv6 }} + clusterIP: {{ .Values.serviceDns.clusterIPv6 }} + {{- end }} + {{- if .Values.serviceDns.clusterIPs }} + clusterIPs: + {{- .Values.serviceDns.clusterIPs | indent 4 }} {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} diff --git a/charts/pihole/templates/service-web.yaml b/charts/pihole/templates/service-web.yaml index ace46032..4972d4ab 100644 --- a/charts/pihole/templates/service-web.yaml +++ b/charts/pihole/templates/service-web.yaml @@ -22,6 +22,13 @@ spec: {{- if .Values.serviceWeb.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceWeb.loadBalancerIP }} {{- end }} + {{- if .Values.serviceWeb.clusterIP }} + clusterIP: {{ .Values.serviceWeb.clusterIP }} + {{- end }} + {{- if .Values.serviceWeb.clusterIPs }} + clusterIPs: + {{- toYaml .Values.serviceWeb.clusterIPs | indent 4 }} + {{- end }} {{- if or (eq .Values.serviceWeb.type "NodePort") (eq .Values.serviceWeb.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceWeb.externalTrafficPolicy }} {{- end }} @@ -75,6 +82,9 @@ spec: {{- if .Values.serviceWeb.loadBalancerIPv6 }} loadBalancerIP: {{ .Values.serviceWeb.loadBalancerIPv6 }} {{- end }} + {{- if .Values.serviceWeb.clusterIPv6 }} + clusterIP: {{ .Values.serviceWeb.clusterIPv6 }} + {{- end }} {{- if or (eq .Values.serviceWeb.type "NodePort") (eq .Values.serviceWeb.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceWeb.externalTrafficPolicy }} {{- end }} diff --git a/charts/pihole/values.yaml b/charts/pihole/values.yaml index c372bdf0..db4a1219 100644 --- a/charts/pihole/values.yaml +++ b/charts/pihole/values.yaml @@ -34,7 +34,6 @@ dnsHostPort: # -- Configuration for the DNS service on port 53 serviceDns: - # -- deploys a mixed (TCP + UDP) Service instead of separate ones mixedService: false @@ -55,14 +54,21 @@ serviceDns: # -- A fixed `spec.loadBalancerIP` for the IPv6 DNS Service loadBalancerIPv6: "" + # -- A fixed `spec.clusterIP` for the DNS Service + clusterIP: "" + # -- Multiple fixed `spec.clusterIPs` for the IPv6 DNS Service + clusterIPv6: "" + # -- Multiple fixed `spec.clusterIPs` for the Dual-Stack DNS Service + clusterIPS: [] + # -- Annotations for the DNS service - annotations: {} + annotations: + {} # metallb.universe.tf/address-pool: network-services # metallb.universe.tf/allow-shared-ip: pihole-svc # -- Configuration for the DHCP service on port 67 serviceDhcp: - # -- Generate a Service resource for DHCP traffic enabled: true @@ -83,8 +89,16 @@ serviceDhcp: # -- A fixed `spec.loadBalancerIP` for the IPv6 DHCP Service loadBalancerIPv6: "" + # -- A fixed `spec.clusterIP` for the DHCP Service + clusterIP: "" + # -- Multiple fixed `spec.clusterIPs` for the IPv6 DHCP Service + clusterIPv6: "" + # -- Multiple fixed `spec.clusterIPs` for the Dual-Stack DHCP Service + clusterIPS: [] + # -- Annotations for the DHCP service - annotations: {} + annotations: + {} # metallb.universe.tf/address-pool: network-services # metallb.universe.tf/allow-shared-ip: pihole-svc @@ -92,7 +106,6 @@ serviceDhcp: serviceWeb: # -- Configuration for the HTTP web interface listener http: - # -- Generate a service for HTTP traffic enabled: true @@ -124,8 +137,16 @@ serviceWeb: # -- A fixed `spec.loadBalancerIP` for the IPv6 web interface Service loadBalancerIPv6: "" + # -- A fixed `spec.clusterIP` for the web interface Service + clusterIP: "" + # -- Multiple fixed `spec.clusterIPs` for the IPv6 web interface Service + clusterIPv6: "" + # -- Multiple fixed `spec.clusterIPs` for the Dual-Stack web interface Service + clusterIPS: [] + # -- Annotations for the DHCP service - annotations: {} + annotations: + {} # metallb.universe.tf/address-pool: network-services # metallb.universe.tf/allow-shared-ip: pihole-svc @@ -140,7 +161,8 @@ ingress: # ingressClassName: nginx # -- Annotations for the ingress - annotations: {} + annotations: + {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" path: / @@ -177,7 +199,8 @@ probes: # -- choice for the user. This also increases chances charts run on environments with little # -- resources, such as Minikube. If you do want to specify resources, uncomment the following # -- lines, adjust them as necessary, and remove the curly braces after 'resources:'. -resources: {} +resources: + {} # limits: # cpu: 100m # memory: 128Mi @@ -241,11 +264,13 @@ admin: passwordKey: "password" # -- extraEnvironmentVars is a list of extra enviroment variables to set for pihole to use -extraEnvVars: {} +extraEnvVars: + {} # TZ: UTC # -- extraEnvVarsSecret is a list of secrets to load in as environment variables. -extraEnvVarsSecret: {} +extraEnvVarsSecret: + {} # env_var: # name: secret-name # key: secret-key @@ -272,7 +297,8 @@ doh: tag: latest pullPolicy: IfNotPresent # -- Here you can pass environment variables to the DoH container, for example: - envVars: {} + envVars: + {} # TUNNEL_DNS_UPSTREAM: "https://1.1.1.2/dns-query,https://1.0.0.2/dns-query" # -- Probes configuration @@ -337,28 +363,33 @@ dnsmasq: # - cname=cname record,dns record # -- list of adlists to import during initial start of the container -adlists: {} +adlists: + {} # If you want to provide blocklists, add them here. # - https://hosts-file.net/grm.txt # - https://reddestdream.github.io/Projects/MinimalHosts/etc/MinimalHostsBlocker/minimalhosts # -- list of whitelisted domains to import during initial start of the container -whitelist: {} +whitelist: + {} # If you want to provide whitelisted domains, add them here. # - clients4.google.com # -- list of blacklisted domains to import during initial start of the container -blacklist: {} +blacklist: + {} # If you want to have special domains blacklisted, add them here # - *.blackist.com # -- list of blacklisted regex expressions to import during initial start of the container -regex: {} +regex: + {} # Add regular expression blacklist items # - (^|\.)facebook\.com$ # -- values that should be added to pihole-FTL.conf -ftl: {} +ftl: + {} # Add values for pihole-FTL.conf # MAXDBDAYS: 14 @@ -381,24 +412,28 @@ customVolumes: # -- set this to true to enable custom volumes enabled: false # -- any volume type can be used here - config: {} + config: + {} # hostPath: # path: "/mnt/data" # -- any extra volumes you might want -extraVolumes: {} +extraVolumes: + {} # external-conf: # configMap: # name: pi-hole-lighttpd-external-conf # -- any extra volume mounts you might want -extraVolumeMounts: {} +extraVolumeMounts: + {} # external-conf: # mountPath: /etc/lighttpd/external.conf # subPath: external.conf # -- Additional annotations for pods -podAnnotations: {} +podAnnotations: + {} # Example below allows Prometheus to scape on metric port (requires pihole-exporter sidecar enabled) # prometheus.io/port: '9617' # prometheus.io/scrape: 'true' @@ -428,5 +463,5 @@ podDnsConfig: enabled: true policy: "None" nameservers: - - 127.0.0.1 - - 8.8.8.8 + - 127.0.0.1 + - 8.8.8.8 From 79e301e4ad3108c6eef7811f927f9199eefebad0 Mon Sep 17 00:00:00 2001 From: Rafael Gaspar Date: Tue, 8 Nov 2022 16:32:19 +0100 Subject: [PATCH 2/4] Fix dual-stack --- charts/pihole/templates/service-dhcp.yaml | 2 +- charts/pihole/templates/service-dns-tcp.yaml | 2 +- charts/pihole/templates/service-dns-udp.yaml | 2 +- charts/pihole/templates/service-dns.yaml | 8 +++++++- charts/pihole/templates/service-web.yaml | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/charts/pihole/templates/service-dhcp.yaml b/charts/pihole/templates/service-dhcp.yaml index 7ea5929b..fe122663 100644 --- a/charts/pihole/templates/service-dhcp.yaml +++ b/charts/pihole/templates/service-dhcp.yaml @@ -28,7 +28,7 @@ spec: {{- end }} {{- if .Values.serviceDhcp.clusterIPs }} clusterIPs: - {{- toYaml .Values.serviceDhcp.clusterIPs | indent 4 }} + {{- toYaml .Values.serviceDhcp.clusterIPs | nindent 4 }} {{- end }} {{- if or (eq .Values.serviceDhcp.type "NodePort") (eq .Values.serviceDhcp.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDhcp.externalTrafficPolicy }} diff --git a/charts/pihole/templates/service-dns-tcp.yaml b/charts/pihole/templates/service-dns-tcp.yaml index a15175bb..5297d6fe 100644 --- a/charts/pihole/templates/service-dns-tcp.yaml +++ b/charts/pihole/templates/service-dns-tcp.yaml @@ -28,7 +28,7 @@ spec: {{- end }} {{- if .Values.serviceDns.clusterIPs }} clusterIPs: - {{- toYaml .Values.serviceDns.clusterIPs | indent 4 }} + {{- toYaml .Values.serviceDns.clusterIPs | nindent 4 }} {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} diff --git a/charts/pihole/templates/service-dns-udp.yaml b/charts/pihole/templates/service-dns-udp.yaml index 9c45dc8e..5d80c184 100644 --- a/charts/pihole/templates/service-dns-udp.yaml +++ b/charts/pihole/templates/service-dns-udp.yaml @@ -28,7 +28,7 @@ spec: {{- end }} {{- if .Values.serviceDns.clusterIPs }} clusterIPs: - {{- toYaml .Values.serviceDns.clusterIPs | indent 4 }} + {{- toYaml .Values.serviceDns.clusterIPs | nindent 4 }} {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} diff --git a/charts/pihole/templates/service-dns.yaml b/charts/pihole/templates/service-dns.yaml index 7c4328a1..83895810 100644 --- a/charts/pihole/templates/service-dns.yaml +++ b/charts/pihole/templates/service-dns.yaml @@ -14,6 +14,12 @@ metadata: {{- end }} spec: type: {{ .Values.serviceDns.type }} + {{- if and (.Values.dualStack.enabled) (not (eq .Values.serviceDns.type "LoadBalancer")) }} + ipFamilies: + - IPv4 + - IPv6 + ipFamilyPolicy: PreferDualStack + {{- end }} {{- if .Values.serviceDns.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }} {{- end }} @@ -22,7 +28,7 @@ spec: {{- end }} {{- if .Values.serviceDns.clusterIPs }} clusterIPs: - {{- toYaml .Values.serviceDns.clusterIPs | indent 4 }} + {{- toYaml .Values.serviceDns.clusterIPs | nindent 4 }} {{- end }} {{- if or (eq .Values.serviceDns.type "NodePort") (eq .Values.serviceDns.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceDns.externalTrafficPolicy }} diff --git a/charts/pihole/templates/service-web.yaml b/charts/pihole/templates/service-web.yaml index 4972d4ab..fde4aad9 100644 --- a/charts/pihole/templates/service-web.yaml +++ b/charts/pihole/templates/service-web.yaml @@ -27,7 +27,7 @@ spec: {{- end }} {{- if .Values.serviceWeb.clusterIPs }} clusterIPs: - {{- toYaml .Values.serviceWeb.clusterIPs | indent 4 }} + {{- toYaml .Values.serviceWeb.clusterIPs | nindent 4 }} {{- end }} {{- if or (eq .Values.serviceWeb.type "NodePort") (eq .Values.serviceWeb.type "LoadBalancer") }} externalTrafficPolicy: {{ .Values.serviceWeb.externalTrafficPolicy }} From a90b8a85c125b3cbee7ef50611b40e55a67f7dfe Mon Sep 17 00:00:00 2001 From: Rafael Gaspar Date: Wed, 9 Nov 2022 09:56:48 +0100 Subject: [PATCH 3/4] Fix DNS loadbalancer IP --- charts/pihole/Chart.yaml | 2 +- charts/pihole/templates/service-dns.yaml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/pihole/Chart.yaml b/charts/pihole/Chart.yaml index 9c54ef83..28b6bdd7 100644 --- a/charts/pihole/Chart.yaml +++ b/charts/pihole/Chart.yaml @@ -3,7 +3,7 @@ description: Installs pihole in kubernetes home: https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole name: pihole appVersion: "2022.09.1" -version: 2.9.4 +version: 2.9.6 sources: - https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole - https://pi-hole.net/ diff --git a/charts/pihole/templates/service-dns.yaml b/charts/pihole/templates/service-dns.yaml index 83895810..5513c278 100644 --- a/charts/pihole/templates/service-dns.yaml +++ b/charts/pihole/templates/service-dns.yaml @@ -80,6 +80,9 @@ spec: {{- if .Values.serviceDns.clusterIPv6 }} clusterIP: {{ .Values.serviceDns.clusterIPv6 }} {{- end }} + {{- if .Values.serviceDns.loadBalancerIPv6 }} + loadBalancerIP: {{ .Values.serviceDns.loadBalancerIPv6 }} + {{- end }} {{- if .Values.serviceDns.clusterIPs }} clusterIPs: {{- .Values.serviceDns.clusterIPs | indent 4 }} From 585333850e8ae8f6ebbabf6b0a17e9b7c705facd Mon Sep 17 00:00:00 2001 From: Rafael Gaspar Date: Wed, 9 Nov 2022 10:13:47 +0100 Subject: [PATCH 4/4] Another attempt --- charts/pihole/Chart.yaml | 2 +- charts/pihole/templates/service-dns.yaml | 4 ++++ charts/pihole/templates/service-web.yaml | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/charts/pihole/Chart.yaml b/charts/pihole/Chart.yaml index 28b6bdd7..58599496 100644 --- a/charts/pihole/Chart.yaml +++ b/charts/pihole/Chart.yaml @@ -3,7 +3,7 @@ description: Installs pihole in kubernetes home: https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole name: pihole appVersion: "2022.09.1" -version: 2.9.6 +version: 2.9.7 sources: - https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole - https://pi-hole.net/ diff --git a/charts/pihole/templates/service-dns.yaml b/charts/pihole/templates/service-dns.yaml index 5513c278..dd3dd57f 100644 --- a/charts/pihole/templates/service-dns.yaml +++ b/charts/pihole/templates/service-dns.yaml @@ -19,6 +19,10 @@ spec: - IPv4 - IPv6 ipFamilyPolicy: PreferDualStack + {{- else }} + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack {{- end }} {{- if .Values.serviceDns.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceDns.loadBalancerIP }} diff --git a/charts/pihole/templates/service-web.yaml b/charts/pihole/templates/service-web.yaml index fde4aad9..1935e1dd 100644 --- a/charts/pihole/templates/service-web.yaml +++ b/charts/pihole/templates/service-web.yaml @@ -18,6 +18,10 @@ spec: - IPv4 - IPv6 ipFamilyPolicy: PreferDualStack + {{- else }} + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack {{- end }} {{- if .Values.serviceWeb.loadBalancerIP }} loadBalancerIP: {{ .Values.serviceWeb.loadBalancerIP }}