| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | # kubernetes
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | *kubernetes* enables reading zone data from a kubernetes cluster. | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | It implements the [spec](https://github.com/kubernetes/dns/blob/master/docs/specification.md) | 
					
						
							|  |  |  | defined for kubernetes DNS-Based service discovery: | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | Service `A` records are constructed as "myservice.mynamespace.svc.coredns.local" where: | 
					
						
							| 
									
										
										
										
											2016-10-10 20:13:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | * "myservice" is the name of the k8s service | 
					
						
							|  |  |  | * "mynamespace" is the k8s namespace for the service, and | 
					
						
							|  |  |  | * "svc" indicates this is a service | 
					
						
							|  |  |  | * "coredns.local" is the zone | 
					
						
							| 
									
										
										
										
											2016-10-10 20:13:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | Pod `A` records are constructed as "1-2-3-4.mynamespace.pod.coredns.local" where: | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | * "1-2-3-4" is derived from the ip address of the pod (1.2.3.4 in this example) | 
					
						
							|  |  |  | * "mynamespace" is the k8s namespace for the service, and | 
					
						
							|  |  |  | * "pod" indicates this is a pod | 
					
						
							|  |  |  | * "coredns.local" is the zone | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | Endpoint `A` records are constructed as "epname.myservice.mynamespace.svc.coredns.local" where: | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | * "epname" is the hostname (or name constructed from IP) of the endpoint | 
					
						
							|  |  |  | * "myservice" is the name of the k8s service that the endpoint serves | 
					
						
							|  |  |  | * "mynamespace" is the k8s namespace for the service, and | 
					
						
							|  |  |  | * "svc" indicates this is a service | 
					
						
							|  |  |  | * "coredns.local" is the zone | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Also supported are PTR and SRV records for services/endpoints. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | ## Syntax
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | This is an example kubernetes configuration block, with all options described: | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | # kubernetes <zone> [<zone>] ...
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Use kubernetes middleware for domain "coredns.local"
 | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | # Reverse domain zones can be defined here (e.g. 0.0.10.in-addr.arpa),
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | # or instead with the "cidrs" option.
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | kubernetes coredns.local { | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# resyncperiod <period> | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	# Kubernetes data API resync period. Default is 5m | 
					
						
							|  |  |  | 	# Example values: 60s, 5m, 1h | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	resyncperiod 5m | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# endpoint <url> | 
					
						
							|  |  |  | 	# | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 	# Use url for a remote k8s API endpoint.  If omitted, it will connect to | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# k8s in-cluster using the cluster service account. | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	endpoint https://k8s-endpoint:8080 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	# tls <cert-filename> <key-filename> <cacert-filename> | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	# The tls cert, key and the CA cert filenanames for remote k8s connection. | 
					
						
							|  |  |  | 	# This option is ignored if connecting in-cluster (i.e. endpoint is not | 
					
						
							|  |  |  | 	# specified). | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	tls cert key cacert | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# namespaces <namespace> [<namespace>] ... | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	# Only expose the k8s namespaces listed.  If this option is omitted | 
					
						
							|  |  |  | 	# all namespaces are exposed | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	namespaces demo | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# lables <expression> [,<expression>] ... | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	# Only expose the records for kubernetes objects | 
					
						
							|  |  |  | 	# that match 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 | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# pods <disabled|insecure|verified> | 
					
						
							|  |  |  | 	# | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 	# Set the mode of responding to pod A record requests. | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# e.g 1-2-3-4.ns.pod.zone.  This option is provided to allow use of | 
					
						
							|  |  |  | 	# SSL certs when connecting directly to pods. | 
					
						
							|  |  |  | 	# Valid values: disabled, verified, insecure | 
					
						
							|  |  |  | 	#  disabled: Do not process pod requests, always returning NXDOMAIN | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 	#  insecure: Always return an A record with IP from request (without | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	#            checking k8s).  This option is is vulnerable to abuse if | 
					
						
							|  |  |  | 	#            used maliciously in conjuction with wildcard SSL certs. | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 	#  verified: Return an A record if there exists a pod in same | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	#            namespace with matching IP.  This option requires | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 	#            substantially more memory than in insecure mode, since it | 
					
						
							|  |  |  | 	#            will maintain a watch on all pods. | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# Default value is "disabled". | 
					
						
							|  |  |  | 	# | 
					
						
							| 
									
										
										
										
											2017-01-15 03:12:28 -05:00
										 |  |  | 	pods disabled | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | 	# cidrs <cidr> [<cidr>] ... | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	# Expose cidr ranges to reverse lookups.  Include any number of space | 
					
						
							|  |  |  | 	# delimited cidrs, and or multiple cidrs options on separate lines. | 
					
						
							|  |  |  | 	# kubernetes middleware will respond to PTR requests for ip addresses | 
					
						
							|  |  |  | 	# that fall within these ranges. | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	cidrs 10.0.0.0/24 10.0.10.0/25 | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-19 17:42:45 -04:00
										 |  |  | 	# fallthrough | 
					
						
							|  |  |  | 	# | 
					
						
							|  |  |  | 	# If a query for a record in the cluster zone results in NXDOMAIN, | 
					
						
							|  |  |  | 	# normally that is what the response will be. However, if you specify | 
					
						
							|  |  |  | 	# this option, the query will instead be passed on down the middleware | 
					
						
							|  |  |  | 	# chain, which can include another middleware to handle the query. | 
					
						
							|  |  |  | 	fallthrough | 
					
						
							| 
									
										
										
										
											2016-08-25 07:35:09 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | ## Wildcards
 | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-06 11:42:59 +00:00
										 |  |  | Some query labels accept a wildcard value to match any value. | 
					
						
							|  |  |  | If a label is a valid wildcard (\*, or the word "any"), then that label will match | 
					
						
							| 
									
										
										
										
											2017-02-02 16:51:42 -05:00
										 |  |  | all values.  The labels that accept wildcards are: | 
					
						
							|  |  |  | * _service_ in an `A` record request: _service_.namespace.svc.zone. | 
					
						
							|  |  |  |    * e.g. `*.ns.svc.myzone.local` | 
					
						
							|  |  |  | * _namespace_ in an `A` record request: service._namespace_.svc.zone. | 
					
						
							|  |  |  |    * e.g. `nginx.*.svc.myzone.local` | 
					
						
							|  |  |  | * _port and/or protocol_ in an `SRV` request: __port_.__protocol_.service.namespace.svc.zone. | 
					
						
							|  |  |  |    * e.g. `_http.*.service.ns.svc.` | 
					
						
							|  |  |  | * multiple wild cards are allowed in a single query. | 
					
						
							|  |  |  |    * e.g. `A` Request `*.*.svc.zone.` or `SRV` request `*.*.*.*.svc.zone.` | 
					
						
							| 
									
										
										
										
											2016-07-07 01:40:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-22 16:44:20 -05:00
										 |  |  | ## Deployment in Kubernetes
 | 
					
						
							| 
									
										
										
										
											2016-07-07 01:40:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-22 16:44:20 -05:00
										 |  |  | See the [deployment](https://github.com/coredns/deployment) repository for details on how | 
					
						
							|  |  |  | to deploy CoreDNS in Kubernetes. |