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 18, 2024
1 parent 24683ec commit aaaef15
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 25 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 }}
4 changes: 2 additions & 2 deletions charts/pihole/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data:
{{ . }}
{{- end }}
{{- range .Values.dnsmasq.customDnsEntries }}
{{ . }}
address=/{{ .domain }}/{{ .address }}
{{- end }}
{{- if .Values.serviceDns.loadBalancerIP }}
dhcp-option=6,{{ .Values.serviceDns.loadBalancerIP }}
Expand All @@ -28,5 +28,5 @@ data:
{{- end }}
05-pihole-custom-cname.conf: |
{{- range .Values.dnsmasq.customCnameEntries }}
{{ . }}
cname={{ .domain }},{{ .target }}
{{- end }}
18 changes: 12 additions & 6 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 @@ -220,7 +221,7 @@ spec:
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}

{{- end }}
{{- if .Values.probes.readiness.enabled }}
readinessProbe:
Expand All @@ -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
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 aaaef15

Please sign in to comment.