Skip to content

Commit

Permalink
feat: Change yaml for Custom DNS definition + add custom.list template
Browse files Browse the repository at this point in the history
  • Loading branch information
xorinzor committed Feb 19, 2024
1 parent 24683ec commit 08ede33
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 41 deletions.
2 changes: 1 addition & 1 deletion charts/pihole/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ home: https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole
name: pihole
appVersion: "2024.01.0"
# Do not touch will be updated during release
version: 2.21.0
version: 3.0.0
sources:
- https://github.com/MoJo2600/pihole-kubernetes/tree/master/charts/pihole
- https://pi-hole.net/
Expand Down
16 changes: 16 additions & 0 deletions charts/pihole/templates/configmap-custom-dns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{ if .Values.dnsmasq.customDnsEntries }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "pihole.fullname" . }}-custom-dns
labels:
app: {{ template "pihole.name" . }}
chart: {{ template "pihole.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
custom.list: |
{{- range .Values.dnsmasq.customDnsEntries }}
{{ .address }} {{ .domain }}
{{- end }}
{{ end }}
38 changes: 19 additions & 19 deletions charts/pihole/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ metadata:
heritage: {{ .Release.Service }}
data:
02-custom.conf: |
addn-hosts=/etc/addn-hosts
{{- range .Values.dnsmasq.upstreamServers }}
{{ . }}
{{- end }}
{{- range .Values.dnsmasq.customDnsEntries }}
{{ . }}
{{- end }}
{{- if .Values.serviceDns.loadBalancerIP }}
dhcp-option=6,{{ .Values.serviceDns.loadBalancerIP }}
{{- end }}
{{- range .Values.dnsmasq.customSettings }}
{{ . }}
{{- end }}
addn-hosts=/etc/addn-hosts
{{- range .Values.dnsmasq.upstreamServers }}
{{ . }}
{{- end }}
{{- range .Values.dnsmasq.customDnsEntries }}
address=/{{ .domain }}/{{ .address }}
{{- end }}
{{- if .Values.serviceDns.loadBalancerIP }}
dhcp-option=6,{{ .Values.serviceDns.loadBalancerIP }}
{{- end }}
{{- range .Values.dnsmasq.customSettings }}
{{ . }}
{{- end }}
addn-hosts: |
{{- range .Values.dnsmasq.additionalHostsEntries }}
{{ . }}
{{- end }}
{{- range .Values.dnsmasq.additionalHostsEntries }}
{{ . }}
{{- end }}
05-pihole-custom-cname.conf: |
{{- range .Values.dnsmasq.customCnameEntries }}
{{ . }}
{{- end }}
{{- range .Values.dnsmasq.customCnameEntries }}
cname={{ .domain }},{{ .target }}
{{- end }}
22 changes: 17 additions & 5 deletions charts/pihole/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
checksum.config.whitelist: {{ include (print $.Template.BasePath "/configmap-whitelist.yaml") . | sha256sum | trunc 63 }}
checksum.config.dnsmasqConfig: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
checksum.config.staticDhcpConfig: {{ include (print $.Template.BasePath "/configmap-static-dhcp.yaml") . | sha256sum | trunc 63 }}
checksum.config.customDnsConfig: {{ include (print $.Template.BasePath "/configmap-custom-dns.yaml") . | sha256sum | trunc 63 }}
{{- with .Values.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
Expand Down Expand Up @@ -244,11 +245,21 @@ spec:
- mountPath: /etc/addn-hosts
name: custom-dnsmasq
subPath: addn-hosts
{{- if .Values.dnsmasq.staticDhcpEntries }}
- mountPath: /etc/dnsmasq.d/04-pihole-static-dhcp.conf
name: static-dhcp
subPath: pihole-static-dhcp.conf
{{- end }}
{{- if .Values.dnsmasq.customCnameEntries }}
- mountPath: /etc/dnsmasq.d/05-pihole-custom-cname.conf
name: custom-dnsmasq
subPath: 05-pihole-custom-cname.conf
{{- end }}
{{- if .Values.dnsmasq.customDnsEntries }}
- mountPath: /etc/pihole/custom.list
name: custom-dns
subPath: custom.list
{{- end }}
{{- if .Values.adlists }}
- mountPath: /etc/pihole/adlists.list
name: adlists
Expand All @@ -269,11 +280,6 @@ spec:
name: whitelist
subPath: whitelist.txt
{{- end }}
{{- if .Values.dnsmasq.staticDhcpEntries }}
- mountPath: /etc/dnsmasq.d/04-pihole-static-dhcp.conf
name: static-dhcp
subPath: pihole-static-dhcp.conf
{{- end }}
{{- range $key, $value := .Values.extraVolumeMounts }}
- name: {{ $key }}
{{- toYaml $value | nindent 12 }}
Expand Down Expand Up @@ -331,6 +337,12 @@ spec:
name: {{ template "pihole.fullname" . }}-static-dhcp
name: static-dhcp
{{- end }}
{{- if .Values.dnsmasq.customDnsEntries }}
- configMap:
defaultMode: 420
name: {{ template "pihole.fullname" . }}-custom-dns
name: custom-dns
{{- end }}
{{- if .Values.blacklist }}
- configMap:
defaultMode: 420
Expand Down
28 changes: 12 additions & 16 deletions charts/pihole/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,19 @@ dnsmasq:

# -- Add custom dns entries to override the dns resolution. All lines will be added to the pihole dnsmasq configuration.
customDnsEntries: []
# - address=/foo.bar/192.168.178.10
# - address=/bar.foo/192.168.178.11
# - domain: foo.bar
# address: 192.168.178.10
# - domain: bar.foo
# address: 192.168.178.11

# -- Here we specify custom cname entries that should point to `A` records or
# elements in customDnsEntries array.
customCnameEntries: []
# - domain: cname.foo.bar
# target: foo.bar
# - domain: cname.bar.foo
# target: bar.foo

# -- Dnsmasq reads the /etc/hosts file to resolve ips. You can add additional entries if you like
additionalHostsEntries: []
# - 192.168.0.3 host4
Expand All @@ -343,20 +353,6 @@ dnsmasq:
# otherSettings:
# - rebind-domain-ok=/plex.direct/

# -- Here we specify custom cname entries that should point to `A` records or
# elements in customDnsEntries array.
# The format should be:
# - cname=cname.foo.bar,foo.bar
# - cname=cname.bar.foo,bar.foo
# - cname=cname record,dns record
customCnameEntries: []
# Here we specify custom cname entries that should point to `A` records or
# elements in customDnsEntries array.
# The format should be:
# - cname=cname.foo.bar,foo.bar
# - cname=cname.bar.foo,bar.foo
# - cname=cname record,dns record

# -- list of adlists to import during initial start of the container
adlists: {}
# If you want to provide blocklists, add them here.
Expand Down

0 comments on commit 08ede33

Please sign in to comment.