2017-03-14 18:44:53 +00:00
|
|
|
---
|
2017-06-08 21:42:56 +00:00
|
|
|
title: Set up CoreDNS as DNS provider for Cluster Federation
|
2018-05-05 16:00:51 +00:00
|
|
|
content_template: templates/tutorial
|
2017-03-14 18:44:53 +00:00
|
|
|
---
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture overview %}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{< include "federation-current-state.md" >}}
|
2018-04-26 19:49:29 +00:00
|
|
|
|
2017-03-14 18:44:53 +00:00
|
|
|
This page shows how to configure and deploy CoreDNS to be used as the
|
|
|
|
DNS provider for Cluster Federation.
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture objectives %}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
* Configure and deploy CoreDNS server
|
2017-08-18 06:35:28 +00:00
|
|
|
* Bring up federation with CoreDNS as dns provider
|
2017-03-14 18:44:53 +00:00
|
|
|
* Setup CoreDNS server in nameserver lookup chain
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture prerequisites %}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
2017-09-01 21:35:40 +00:00
|
|
|
* You need to have a running Kubernetes cluster (which is
|
2017-03-14 18:44:53 +00:00
|
|
|
referenced as host cluster). Please see one of the
|
2017-10-10 02:17:59 +00:00
|
|
|
[getting started](/docs/setup/) guides for
|
2017-03-14 18:44:53 +00:00
|
|
|
installation instructions for your platform.
|
2017-09-01 21:35:40 +00:00
|
|
|
* Support for `LoadBalancer` services in member clusters of federation is
|
|
|
|
mandatory to enable `CoreDNS` for service discovery across federated clusters.
|
2017-03-14 18:44:53 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture lessoncontent %}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
## Deploying CoreDNS and etcd charts
|
|
|
|
|
|
|
|
CoreDNS can be deployed in various configurations. Explained below is a
|
|
|
|
reference and can be tweaked to suit the needs of the platform and the
|
|
|
|
cluster federation.
|
|
|
|
|
|
|
|
To deploy CoreDNS, we shall make use of helm charts. CoreDNS will be
|
|
|
|
deployed with [etcd](https://coreos.com/etcd) as the backend and should
|
|
|
|
be pre-installed. etcd can also be deployed using helm charts. Shown
|
|
|
|
below are the instructions to deploy etcd.
|
|
|
|
|
|
|
|
helm install --namespace my-namespace --name etcd-operator stable/etcd-operator
|
|
|
|
helm upgrade --namespace my-namespace --set cluster.enabled=true etcd-operator stable/etcd-operator
|
|
|
|
|
|
|
|
*Note: etcd default deployment configurations can be overridden, suiting the
|
|
|
|
host cluster.*
|
|
|
|
|
|
|
|
After deployment succeeds, etcd can be accessed with the
|
|
|
|
[http://etcd-cluster.my-namespace:2379](http://etcd-cluster.my-namespace:2379) endpoint within the host cluster.
|
|
|
|
|
|
|
|
The CoreDNS default configuration should be customized to suit the federation.
|
|
|
|
Shown below is the Values.yaml, which overrides the default
|
|
|
|
configuration parameters on the CoreDNS chart.
|
|
|
|
|
2018-07-10 16:09:26 +00:00
|
|
|
```yaml
|
|
|
|
isClusterService: false
|
|
|
|
serviceType: "LoadBalancer"
|
|
|
|
plugins:
|
|
|
|
kubernetes:
|
|
|
|
enabled: false
|
|
|
|
etcd:
|
|
|
|
enabled: true
|
|
|
|
zones:
|
|
|
|
- "example.com."
|
|
|
|
endpoint: "http://etcd-cluster.my-namespace:2379"
|
|
|
|
```
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
The above configuration file needs some explanation:
|
|
|
|
|
|
|
|
- `isClusterService` specifies whether CoreDNS should be deployed as a
|
|
|
|
cluster-service, which is the default. You need to set it to false, so
|
|
|
|
that CoreDNS is deployed as a Kubernetes application service.
|
|
|
|
- `serviceType` specifies the type of Kubernetes service to be created
|
|
|
|
for CoreDNS. You need to choose either "LoadBalancer" or "NodePort" to
|
|
|
|
make the CoreDNS service accessible outside the Kubernetes cluster.
|
2018-06-15 20:16:29 +00:00
|
|
|
- Disable `plugins.kubernetes`, which is enabled by default by
|
|
|
|
setting `plugins.kubernetes.enabled` to false.
|
|
|
|
- Enable `plugins.etcd` by setting `plugins.etcd.enabled` to
|
2017-03-14 18:44:53 +00:00
|
|
|
true.
|
|
|
|
- Configure the DNS zone (federation domain) for which CoreDNS is
|
2018-06-15 20:16:29 +00:00
|
|
|
authoritative by setting `plugins.etcd.zones` as shown above.
|
2017-03-14 18:44:53 +00:00
|
|
|
- Configure the etcd endpoint which was deployed earlier by setting
|
2018-06-15 20:16:29 +00:00
|
|
|
`plugins.etcd.endpoint`
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
Now deploy CoreDNS by running
|
|
|
|
|
|
|
|
helm install --namespace my-namespace --name coredns -f Values.yaml stable/coredns
|
|
|
|
|
|
|
|
Verify that both etcd and CoreDNS pods are running as expected.
|
|
|
|
|
|
|
|
|
|
|
|
## Deploying Federation with CoreDNS as DNS provider
|
|
|
|
|
|
|
|
The Federation control plane can be deployed using `kubefed init`. CoreDNS
|
|
|
|
can be chosen as the DNS provider by specifying two additional parameters.
|
|
|
|
|
|
|
|
--dns-provider=coredns
|
|
|
|
--dns-provider-config=coredns-provider.conf
|
|
|
|
|
|
|
|
coredns-provider.conf has below format:
|
|
|
|
|
|
|
|
[Global]
|
|
|
|
etcd-endpoints = http://etcd-cluster.my-namespace:2379
|
|
|
|
zones = example.com.
|
2017-06-06 07:30:47 +00:00
|
|
|
coredns-endpoints = <coredns-server-ip>:<port>
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
- `etcd-endpoints` is the endpoint to access etcd.
|
|
|
|
- `zones` is the federation domain for which CoreDNS is authoritative and is same as --dns-zone-name flag of `kubefed init`.
|
2017-08-14 10:57:49 +00:00
|
|
|
- `coredns-endpoints` is the endpoint to access CoreDNS server. This is an optional parameter introduced from v1.7 onwards.
|
2017-03-14 18:44:53 +00:00
|
|
|
|
2018-06-15 20:16:29 +00:00
|
|
|
{{< note >}}**Note**: *plugins.etcd.zones in CoreDNS configuration and --dns-zone-name flag to kubefed init should match.*{{< /note >}}
|
2017-03-14 18:44:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Setup CoreDNS server in nameserver resolv.conf chain
|
|
|
|
|
2017-06-21 22:51:31 +00:00
|
|
|
*Note: The following section applies only to versions prior to v1.7
|
|
|
|
and will be automatically taken care of if the `coredns-endpoints`
|
|
|
|
parameter is configured in `coredns-provider.conf` as described in
|
|
|
|
section above.*
|
2017-06-06 07:30:47 +00:00
|
|
|
|
2017-03-14 18:44:53 +00:00
|
|
|
Once the federation control plane is deployed and federated clusters
|
|
|
|
are joined to the federation, you need to add the CoreDNS server to the
|
|
|
|
pod's nameserver resolv.conf chain in all the federated clusters as this
|
|
|
|
self hosted CoreDNS server is not discoverable publicly. This can be
|
|
|
|
achieved by adding the below line to `dnsmasq` container's arg in
|
|
|
|
`kube-dns` deployment.
|
|
|
|
|
|
|
|
--server=/example.com./<CoreDNS endpoint>
|
|
|
|
|
|
|
|
Replace `example.com` above with federation domain.
|
|
|
|
|
|
|
|
|
|
|
|
Now the federated cluster is ready for cross-cluster service discovery!
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
|
|
|
|
2017-03-14 18:44:53 +00:00
|
|
|
|