MoJo2600 / pihole-kubernetes

PiHole on kubernetes
498 stars 173 forks source link

podDnsConfig enabled false still results in an Upstream DNS Server being checked #200

Open lknite opened 2 years ago

lknite commented 2 years ago

I have my own dns server and for pihole to work the Upstream DNS Servers all need to be unchecked.

I'm setting:

podDnsConfig:
  enabled: false

but after deploying pihole i still need to log in and uncheck the default upstream server

MoJo2600 commented 2 years ago

Ok, this seems to be a bug. I think charts/pihole/templates/deployment.yaml (Line 59) should be like this to enforce dnsPolicy: "None".

      {{- if .Values.podDnsConfig.enabled }}
      dnsPolicy: {{ .Values.podDnsConfig.policy }}
      {{- else }}
      dnsPolicy: "None"
      {{- end }}

Maybe you want to test this out an create a pull request if it is working for you?

lknite commented 2 years ago

Here's what I've discovered: If I only have DNS1 set in my values.conf, and not DNS2, then Google gets set automatically with 8.8.4.4. I can view the deployment and see this in the environment variable being set PIHOLEDNS. First I tried an empty DNS2, which didn't work, then I made up an invalid DNS2 and that worked.

In deployment.yaml it is checking if DNS2 exists, though, it always will because it is always set with a default value in values.yaml.

{{- if .Values.DNS1 }}
          - name: 'PIHOLE_DNS_'
            value: {{ if .Values.DNS2 }}{{ ( printf "%v;%v" .Values.DNS1 .Values.DNS2 ) | squote }}{{ else }}{{ .Values.DNS1 | squote }}{{ end }}

Currently, the README.md seems inaccurate, if someone uses podDnsConfig.enabled=false, and only specify a DNS1 they'll get the 8.8.4.4 DNS2 as a default. I'm not sure the best solution. Default DNS values of 8.8.8.8 and 8.8.4.4 are probably good, but it seems 8.8.4.4 should be removed as a default and perhaps added back in later if no DNS2 is specified and podDnsConfig.enabled=true. What do you think?