You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
4.2 KiB

  1. K8s DNS stack by Kargo
  2. ======================
  3. Kargo configures a [Kubernetes DNS](http://kubernetes.io/docs/admin/dns/)
  4. [cluster add-on](http://releases.k8s.io/master/cluster/addons/README.md)
  5. to serve as an authoritative DNS server for a given ``dns_domain`` and its
  6. ``svc, default.svc`` default subdomains (a total of ``ndots: 5`` max levels).
  7. Note, additional search (sub)domains may be defined in the ``searchdomains``
  8. and ``ndots`` vars. And additional recursive DNS resolvers in the `` upstream_dns_servers``,
  9. ``nameservers`` vars. Intranet DNS resolvers should be specified in the first
  10. place, followed by external resolvers, for example:
  11. ```
  12. skip_dnsmasq: true
  13. nameservers: [8.8.8.8]
  14. upstream_dns_servers: [172.18.32.6]
  15. ```
  16. or
  17. ```
  18. skip_dnsmasq: false
  19. upstream_dns_servers: [172.18.32.6, 172.18.32.7, 8.8.8.8, 8.8.8.4]
  20. ```
  21. The vars are explained below as well.
  22. DNS configuration details
  23. -------------------------
  24. Here is an approximate picture of how DNS things working and
  25. being configured by Kargo ansible playbooks:
  26. ![Image](figures/dns.jpeg?raw=true)
  27. Note that an additional dnsmasq daemon set is installed by Kargo
  28. by default. Kubelet will configure DNS base of all pods to use the
  29. given dnsmasq cluster IP, which is defined via the ``dns_server`` var.
  30. The dnsmasq forwards requests for a given cluster ``dns_domain`` to
  31. Kubedns's SkyDns service. The SkyDns server is configured to be an
  32. authoritative DNS server for the given cluser domain (and its subdomains
  33. up to ``ndots:5`` depth). Note: you should scale its replication controller
  34. up, if SkyDns chokes. These two layered DNS forwarders provide HA for the
  35. DNS cluster IP endpoint, which is a critical moving part for Kubernetes apps.
  36. Nameservers are as well configured in the hosts' ``/etc/resolv.conf`` files,
  37. as the given DNS cluster IP merged with ``nameservers`` values. While the
  38. DNS cluster IP merged with the ``upstream_dns_servers`` defines additional
  39. nameservers for the aforementioned nsmasq daemon set running on all hosts.
  40. This mitigates existing Linux limitation of max 3 nameservers in the
  41. ``/etc/resolv.conf`` and also brings an additional caching layer for the
  42. clustered DNS services.
  43. You can skip the dnsmasq daemon set install steps by setting the
  44. ``skip_dnsmasq: true``. This may be the case, if you're fine with
  45. the nameservers limitation. Sadly, there is no way to work around the
  46. search domain limitations of a 256 chars and 6 domains. Thus, you can
  47. use the ``searchdomains`` var to define no more than a three custom domains.
  48. Remaining three slots are reserved for K8s cluster default subdomains.
  49. When dnsmasq skipped, Kargo redefines the DNS cluster IP to point directly
  50. to SkyDns cluster IP ``skydns_server`` and configures Kubelet's
  51. ``--dns_cluster`` to use that IP as well. While this greatly simplifies
  52. things, it comes by the price of limited nameservers though. As you know now,
  53. the DNS cluster IP takes a slot in the ``/etc/resolv.conf``, thus you can
  54. specify no more than a two nameservers for infra and/or external use.
  55. Those may be specified either in ``nameservers`` or ``upstream_dns_servers``
  56. and will be merged together with the ``skydns_server`` IP into the hots'
  57. ``/etc/resolv.conf``.
  58. Limitations
  59. -----------
  60. * Kargo has yet ways to configure Kubedns addon to forward requests SkyDns can
  61. not answer with authority to arbitrary recursive resolvers. This task is left
  62. for future. See [official SkyDns docs](https://github.com/skynetservices/skydns)
  63. for details.
  64. * There is
  65. [no way to specify a custom value](https://github.com/kubernetes/kubernetes/issues/33554)
  66. for the SkyDNS ``ndots`` param via an
  67. [option for KubeDNS](https://github.com/kubernetes/kubernetes/blob/master/cmd/kube-dns/app/options/options.go)
  68. add-on, while SkyDNS supports it though. Thus, DNS SRV records may not work
  69. as expected as they require the ``ndots:7``.
  70. * the ``searchdomains`` have a limitation of a 6 names and 256 chars
  71. length. Due to default ``svc, default.svc`` subdomains, the actual
  72. limits are a 4 names and 239 chars respectively.
  73. * the ``nameservers`` have a limitation of a 3 servers, although there
  74. is a way to mitigate that with the ``upstream_dns_servers``,
  75. see below. Anyway, the ``nameservers`` can take no more than a two
  76. custom DNS servers because of one slot is reserved for a Kubernetes
  77. cluster needs.