external

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

k8s_external

Name

k8s_external - resolve load balancer and external IPs from outside kubernetes clusters.

Description

This plugin allows an additional zone to resolve the external IP address(es) of a Kubernetes service. This plugin is only useful if the kubernetes plugin is also loaded.

The plugin uses an external zone to resolve in-cluster IP addresses. It only handles queries for A, AAAA and SRV records, all others result in NODATA responses. To make it a proper DNS zone it handles SOA and NS queries for the apex of the zone.

By default the apex of the zone will look like (assuming the zone used is example.org):

example.org.	5 IN	SOA ns1.dns.example.org. hostmaster.example.org. (
				12345      ; serial
				14400      ; refresh (4 hours)
				3600       ; retry (1 hour)
				604800     ; expire (1 week)
				5          ; minimum (4 hours)
				)
example.org		5 IN	NS ns1.dns.example.org.

ns1.dns.example.org.  5 IN  A    ....
ns1.dns.example.org.  5 IN  AAAA ....

Note we use the dns subdomain to place the records the DNS needs (see the apex directive). Also note the SOA's serial number is static. The IP addresses of the nameserver records are those of the CoreDNS service.

The k8s_external plugin handles the subdomain dns and the apex of the zone by itself, all other queries are resolved to addresses in the cluster.

Syntax

k8s_external [ZONE...]
  • ZONES zones k8s_external should be authoritative for.

If you want to change the apex domain or use a different TTL for the return records you can use this extended syntax.

k8s_external [ZONE...] {
    apex APEX
    ttl TTL
}
  • APEX is the name (DNS label) to use the apex records, defaults to dns.
  • ttl allows you to set a custom TTL for responses. The default is 5 (seconds).

Examples

Enable names under example.org to be resolved to in cluster DNS addresses.

. {
   kubernetes cluster.local
   k8s_external example.org
}

Also See

For some background see resolve external IP address. And A records for services with Load Balancer IP.

Bugs

PTR queries for the reverse zone is not supported.

Documentation

Overview

Package external implements external names for kubernetes clusters.

This plugin only handles three qtypes (except the apex queries, because those are handled differently). We support A, AAAA and SRV request, for all other types we return NODATA or NXDOMAIN depending on the state of the cluster.

A plugin willing to provide these services must implement the Externaler interface, although it likely only makes sense for the *kubernetes* plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type External

type External struct {
	Next  plugin.Handler
	Zones []string
	// contains filtered or unexported fields
}

External resolves Ingress and Loadbalance IPs from kubernetes clusters.

func New

func New() *External

New returns a new and initialized *External.

func (*External) Name

func (e *External) Name() string

Name implements the Handler interface.

func (*External) ServeDNS

func (e *External) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handle interface.

type Externaler

type Externaler interface {
	// External returns a slice of msg.Services that are looked up in the backend and match
	// the request.
	External(request.Request) ([]msg.Service, int)
	// ExternalAddress should return a string slice of addresses for the nameserving endpoint.
	ExternalAddress(state request.Request) []dns.RR
}

Externaler defines the interface that a plugin should implement in order to be used by External.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL