The parent task describes the work going on to run a coredns service on our k8s infrastructure to serve PTR records for k8s pod IPs, which will aid troubleshooting by giving us a way to work back from an IP address in a log to a particular k8s pod.
Part of this involves creating NS records in the DNS zones hosted by our authdns servers, to delegate the ranges managed by kubernetes to the correct hosts. The plan currently is that the control-plane nodes for each kubernetes cluster will host the service, which will be available on the actual host's main IP address through the use of NodePort.
This task will be used to track the work to get the authdns delegation side of this up and working.
Subnets and name servers
The list of subnets used by each cluster, and the control-plane nodes for each, is available in hiera under kubernetes::clusters. Reverse zone(s) covering the IP ranges listed under cluster_cidr for each cluster need to be delegated to the set of servers listed under control_plane_nodes.
Generating the zone file data
I've been experimenting with how to generate the DNS records we need from the above data, some of which I've put on github here:
https://github.com/topranks/random_wmf/tree/main/hackathon_k8s_dns
At a high-level I think we can generate 'snippet' files, much as the Netbox generate_dns_snippets script does. Like that case we can publish the generated files to a sub-directory under /etc/gdnsd/templates/, and use INCLUDE statements in the dns repo zone templates to include the new records.
Unlike the Netbox snippet script we can probably run the script to generate the NS entries directly on the authdns hosts themselves. Or at any rate there is no particular reason the script needs to run on a netbox host. The script I've been playing with will need the information about the parent zones as well as the kubernetes k8s info. We can add this parent zone data to hiera. My idea was to then make this data available in YAML files local to where the script runs, which we can potentially create using puppet.
Open questions
- Is this a good approach?
- Where should the script be run from? authdns servers themselves?
- How should the data it needs be created? Using puppet?
- How and when should the script run to (re-)generate the zone file snippets?
- How should it trigger authdns-update
- How do we automate all of this?