Skip to content

ForwardToKubeDNS when using NodeLocal DNSCache is not working as expected #11742

@ederst

Description

@ederst

/kind bug

1. What kops version are you running? The command kops version, will display
this information.

1.20.1

2. What Kubernetes version are you running? kubectl version will print the
version if a cluster is running or provide the Kubernetes version specified as
a kops flag.

1.20.5

3. What cloud provider are you using?

OpenStack

4. What commands did you run? What is the simplest way to reproduce this issue?

When executing kops update cluster the NodeLocal DNSCache Corefile config will not be updated when the forwardToKubeDNS value - introduced with #10111 - has changed.

The easiest way to reproduce the issue is, to enable the NodeLocal DNSCache and set forwardToKubeDNS to either true or false or not set it at all, which should default to false. Irrespective of the set value, the resulting Corefile config for the NodeLocal DNSCache will always use the true clause:

{{- if KubeDNS.NodeLocalDNS.ForwardToKubeDNS }}
.:53 {
errors
cache 30
reload
loop
bind {{ KubeDNS.NodeLocalDNS.LocalIP }}
forward . {{ NodeLocalDNSClusterIP }} {
force_tcp
}
prometheus :9253
}
{{- else }}
in-addr.arpa:53 {
errors
cache 30
reload
loop
bind {{ KubeDNS.NodeLocalDNS.LocalIP }}
forward . {{ NodeLocalDNSClusterIP }} {
force_tcp
}
prometheus :9253
}
ip6.arpa:53 {
errors
cache 30
reload
loop
bind {{ KubeDNS.NodeLocalDNS.LocalIP }}
forward . {{ NodeLocalDNSClusterIP }} {
force_tcp
}
prometheus :9253
}
.:53 {
errors
cache 30
reload
loop
bind {{ KubeDNS.NodeLocalDNS.LocalIP }}
forward . __PILLAR__UPSTREAM__SERVERS__
prometheus :9253
}
{{- end }}

5. What happened after the commands executed?

The Corefile of the NodeLocal DNSCache was configured wrong when using forwardToKubeDNS: false.

6. What did you expect to happen?

I expected the Corefile of the NodeLocal DNSCache to contain the the config of the else clause (when forwardToKubeDNS is set to false or not set at all, which defaults to false as well) of the template (see link to template above).

7. Please provide your cluster manifest. Execute
kops get --name my.example.com -o yaml to display your cluster manifest.
You may want to remove your cluster name and other sensitive information.

Relevant part:

spec:
  kubeDNS:
    provider: CoreDNS
    nodeLocalDNS:
      enabled: true
      forwardToKubeDNS: false  # or do not set it at all

8. Please run the commands with most verbose logging by adding the -v 10 flag.
Paste the logs into this report, or in a gist and provide the gist link here.

n/a

9. Anything else do we need to know?

The issue seems to be related to the fact that ForwardToKubeDNS is a bool pointer and does not get dereferenced in the template:

ForwardToKubeDNS *bool `json:"forwardToKubeDNS,omitempty"`

Thus the address is used, which always results in a "true". The proper way of doing this would be to either change ForwardToKubeDNS to a bool or to dereference it in the template, with for example WithDefaultBool:

dest["WithDefaultBool"] = func(v *bool, defaultValue bool) bool {
if v != nil {
return *v
}
return defaultValue
}

I will provide a PR for the latter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions