Merge branch 'cleanup-for-release'

This commit is contained in:
Miek Gieben 2016-08-28 09:33:04 +01:00
commit c3d3ff2825
4 changed files with 32 additions and 51 deletions

View file

@ -1,4 +0,0 @@
.:1053 authors.bind:1053 {
chaos CoreDNS-001 "Miek Gieben" miek@miek.nl
proxy . 8.8.8.8:53
}

View file

@ -1,10 +0,0 @@
.:1053 {
etcd skydns.local {
stubzones
path /skydns
endpoint http://localhost:2379
upstream 8.8.8.8:53 8.8.4.4:53
debug
}
proxy . 8.8.8.8:53
}

View file

@ -1,25 +0,0 @@
# Serve on port 53
.:53 {
# use kubernetes middleware for domain "coredns.local"
kubernetes coredns.local {
# Kubernetes data API resync period
# Example values: 60s, 5m, 1h
resyncperiod 5m
# Use url for k8s API endpoint
endpoint http://localhost:8080
# Assemble k8s record names with the template
template {service}.{namespace}.{zone}
# Only expose the k8s namespace "demo"
namespaces demo
# Only expose the records for kubernetes objects
# that matches this label selector. The label
# selector syntax is described in the kubernetes
# API documentation: http://kubernetes.io/docs/user-guide/labels/
# Example selector below only exposes objects tagged as
# "application=nginx" in the staging or qa environments.
#labels environment in (staging, qa),application=nginx
}
# Perform DNS response caching for the coredns.local zone
# Cache timeout is provided by the integer in seconds
#cache 180 coredns.local
}

View file

@ -3,7 +3,7 @@
`kubernetes` enables reading zone data from a kubernetes cluster. Record names `kubernetes` enables reading zone data from a kubernetes cluster. Record names
are constructed as "myservice.mynamespace.coredns.local" where: are constructed as "myservice.mynamespace.coredns.local" where:
* "myservice" is the name of the k8s service (this may include multiple DNS labels, * "myservice" is the name of the k8s service (this may include multiple DNS labels,
such as "c1.myservice"), such as "c1.myservice"),
* "mynamespace" is the k8s namespace for the service, and * "mynamespace" is the k8s namespace for the service, and
* "coredns.local" is the zone configured for `kubernetes`. * "coredns.local" is the zone configured for `kubernetes`.
@ -64,7 +64,7 @@ Defaults:
* If the `template` keyword is omitted, the default template of "{service}.{namespace}.{zone}" is used. * If the `template` keyword is omitted, the default template of "{service}.{namespace}.{zone}" is used.
* If the `resyncperiod` keyword is omitted, the default resync period is 5 minutes. * If the `resyncperiod` keyword is omitted, the default resync period is 5 minutes.
* The `labels` keyword is only used when filtering results based on kubernetes label selector syntax * The `labels` keyword is only used when filtering results based on kubernetes label selector syntax
is required. The label selector syntax is described in the kubernetes API documentation at: is required. The label selector syntax is described in the kubernetes API documentation at:
http://kubernetes.io/docs/user-guide/labels/ http://kubernetes.io/docs/user-guide/labels/
### Template syntax ### Template syntax
@ -90,7 +90,7 @@ The kubernetes control client can be downloaded from the generic URL:
For example, the kubectl client for Linux can be downloaded using the command: For example, the kubectl client for Linux can be downloaded using the command:
`curl -sSL "http://storage.googleapis.com/kubernetes-release/release/v1.2.4/bin/linux/amd64/kubectl"` `curl -sSL "http://storage.googleapis.com/kubernetes-release/release/v1.2.4/bin/linux/amd64/kubectl"`
The `contrib/kubernetes/testscripts/10_setup_kubectl.sh` script can be stored in the same directory as The `contrib/kubernetes/testscripts/10_setup_kubectl.sh` script can be stored in the same directory as
kubectl to setup kubectl to communicate with kubernetes running on the localhost. kubectl to setup kubectl to communicate with kubernetes running on the localhost.
@ -111,20 +111,40 @@ $ ./kubectl get service --namespace=demo
~~~ ~~~
The script `contrib/kubernetes/testscripts/20_setup_k8s_services.sh` creates a couple of sample namespaces The script `contrib/kubernetes/testscripts/20_setup_k8s_services.sh` creates a couple of sample namespaces
with services running in those namespaces. The automated kubernetes integration tests in with services running in those namespaces. The automated kubernetes integration tests in
`test/kubernetes_test.go` depend on these services and namespaces to exist in kubernetes. `test/kubernetes_test.go` depend on these services and namespaces to exist in kubernetes.
#### Launch CoreDNS #### Launch CoreDNS
Build CoreDNS and launch using the configuration file in `conf/k8sCorefile`. Build CoreDNS and launch using this configuration file:
This configuration file sets up CoreDNS to use the zone `coredns.local` for
the kubernetes services. ~~~ txt
# Serve on port 53
.:53 {
kubernetes coredns.local {
resyncperiod 5m
endpoint http://localhost:8080
template {service}.{namespace}.{zone}
namespaces demo
# Only expose the records for kubernetes objects
# that matches this label selector.
# See http://kubernetes.io/docs/user-guide/labels/
# Example selector below only exposes objects tagged as
# "application=nginx" in the staging or qa environments.
#labels environment in (staging, qa),application=nginx
}
#cache 180 coredns.local # optionally enable caching
}
~~~
Put it in `~/k8sCorefile` for instance. This configuration file sets up CoreDNS to use the zone
`coredns.local` for the kubernetes services.
The command to launch CoreDNS is: The command to launch CoreDNS is:
~~~ ~~~
$ ./coredns -conf conf/k8sCoreFile $ ./coredns -conf ~/k8sCorefile
~~~ ~~~
In a separate terminal a DNS query can be issued using dig: In a separate terminal a DNS query can be issued using dig:
@ -158,10 +178,10 @@ mynginx.demo.coredns.local. 0 IN A 10.0.0.10
## Implementation Notes/Ideas ## Implementation Notes/Ideas
### Basic Zone Mapping ### Basic Zone Mapping
The middleware is configured with a "zone" string. For The middleware is configured with a "zone" string. For
example: "zone = coredns.local". example: "zone = coredns.local".
The Kubernetes service "myservice" running in "mynamespace" would map The Kubernetes service "myservice" running in "mynamespace" would map
to: "myservice.mynamespace.coredns.local". to: "myservice.mynamespace.coredns.local".
The middleware should publish an A record for that service and a service record. The middleware should publish an A record for that service and a service record.
@ -277,9 +297,9 @@ TBD:
* Improve lookup to reduce size of query result obtained from k8s API. * Improve lookup to reduce size of query result obtained from k8s API.
(namespace-based?, other ideas?) (namespace-based?, other ideas?)
* Additional features: * Additional features:
* Reverse IN-ADDR entries for services. (Is there any value in supporting * Reverse IN-ADDR entries for services. (Is there any value in supporting
reverse lookup records?) (need tests, functionality should work based on @aledbf's code.) reverse lookup records?) (need tests, functionality should work based on @aledbf's code.)
* (done) ~~How to support label specification in Corefile to allow use of labels to * (done) ~~How to support label specification in Corefile to allow use of labels to
indicate zone? For example, the following indicate zone? For example, the following
configuration exposes all services labeled for the "staging" environment configuration exposes all services labeled for the "staging" environment
and tenant "customerB" in the zone "customerB.stage.local": and tenant "customerB" in the zone "customerB.stage.local":