Files
coredns/middleware/kubernetes/SkyDNS.md
Michael Richmond 289f53d386 k8s middleware cleanup, testcases, basic SRV (#181)
* Removing unnecessary gitignore pattern

* Updating Makefile to run unittests for subpackages

* Adding Corefile validation to ignore overlapping zones

* Fixing SRV query handling

* Updating README.md now that SRV works

* Fixing debug message, adding code comment

* Clarifying implementation of zone normalization

* "Overlapping zones" is ill-defined. Reimplemented zone overlap/subzone
  checking to contain these functions in k8s middleware and provide
  better code comments explaining the normalization.

* Separate build verbosity from test verbosity

* Cleaning up comments to match repo code style

* Merging warning messages into single message
* Moving function docs to before function declaration

* Adding test cases for k8sclient connector

* Tests cover connector create and setting base url
* Fixed bugs in connector create and setting base url functions

* Updaing README to group and order development work

* Priority focused on achieving functional parity with SkyDNS.

* Adding work items to README and cleaning up formatting

* More README format cleaning

* List formating

* Refactoring k8s API call to allow dependency injection

* Add test cases for data parsing from k8s into dataobject structures

* URL is dependency-injected to allow replacement with a mock http
  server during test execution

* Adding more data validation for JSON parsing tests

* Adding test case for GetResourceList()

* Adding notes about SkyDNS embedded IP and port record names

* Marked test case implemented.

* Fixing formatting for example command.

* Fixing formatting

* Adding notes about Docker image building.

* Adding SkyDNS work item

* Updating TODO list

* Adding name template to Corefile to specify how k8s record names are assembled

* Adding template support for multi-segment zones

* Updating example CoreFile for k8s with template comment

* Misc whitespace cleanup

* Adding SkyDNS naming notes

* Adding namespace filtering to CoreFile config

* Updating example k8sCoreFile to specify namespaces

* Removing unused codepath

* Adding check for valid namespace

* More README TODO restructuring to focus effort

* Adding template validation while parsing CoreFile

* Record name template is considered invalid if it contains a symbol of the form ${bar} where the symbol
  "${bar}" is not an accepted template symbol.

* Refactoring generation of answer records

* Parse typeName out of query string
* Refactor answer record creation as operation over list of ServiceItems

* Moving k8s API caching into SkyDNS equivalency segment

* Adding function to assemble record names from template

* Warning: This commit may be broken. Syncing to get laptop code over to dev machine.

* More todo notes

* Adding comment describing sample test data.

* Update k8sCorefile

* Adding comment

* Adding filtering support for kubernetes "type"

* Required refactoring to support reuse of the StringInSlice function.

* Cleaning up formatting

* Adding note about SkyDNS supporting word "any".

* baseUrl -> baseURL

* Also removed debug statement from core/setup/kubernetes.go

* Fixing test breaking from Url -> URL naming changes

* Changing record name template language ${...} -> {...}

* Fix formatting with go fmt

* Updating all k8sclient data getters to return error value

* Adding error message to k8sclient data accessors

* Cleaning up setup for kubernetes

* Removed verbose nils in initial k8s middleware instance
* Set reasonable defaults if CoreFile has no parameters in the
kubernetes block. (k8s endpoint, and name template)

* Formatting cleanup -- go fmt
2016-07-07 09:40:58 +01:00

3.3 KiB

DNS Schema

Notes about the SkyDNS record naming scheme. (Copied from SkyDNS project README for reference while hacking on the k8s middleware.)

Services

A Records

"Normal" (not headless) Services are assigned a DNS A record for a name of the form my-svc.my-namespace.svc.cluster.local. This resolves to the cluster IP of the Service.

"Headless" (without a cluster IP) Services are also assigned a DNS A record for a name of the form my-svc.my-namespace.svc.cluster.local. Unlike normal Services, this resolves to the set of IPs of the pods selected by the Service. Clients are expected to consume the set or else use standard round-robin selection from the set.

Pods

A Records

When enabled, pods are assigned a DNS A record in the form of pod-ip-address.my-namespace.pod.cluster.local.

For example, a pod with ip 1.2.3.4 in the namespace default with a dns name of cluster.local would have an entry: 1-2-3-4.default.pod.cluster.local.

####A Records and hostname Based on Pod Annotations - A Beta Feature in Kubernetes v1.2 Currently when a pod is created, its hostname is the Pod's metadata.name value. With v1.2, users can specify a Pod annotation, pod.beta.kubernetes.io/hostname, to specify what the Pod's hostname should be. If the annotation is specified, the annotation value takes precendence over the Pod's name, to be the hostname of the pod. For example, given a Pod with annotation pod.beta.kubernetes.io/hostname: my-pod-name, the Pod will have its hostname set to "my-pod-name".

v1.2 introduces a beta feature where the user can specify a Pod annotation, pod.beta.kubernetes.io/subdomain, to specify what the Pod's subdomain should be. If the annotation is specified, the fully qualified Pod hostname will be "...svc.". For example, given a Pod with the hostname annotation set to "foo", and the subdomain annotation set to "bar", in namespace "my-namespace", the pod will set its own FQDN as "foo.bar.my-namespace.svc.cluster.local"

If there exists a headless service in the same namespace as the pod and with the same name as the subdomain, the cluster's KubeDNS Server will also return an A record for the Pod's fully qualified hostname. Given a Pod with the hostname annotation set to "foo" and the subdomain annotation set to "bar", and a headless Service named "bar" in the same namespace, the pod will see it's own FQDN as "foo.bar.my-namespace.svc.cluster.local". DNS will serve an A record at that name, pointing to the Pod's IP.

With v1.2, the Endpoints object also has a new annotation endpoints.beta.kubernetes.io/hostnames-map. Its value is the json representation of map[string(IP)][endpoints.HostRecord], for example: '{"10.245.1.6":{HostName: "my-webserver"}}'. If the Endpoints are for a headless service, then A records will be created with the format ...svc. For the example json, if endpoints are for a headless service named "bar", and one of the endpoints has IP "10.245.1.6", then a A record will be created with the name "my-webserver.bar.my-namespace.svc.cluster.local" and the A record lookup would return "10.245.1.6". This endpoints annotation generally does not need to be specified by end-users, but can used by the internal service controller to deliver the aforementioned feature.