diff --git a/docs/snippets/tutorials/coredns/coredns-groups.yaml b/docs/snippets/tutorials/coredns/coredns-groups.yaml new file mode 100644 index 0000000000..cddc869125 --- /dev/null +++ b/docs/snippets/tutorials/coredns/coredns-groups.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: a + annotations: + external-dns.alpha.kubernetes.io/hostname: a.domain.local + external-dns.alpha.kubernetes.io/coredns-group: "g1" +spec: + type: LoadBalancer +status: + loadBalancer: + ingress: + - ip: 127.0.0.1 +--- +apiVersion: v1 +kind: Service +metadata: + name: b + annotations: + external-dns.alpha.kubernetes.io/hostname: b.domain.local + external-dns.alpha.kubernetes.io/coredns-group: "g1" +spec: + type: LoadBalancer +status: + loadBalancer: + ingress: + - ip: 127.0.0.2 +--- +apiVersion: v1 +kind: Service +metadata: + name: c + annotations: + external-dns.alpha.kubernetes.io/hostname: c.subdom.domain.local + external-dns.alpha.kubernetes.io/coredns-group: "g2" +spec: + type: LoadBalancer +status: + loadBalancer: + ingress: + - ip: 127.0.0.3 +--- +apiVersion: v1 +kind: Service +metadata: + name: d + annotations: + external-dns.alpha.kubernetes.io/hostname: d.subdom.domain.local + external-dns.alpha.kubernetes.io/coredns-group: "g2" +spec: + type: LoadBalancer +status: + loadBalancer: + ingress: + - ip: 127.0.0.4 diff --git a/docs/snippets/tutorials/coredns/etcd.yaml b/docs/snippets/tutorials/coredns/etcd.yaml new file mode 100644 index 0000000000..f7105ca082 --- /dev/null +++ b/docs/snippets/tutorials/coredns/etcd.yaml @@ -0,0 +1,93 @@ +# kubectl apply -f docs/snippets/tutorials/coredns/etcd.yaml +# kubectl delete -f docs/snippets/tutorials/coredns/etcd.yaml +--- +apiVersion: v1 +kind: Service +metadata: + name: etcd + namespace: default +spec: + type: ClusterIP + clusterIP: None + ports: + - name: etcd-client + port: 2379 + - name: etcd-server + port: 2380 + - name: etcd-metrics + port: 8080 + selector: + app: etcd +--- +apiVersion: v1 +kind: Service +metadata: + name: etcd-nodeport-external + namespace: default +spec: + type: NodePort + ports: + - port: 2379 + targetPort: 2379 + nodePort: 32379 # must match kind config port mapping + selector: + app: etcd +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: etcd + namespace: default +spec: + serviceName: etcd + replicas: 1 + selector: + matchLabels: + app: etcd + template: + metadata: + labels: + app: etcd + annotations: + serviceName: etcd + spec: + containers: + - name: etcd + image: quay.io/coreos/etcd:v3.5.15 + command: + - /usr/local/bin/etcd + - --name=$(HOSTNAME) + - --listen-peer-urls=$(URI_SCHEME)://0.0.0.0:2380 + - --listen-client-urls=$(URI_SCHEME)://0.0.0.0:2379 + - --advertise-client-urls=$(URI_SCHEME)://$(HOSTNAME).$(SERVICE_NAME):2379 + - --data-dir=/var/lib/etcd + ports: + - containerPort: 2379 + volumeMounts: + - name: data + mountPath: /var/lib/etcd + env: + - name: K8S_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: HOSTNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: SERVICE_NAME + valueFrom: + fieldRef: + fieldPath: metadata.annotations['serviceName'] + - name: ETCDCTL_ENDPOINTS + value: $(HOSTNAME).$(SERVICE_NAME):2379 + - name: URI_SCHEME + value: "http" + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 50Mi diff --git a/docs/snippets/tutorials/coredns/fixtures.yaml b/docs/snippets/tutorials/coredns/fixtures.yaml new file mode 100644 index 0000000000..3a113218bd --- /dev/null +++ b/docs/snippets/tutorials/coredns/fixtures.yaml @@ -0,0 +1,43 @@ +# kubectl apply -f docs/snippets/tutorials/coredns/fixtures.yaml +# kubectl delete -f docs/snippets/tutorials/coredns/fixtures.yaml +# kubectl get svc -l svc=test-svc +--- +apiVersion: v1 +kind: Service +metadata: + name: a-g1-record + labels: + svc: test-svc + annotations: + external-dns.alpha.kubernetes.io/hostname: a.example.org + external-dns.alpha.kubernetes.io/coredns-group: "g1" + cluster-name: "cluster1" + namespace: default +spec: + type: LoadBalancer + ports: + - port: 80 + name: http + targetPort: 80 + selector: + app: test-app +--- +apiVersion: v1 +kind: Service +metadata: + name: aa-g1-record + labels: + svc: test-svc + annotations: + external-dns.alpha.kubernetes.io/hostname: aa.example.org + external-dns.alpha.kubernetes.io/coredns-group: "g1" + cluster-name: "cluster1" + namespace: default +spec: + type: LoadBalancer + ports: + - port: 80 + name: http + targetPort: 80 + selector: + app: test-app diff --git a/docs/snippets/tutorials/coredns/kind.yaml b/docs/snippets/tutorials/coredns/kind.yaml new file mode 100644 index 0000000000..dba7b308e7 --- /dev/null +++ b/docs/snippets/tutorials/coredns/kind.yaml @@ -0,0 +1,38 @@ +# ref: https://kind.sigs.k8s.io/docs/user/quick-start/ +# https://kind.sigs.k8s.io/docs/user/configuration/#extra-port-mappings + +# kind create cluster --config=docs/snippets/tutorials/coredns/kind.yaml +# kind delete cluster --name coredns-etcd +# kubectl cluster-info --context kind-coredns-etcd +# kubectl get nodes -o wide +--- +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +name: coredns-etcd +networking: + apiServerAddress: 127.0.0.1 + apiServerPort: 6443 +nodes: +- role: control-plane + image: kindest/node:v1.33.0 + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 80 + hostPort: 8080 + listenAddress: "0.0.0.0" + protocol: TCP + - containerPort: 43 + hostPort: 4443 + listenAddress: "0.0.0.0" + protocol: TCP + - containerPort: 32379 # inside kind node + hostPort: 32379 # exposed on host + listenAddress: "0.0.0.0" + protocol: TCP +- role: worker + image: kindest/node:v1.33.0 diff --git a/docs/snippets/tutorials/coredns/values-coredns.yaml b/docs/snippets/tutorials/coredns/values-coredns.yaml new file mode 100644 index 0000000000..b03f8ea8a8 --- /dev/null +++ b/docs/snippets/tutorials/coredns/values-coredns.yaml @@ -0,0 +1,53 @@ +# kubectl logs deploy/coredns -n default -c coredns +# ref: https://github.com/coredns/helm/blob/master/charts/coredns/values.yaml +isClusterService: false + +service: + name: coredns + port: 53 + annotations: {} + clusterIP: "" + +# Main customization +servers: + - zones: + - zone: . + port: 53 + plugins: + - name: errors + - name: debug # <── enables debug mode + - name: health + configBlock: |- + lameduck 5s + - name: ready + # to query kubernetes API for data + - name: kubernetes + parameters: cluster.local 10.0.0.0/24 + configBlock: |- + pods insecure + fallthrough in-addr.arpa ip6.arpa + ttl 30 + - name: etcd + parameters: "example.org" + configBlock: | + stubzones + path /skydns + endpoint http://etcd.default.svc.cluster.local:2379 + fallthrough + - name: log # <── log each DNS query + - name: forward + parameters: ". /etc/resolv.conf" + - name: cache + parameters: 30 + - name: reload + - name: loop + - name: loadbalance + +replicaCount: 1 + +# required to debug DNS resolution from within CoreDNS pods +# kubectl logs deploy/coredns -n default -c resolv-check --tail=50 +initContainers: + - name: resolv-check + image: busybox:1.37 + command: ["sh", "-c", "echo '--- /etc/resolv.conf ---'; cat /etc/resolv.conf; echo '---------------------------'; nslookup kubernetes.default.svc.cluster.local || true; sleep 5"] diff --git a/docs/snippets/tutorials/coredns/values-extdns-coredns.yaml b/docs/snippets/tutorials/coredns/values-extdns-coredns.yaml new file mode 100644 index 0000000000..f0543a8ffa --- /dev/null +++ b/docs/snippets/tutorials/coredns/values-extdns-coredns.yaml @@ -0,0 +1,39 @@ + +# ref: https://github.com/kubernetes-sigs/external-dns/blob/master/charts/external-dns/values.yaml +provider: + name: coredns + +env: + - name: ETCD_URLS + value: "http://etcd.default.svc.cluster.local:2379" + + +txtOwnerId: cluster1 +# Filter resources queried for endpoints by annotation, using label selector semantics +annotationFilter: cluster-name=cluster1 + +domainFilters: + - example.org + +# Sources define what ExternalDNS will use to discover endpoints +sources: + - service + +# Policy options +policy: sync + +logLevel: debug +interval: 1m + +# RBAC configuration +rbac: + create: true + +# Optional: tune resource requests +resources: + requests: + cpu: 100m + memory: 64Mi + limits: + cpu: 200m + memory: 128Mi diff --git a/docs/tutorials/coredns-etcd.md b/docs/tutorials/coredns-etcd.md new file mode 100644 index 0000000000..8f8ee0db99 --- /dev/null +++ b/docs/tutorials/coredns-etcd.md @@ -0,0 +1,254 @@ +# CoreDNS with etcd backend + +## Overview + +This tutorial describes how to deploy CoreDNS backed by etcd as a dynamic DNS provider for external-dns. +It shows how to configure external-dns to write DNS records into etcd, which CoreDNS will then serve. + +### TL;DR + +After completing this lab, you will have a Kubernetes environment running as containers in your local development machine with etcd, coredns and external-dns. + +### Notes + +- `CoreDNS` and etcd here run inside the cluster for demonstration purposes. +- For real deployments, you can use external etcd or secure etcd with TLS. +- The zone example.org is arbitrary — use your domain. +- `external-dns` automatically maintains records in etcd under `/skydns/`. + +## Prerequisite + +Before you start, ensure you have: + +- A running kubernetes cluster. + - In this tutorial we are going to use [kind](https://kind.sigs.k8s.io/) +- [`kubectl`](https://kubernetes.io/docs/tasks/tools/) and [`helm`](https://helm.sh/) +- `external-dns` source code or [helm chart](https://github.com/kubernetes-sigs/external-dns/tree/master/charts/external-dns) +- `CoreDNS` [helm chart](https://github.com/coredns/helm) +- Optional + - `dnstools` container for testing + - `etcdctl` to interat with [etcd](https://etcd.io/docs/v3.4/dev-guide/interacting_v3/) + +## Bootstrap Environment + +### 1. Create cluster + +```sh +kind create cluster --config=docs/snippets/tutorials/coredns/kind.yaml + +Creating cluster "coredns-etcd" ... + ✓ Ensuring node image (kindest/node:v1.33.0) 🖼 + ✓ Preparing nodes 📦 📦 + ✓ Writing configuration 📜 + ✓ Starting control-plane 🕹️ + ✓ Installing CNI 🔌 + ✓ Installing StorageClass 💾 + ✓ Joining worker nodes 🚜 +Set kubectl context to "kind-coredns-etcd" +You can now use your cluster with: + +kubectl cluster-info --context kind-coredns-etcd +``` + +### 2. Deploy etcd as stateful set + +There are multiple options to configure etcd + +1. With custom manifest. +2. ETCD [manifest](https://etcd.io/docs/v3.6/op-guide/kubernetes/) +3. ETCD [operator](https://github.com/etcd-io/etcd-operator) + +In this tutorial, we'll use the first option. + +```sh +# apply custom manifest from external-dns repository +kubectl apply -f docs/snippets/tutorials/coredns/etcd.yaml +# wait until it's ready +kubectl rollout status statefulset etcd + +❯❯ partitioned roll out complete: 1 new pods have been updated... +``` + +Test etcd connectivity: + +```sh +kubectl exec -it etcd-0 -- etcdctl member list -wtable + ++------------------+---------+--------+------------------------+-------------------------+------------+ +| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | ++------------------+---------+--------+------------------------+-------------------------+------------+ +| 3b3ae05f90cfc535 | started | etcd-0 | http://10.244.1.3:2380 | http://etcd-0.etcd:2379 | false | ++------------------+---------+--------+------------------------+-------------------------+------------+ +``` + +Test etcd record management: + +```sh +kubectl -n default exec -it etcd-0 -- etcdctl put /skydns/org/example/myservice '{"host":"10.0.0.10"}' +❯❯ OK + +kubectl -n default exec -it etcd-0 -- etcdctl get /skydns --prefix +❯❯ /skydns/org/example/myservice +❯❯ {"host":"10.0.0.10"} + +kubectl -n default exec -it etcd-0 -- etcdctl del /skydns/org/example/myservice +❯❯ 1 +``` + +To access etcd from host: + +```sh +etcdctl --endpoints=http://127.0.0.1:32379 member list +❯❯ 3b3ae05f90cfc535, started, etcd-0, http://10.244.1.3:2380, http://etcd-0.etcd:2379, false +``` + +### 3. Deploy CoreDNS using Helm + +- [CoreDNS](https://github.com/coredns/coredns) +- [CoreDNS helm](https://github.com/coredns/helm) + +```sh +helm repo add coredns https://coredns.github.io/helm +helm repo update + +helm upgrade --install coredns coredns/coredns \ + -f docs/snippets/tutorials/coredns/values-coredns.yaml \ + -n default + +❯❯ Release "coredns" does not exist. Installing it now. +``` + +Validate it's running + +```sh +kubectl get pods -l app.kubernetes.io/name=coredns +``` + +Check the logs for errors + +```sh +kubectl logs deploy/coredns -n default -c coredns --tail=50 +kubectl logs deploy/coredns -n default -c resolv-check --tail=50 +``` + +Test DNS Resolution + +```sh +kubectl run -it --rm dnsutils --image=infoblox/dnstools + +❯❯ curl -v http://etcd.default.svc.cluster.local:2379/version +❯❯ dig @coredns.default.svc.cluster.local kubernetes.default.svc.cluster.local +❯❯ dig @coredns.default.svc.cluster.local etcd.default.svc.cluster.local +``` + +### 3. Configure ExternalDNS + +Deploy with helm and minimal configuration. + +Add the `external-dns` helm repository and check available versions + +```sh +helm repo add external-dns https://kubernetes-sigs.github.io/external-dns/ +helm repo update +helm search repo external-dns --versions +``` + +Install with required configuration + +```sh +helm upgrade --install external-dns external-dns/external-dns \ + -f docs/snippets/tutorials/coredns/values-extdns-coredns.yaml \ + -n default + +❯❯ Release "external-dns" does not exist. Installing it now. +``` + +Validate pod status and view logs + +```sh +kubectl get pods -l app.kubernetes.io/name=external-dns + +kubectl logs deploy/external-dns +``` + +Or run it on the host from sources + +```sh +export ETCD_URLS="http://127.0.0.1:32379" # port mapping configured on kind cluster + +go run main.go \ + --provider=coredns \ + --source=service \ + --log-level=debug +``` + +### 3. Configure Test Services + +Apply manifest + +```sh +kubectl apply -f docs/snippets/tutorials/coredns/fixtures.yaml + +kubectl get svc -l svc=test-svc + +❯❯ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +❯❯ a-g1-record LoadBalancer 10.96.233.133 80:31188/TCP 3m38s +❯❯ aa-g1-record LoadBalancer 10.96.93.4 80:31710/TCP 3m38s +``` + +Patch services, to manually assign an Ingress IPs. It just makes the Service appear like a real LoadBalancer for tools/tests. + +```sh +kubectl patch svc a-g1-record --type=merge \ + -p '{"status":{"loadBalancer":{"ingress":[{"ip":"172.18.0.2"}]}}}' \ + --subresource=status +❯❯ service/a-g1-record patched + +kubectl patch svc aa-g1-record --type=merge \ + -p '{"status":{"loadBalancer":{"ingress":[{"ip":"2001:db8::1"}]}}}' \ + --subresource=status +❯❯ service/aa-g1-record patched + +kubectl get svc -l svc=test-svc + +❯❯ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +❯❯ a-g1-record LoadBalancer 10.96.233.133 172.18.0.2 80:31188/TCP 7m13s +❯❯ aa-g1-record LoadBalancer 10.96.93.4 2001:db8::1 80:31710/TCP 7m13s +``` + +### 4. Verify that records are written to etcd + +Check `etcd` content. Where you should see keys similar to: + +```sh +kubectl exec -it etcd-0 -- etcdctl get /skydns/org/example --prefix --keys-only + +❯❯ /skydns/org/example/a-a/1acbad7e +❯❯ /skydns/org/example/a/048b0377 +❯❯ /skydns/org/example/aa/2b981607 +❯❯ /skydns/org/example/aaaa-aa/1228708f +``` + +### 5. Test DNS resolution via CoreDNS + +Launch a debug pod: + +```sh +kubectl run --rm -it dnsutils --image=infoblox/dnstools --restart=Never +``` + +Run with expected output + +```sh +dig +short @coredns.default.svc.cluster.local a.example.org +❯❯ 172.18.0.2 + +dig +short @coredns.default.svc.cluster.local aa.example.org AAAA +❯❯ 2001:db8::1 +``` + +### 6. Cleanup + +```sh +kind delete cluster --name coredns-etcd +``` diff --git a/docs/tutorials/coredns.md b/docs/tutorials/coredns.md index 08bc38c30e..63e63358e6 100644 --- a/docs/tutorials/coredns.md +++ b/docs/tutorials/coredns.md @@ -1,265 +1,6 @@ -# CoreDNS with minikube +# CoreDNS -:warning: This tutorial is out of date. - -:information_source: PRs to update it are welcome ! - -This tutorial describes how to setup ExternalDNS for usage within a [minikube](https://github.com/kubernetes/minikube) cluster that makes use of [CoreDNS](https://github.com/coredns/coredns) and [nginx ingress controller](https://github.com/kubernetes/ingress-nginx). - -You need to: - -* install CoreDNS with [etcd](https://github.com/etcd-io/etcd) enabled -* install external-dns with coredns as a provider -* enable ingress controller for the minikube cluster - -## Creating a cluster - -```shell -minikube start -``` - -## Installing CoreDNS with etcd enabled - -Helm chart is used to install etcd and CoreDNS. - -### Initializing helm chart - -```shell -helm init -``` - -### Installing etcd - -[etcd operator](https://github.com/coreos/etcd-operator) is used to manage etcd clusters. - -```sh -helm install stable/etcd-operator --name my-etcd-op -``` - -etcd cluster is installed with example yaml from etcd operator website. - -```shell -kubectl apply -f https://raw.githubusercontent.com/coreos/etcd-operator/HEAD/example/example-etcd-cluster.yaml -``` - -### Installing CoreDNS - -In order to make CoreDNS work with etcd backend, values.yaml of the chart should be changed with corresponding configurations. - -```sh -wget https://raw.githubusercontent.com/helm/charts/HEAD/stable/coredns/values.yaml -``` - -You need to edit/patch the file with below diff - -```diff -diff --git a/values.yaml b/values.yaml -index 964e72b..e2fa934 100644 ---- a/values.yaml -+++ b/values.yaml -@@ -27,12 +27,12 @@ service: - - rbac: - # If true, create & use RBAC resources -- create: false -+ create: true - # Ignored if rbac.create is true - serviceAccountName: default - - # isClusterService specifies whether chart should be deployed as cluster-service or normal k8s app. --isClusterService: true -+isClusterService: false - - servers: - - zones: -@@ -51,6 +51,12 @@ servers: - parameters: 0.0.0.0:9153 - - name: proxy - parameters: . /etc/resolv.conf -+ - name: etcd -+ parameters: example.org -+ configBlock: |- -+ stubzones -+ path /skydns -+ endpoint http://10.105.68.165:2379 - - # Complete example with all the options: - # - zones: # the `zones` block can be left out entirely, defaults to "." -``` - -**Note**: - -* IP address of etcd's endpoint should be get from etcd client service. It should be "example-etcd-cluster-client" in this example. This IP address is used through this document for etcd endpoint configuration. - -```shell -$ kubectl get svc example-etcd-cluster-client -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -example-etcd-cluster-client ClusterIP 10.105.68.165 2379/TCP 16m -``` - -* Parameters should configure your own domain. "example.org" is used in this example. - -After configuration done in values.yaml, you can install coredns chart. - -```shell -helm install --name my-coredns --values values.yaml stable/coredns -``` - -## Installing ExternalDNS - -### Install external ExternalDNS - -ETCD_URLS is configured to etcd client service address. -Optionally, you can configure ETCD_USERNAME and ETCD_PASSWORD for authenticating to etcd. It is also possible to connect to the etcd cluster via HTTPS using the following environment variables: ETCD_CA_FILE, ETCD_CERT_FILE, ETCD_KEY_FILE, ETCD_TLS_SERVER_NAME, ETCD_TLS_INSECURE. - -#### Manifest (for clusters without RBAC enabled) - -```yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: external-dns - namespace: kube-system -spec: - strategy: - type: Recreate - selector: - matchLabels: - app: external-dns - template: - metadata: - labels: - app: external-dns - spec: - containers: - - name: external-dns - image: registry.k8s.io/external-dns/external-dns:v0.19.0 - args: - - --source=ingress - - --provider=coredns - - --log-level=debug # debug only - env: - - name: ETCD_URLS - value: http://10.105.68.165:2379 -``` - -#### Manifest (for clusters with RBAC enabled) - -```yaml ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: external-dns -rules: -- apiGroups: [""] - resources: ["services","pods"] - verbs: ["get","watch","list"] -- apiGroups: ["discovery.k8s.io"] - resources: ["endpointslices"] - verbs: ["get","watch","list"] -- apiGroups: ["extensions","networking.k8s.io"] - resources: ["ingresses"] - verbs: ["get","watch","list"] -- apiGroups: [""] - resources: ["nodes"] - verbs: ["list"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: external-dns-viewer -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: external-dns -subjects: -- kind: ServiceAccount - name: external-dns - namespace: kube-system ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: external-dns - namespace: kube-system ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: external-dns - namespace: kube-system -spec: - strategy: - type: Recreate - selector: - matchLabels: - app: external-dns - template: - metadata: - labels: - app: external-dns - spec: - serviceAccountName: external-dns - containers: - - name: external-dns - image: registry.k8s.io/external-dns/external-dns:v0.19.0 - args: - - --source=ingress - - --provider=coredns - - --log-level=debug # debug only - env: - - name: ETCD_URLS - value: http://10.105.68.165:2379 -``` - -## Enable the ingress controller - -You can use the ingress controller in minikube cluster. It needs to enable ingress addon in the cluster. - -```shell -minikube addons enable ingress -``` - -## Testing ingress example - -```shell -$ cat ingress.yaml -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: nginx -spec: - ingressClassName: nginx - rules: - - host: nginx.example.org - http: - paths: - - backend: - serviceName: nginx - servicePort: 80 - -$ kubectl apply -f ingress.yaml -ingress.extensions "nginx" created -``` - -Wait a moment until DNS has the ingress IP. The DNS service IP is from CoreDNS service. It is "my-coredns-coredns" in this example. - -```shell -$ kubectl get svc my-coredns-coredns -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -my-coredns-coredns ClusterIP 10.100.4.143 53/UDP 12m - -$ kubectl get ingress -NAME HOSTS ADDRESS PORTS AGE -nginx nginx.example.org 10.0.2.15 80 2m - -$ kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools -If you don't see a command prompt, try pressing enter. -dnstools# dig @10.100.4.143 nginx.example.org +short -10.0.2.15 -dnstools# -``` +- [Documentation](https://coredns.io/) ## Specific service annotation options @@ -269,66 +10,7 @@ Groups can be used to group set of services together. The main use of this is to i.e. don't return all records, but only a subset. Let's say we have a configuration like this: ```yaml -apiVersion: v1 -kind: Service -metadata: - name: a - annotations: - external-dns.alpha.kubernetes.io/hostname: a.domain.local - external-dns.alpha.kubernetes.io/coredns-group: "g1" -spec: - type: LoadBalancer - ... -status: - loadBalancer: - ingress: - - ip: 127.0.0.1 ---- -apiVersion: v1 -kind: Service -metadata: - name: b - annotations: - external-dns.alpha.kubernetes.io/hostname: b.domain.local - external-dns.alpha.kubernetes.io/coredns-group: "g1" -spec: - type: LoadBalancer - ... -status: - loadBalancer: - ingress: - - ip: 127.0.0.2 ---- -apiVersion: v1 -kind: Service -metadata: - name: c - annotations: - external-dns.alpha.kubernetes.io/hostname: c.subdom.domain.local - external-dns.alpha.kubernetes.io/coredns-group: "g2" -spec: - type: LoadBalancer - ... -status: - loadBalancer: - ingress: - - ip: 127.0.0.3 ---- -apiVersion: v1 -kind: Service -metadata: - name: d - annotations: - external-dns.alpha.kubernetes.io/hostname: d.subdom.domain.local - external-dns.alpha.kubernetes.io/coredns-group: "g2" -spec: - type: LoadBalancer - ... -status: - loadBalancer: - ingress: - - ip: 127.0.0.4 - +[[% include 'tutorials/coredns/coredns-groups.yaml' %]] ``` And we want domain.local to return (127.0.0.1 and 127.0.0.2) and subdom.domain.local to return (127.0.0.3 and 127.0.0.4).