Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the DNS stack to be backward compatible with an old dns_domain #10630

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/dns-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@ coredns_default_zone_cache_block: |
}
```

### Handle old/extra dns_domains

If you need to change the dns_domain of your cluster for whatever reason (switching to or from `cluster.local` for example),
and you have workloads that embed it in their configuration you can use the variable `old_dns_domains`.
This will add some configuration to coredns and nodelocaldns to ensure the DNS requests using the old domain are handled correctly.
Example:

```yaml
old_dns_domains:
- example1.com
- example2.com
dns_domain: cluster.local
```

will make `my-svc.my-ns.svc.example1.com`, `my-svc.my-ns.svc.example2.com` and `my-svc.my-ns.svc.cluster.local` have the same DNS answer.

### systemd_resolved_disable_stub_listener

Whether or not to set `DNSStubListener=no` when using systemd-resolved. Defaults to `true` on Flatcar.
Expand Down
4 changes: 4 additions & 0 deletions roles/kubernetes-apps/ansible/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ coredns_port: 53
# coredns_additional_error_config: |
# consolidate 5m ".* i/o timeout$" warning

# Configure coredns and nodelocaldns to correctly answer DNS queries when you changed
# your 'dns_domain' and some workloads used it directly.
old_dns_domains: []

# dns_upstream_forward_extra_opts apply to coredns forward section as well as nodelocaldns upstream target forward section
# dns_upstream_forward_extra_opts:
# policy: sequential
Expand Down
3 changes: 3 additions & 0 deletions roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ data:
{% if coredns_rewrite_block is defined %}
{{ coredns_rewrite_block | indent(width=8, first=False) }}
{% endif %}
{% for old_dns_domain in old_dns_domains %}
rewrite name suffix {{ old_dns_domain }} {{ dns_domain }} answer auto
{% endfor %}
ready
kubernetes {{ dns_domain }} {% if coredns_kubernetes_extra_domains is defined %}{{ coredns_kubernetes_extra_domains }} {% endif %}{% if enable_coredns_reverse_dns_lookups %}in-addr.arpa ip6.arpa {% endif %}{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum.
Looking at that just now I wonder if I should instead extend coredns_kubernetes_extra_domains (I don't think that setting can work currently since nodelocaldns won't forward it to coredns)

pods insecure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ data:
}
{% endfor %}
{% endif %}
{{ dns_domain }}:53 {
{{ ([dns_domain] + old_dns_domains) | join(' ') }}:53 {
errors
cache {
success 9984 30
Expand Down