2019-08-30 15:58:25 +01:00
. \" Generated by Mmark Markdown Processer - mmark.miek.nl
2021-03-08 11:15:45 +00:00
.TH "COREDNS-K8S_EXTERNAL" 7 "March 2021" "CoreDNS" "CoreDNS Plugins"
2019-04-06 08:42:40 +01:00
2019-06-24 12:37:27 +01:00
.SH "NAME"
2019-04-06 08:42:40 +01:00
.PP
2019-09-27 13:30:22 +01:00
\fI k8s_external\fP - resolves load balancer and external IPs from outside Kubernetes clusters.
2019-04-06 08:42:40 +01:00
2019-06-24 12:37:27 +01:00
.SH "DESCRIPTION"
2019-04-06 08:42:40 +01:00
.PP
This plugin allows an additional zone to resolve the external IP address(es) of a Kubernetes
service. This plugin is only useful if the \fI kubernetes\fP plugin is also loaded.
.PP
The plugin uses an external zone to resolve in-cluster IP addresses. It only handles queries for A,
2019-08-30 15:58:25 +01:00
AAAA and SRV records; all others result in NODATA responses. To make it a proper DNS zone, it handles
2019-04-06 08:42:40 +01:00
SOA and NS queries for the apex of the zone.
.PP
2019-08-30 15:58:25 +01:00
By default the apex of the zone will look like the following (assuming the zone used is \fB \fC example.org\fR ):
2019-04-06 08:42:40 +01:00
.PP
.RS
2018-12-16 21:48:37 +00:00
.nf
2019-09-27 13:30:22 +01:00
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.
2019-04-06 08:42:40 +01:00
ns1.dns.example.org. 5 IN A ....
ns1.dns.example.org. 5 IN AAAA ....
2018-12-16 21:48:37 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
.PP
2019-08-30 15:58:25 +01:00
Note that we use the \fB \fC dns\fR subdomain for the records DNS needs (see the \fB \fC apex\fR directive). Also
2019-04-06 08:42:40 +01:00
note the SOA's serial number is static. The IP addresses of the nameserver records are those of the
CoreDNS service.
.PP
2019-08-30 15:58:25 +01:00
The \fI k8s_external\fP plugin handles the subdomain \fB \fC dns\fR and the apex of the zone itself; all other
2019-04-06 08:42:40 +01:00
queries are resolved to addresses in the cluster.
2019-06-24 12:37:27 +01:00
.SH "SYNTAX"
2019-04-06 08:42:40 +01:00
.PP
.RS
2018-12-16 21:48:37 +00:00
.nf
2019-04-06 08:42:40 +01:00
k8s\_ external [ZONE...]
2018-12-16 21:48:37 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
.IP \(bu 4
\fB ZONES\fP zones \fI k8s_external\fP should be authoritative for.
2018-12-16 21:48:37 +00:00
2019-04-06 08:42:40 +01:00
.PP
2019-08-30 15:58:25 +01:00
If you want to change the apex domain or use a different TTL for the returned records you can use
2019-04-06 08:42:40 +01:00
this extended syntax.
.PP
.RS
.nf
k8s\_ external [ZONE...] {
2018-12-16 21:48:37 +00:00
apex APEX
ttl TTL
}
2019-04-06 08:42:40 +01:00
2018-12-16 21:48:37 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
.IP \(bu 4
2019-08-30 15:58:25 +01:00
\fB APEX\fP is the name (DNS label) to use for the apex records; it defaults to \fB \fC dns\fR .
2019-04-06 08:42:40 +01:00
.IP \(bu 4
\fB \fC ttl\fR allows you to set a custom \fB TTL\fP for responses. The default is 5 (seconds).
2018-12-16 21:48:37 +00:00
2020-03-06 11:11:45 +00:00
.SH "EXAMPLES"
2019-04-06 08:42:40 +01:00
.PP
2019-08-30 15:58:25 +01:00
Enable names under \fB \fC example.org\fR to be resolved to in-cluster DNS addresses.
2019-04-06 08:42:40 +01:00
.PP
.RS
.nf
\& . {
kubernetes cluster.local
k8s\_ external example.org
2018-12-16 21:48:37 +00:00
}
2019-04-06 08:42:40 +01:00
2018-12-16 21:48:37 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
2019-07-03 19:47:38 +01:00
.PP
2019-08-30 15:58:25 +01:00
With the Corefile above, the following Service will get an \fB \fC A\fR record for \fB \fC test.default.example.org\fR with the IP address \fB \fC 192.168.200.123\fR .
2019-07-03 19:47:38 +01:00
.PP
.RS
.nf
apiVersion: v1
kind: Service
metadata:
name: test
namespace: default
spec:
clusterIP: None
externalIPs:
\- 192.168.200.123
type: ClusterIP
.fi
.RE
2019-04-06 08:42:40 +01:00
.PP
For some background see resolve external IP address
\[ la]https://github.com/kubernetes/dns/issues/242\[ ra].
And A records for services with Load Balancer IP
\[ la]https://github.com/coredns/coredns/issues/1851\[ ra].
.PP
PTR queries for the reverse zone is not supported.