sigs.k8s.io/external-dns@v0.14.1/docs/tutorials/coredns.md (about) 1 # Setting up ExternalDNS for CoreDNS with minikube 2 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). 3 You need to: 4 * install CoreDNS with [etcd](https://github.com/etcd-io/etcd) enabled 5 * install external-dns with coredns as a provider 6 * enable ingress controller for the minikube cluster 7 8 9 ## Creating a cluster 10 ``` 11 minikube start 12 ``` 13 14 ## Installing CoreDNS with etcd enabled 15 Helm chart is used to install etcd and CoreDNS. 16 ### Initializing helm chart 17 ``` 18 helm init 19 ``` 20 ### Installing etcd 21 [etcd operator](https://github.com/coreos/etcd-operator) is used to manage etcd clusters. 22 ``` 23 helm install stable/etcd-operator --name my-etcd-op 24 ``` 25 etcd cluster is installed with example yaml from etcd operator website. 26 ``` 27 kubectl apply -f https://raw.githubusercontent.com/coreos/etcd-operator/HEAD/example/example-etcd-cluster.yaml 28 ``` 29 30 ### Installing CoreDNS 31 In order to make CoreDNS work with etcd backend, values.yaml of the chart should be changed with corresponding configurations. 32 ``` 33 wget https://raw.githubusercontent.com/helm/charts/HEAD/stable/coredns/values.yaml 34 ``` 35 36 You need to edit/patch the file with below diff 37 ```diff 38 diff --git a/values.yaml b/values.yaml 39 index 964e72b..e2fa934 100644 40 --- a/values.yaml 41 +++ b/values.yaml 42 @@ -27,12 +27,12 @@ service: 43 44 rbac: 45 # If true, create & use RBAC resources 46 - create: false 47 + create: true 48 # Ignored if rbac.create is true 49 serviceAccountName: default 50 51 # isClusterService specifies whether chart should be deployed as cluster-service or normal k8s app. 52 -isClusterService: true 53 +isClusterService: false 54 55 servers: 56 - zones: 57 @@ -51,6 +51,12 @@ servers: 58 parameters: 0.0.0.0:9153 59 - name: proxy 60 parameters: . /etc/resolv.conf 61 + - name: etcd 62 + parameters: example.org 63 + configBlock: |- 64 + stubzones 65 + path /skydns 66 + endpoint http://10.105.68.165:2379 67 68 # Complete example with all the options: 69 # - zones: # the `zones` block can be left out entirely, defaults to "." 70 ``` 71 **Note**: 72 * 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. 73 ``` 74 $ kubectl get svc example-etcd-cluster-client 75 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 76 example-etcd-cluster-client ClusterIP 10.105.68.165 <none> 2379/TCP 16m 77 ``` 78 * Parameters should configure your own domain. "example.org" is used in this example. 79 80 81 After configuration done in values.yaml, you can install coredns chart. 82 ``` 83 helm install --name my-coredns --values values.yaml stable/coredns 84 ``` 85 86 ## Installing ExternalDNS 87 ### Install external ExternalDNS 88 ETCD_URLS is configured to etcd client service address. 89 90 #### Manifest (for clusters without RBAC enabled) 91 92 ```yaml 93 apiVersion: apps/v1 94 kind: Deployment 95 metadata: 96 name: external-dns 97 namespace: kube-system 98 spec: 99 strategy: 100 type: Recreate 101 selector: 102 matchLabels: 103 app: external-dns 104 template: 105 metadata: 106 labels: 107 app: external-dns 108 spec: 109 containers: 110 - name: external-dns 111 image: registry.k8s.io/external-dns/external-dns:v0.14.0 112 args: 113 - --source=ingress 114 - --provider=coredns 115 - --log-level=debug # debug only 116 env: 117 - name: ETCD_URLS 118 value: http://10.105.68.165:2379 119 ``` 120 121 #### Manifest (for clusters with RBAC enabled) 122 123 ```yaml 124 --- 125 apiVersion: rbac.authorization.k8s.io/v1 126 kind: ClusterRole 127 metadata: 128 name: external-dns 129 rules: 130 - apiGroups: [""] 131 resources: ["services","endpoints","pods"] 132 verbs: ["get","watch","list"] 133 - apiGroups: ["extensions","networking.k8s.io"] 134 resources: ["ingresses"] 135 verbs: ["get","watch","list"] 136 - apiGroups: [""] 137 resources: ["nodes"] 138 verbs: ["list"] 139 --- 140 apiVersion: rbac.authorization.k8s.io/v1 141 kind: ClusterRoleBinding 142 metadata: 143 name: external-dns-viewer 144 roleRef: 145 apiGroup: rbac.authorization.k8s.io 146 kind: ClusterRole 147 name: external-dns 148 subjects: 149 - kind: ServiceAccount 150 name: external-dns 151 namespace: kube-system 152 --- 153 apiVersion: v1 154 kind: ServiceAccount 155 metadata: 156 name: external-dns 157 namespace: kube-system 158 --- 159 apiVersion: apps/v1 160 kind: Deployment 161 metadata: 162 name: external-dns 163 namespace: kube-system 164 spec: 165 strategy: 166 type: Recreate 167 selector: 168 matchLabels: 169 app: external-dns 170 template: 171 metadata: 172 labels: 173 app: external-dns 174 spec: 175 serviceAccountName: external-dns 176 containers: 177 - name: external-dns 178 image: registry.k8s.io/external-dns/external-dns:v0.14.0 179 args: 180 - --source=ingress 181 - --provider=coredns 182 - --log-level=debug # debug only 183 env: 184 - name: ETCD_URLS 185 value: http://10.105.68.165:2379 186 ``` 187 188 ## Enable the ingress controller 189 You can use the ingress controller in minikube cluster. It needs to enable ingress addon in the cluster. 190 ``` 191 minikube addons enable ingress 192 ``` 193 194 ## Testing ingress example 195 ``` 196 $ cat ingress.yaml 197 apiVersion: networking.k8s.io/v1 198 kind: Ingress 199 metadata: 200 name: nginx 201 spec: 202 ingressClassName: nginx 203 rules: 204 - host: nginx.example.org 205 http: 206 paths: 207 - backend: 208 serviceName: nginx 209 servicePort: 80 210 211 $ kubectl apply -f ingress.yaml 212 ingress.extensions "nginx" created 213 ``` 214 215 216 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. 217 ``` 218 $ kubectl get svc my-coredns-coredns 219 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 220 my-coredns-coredns ClusterIP 10.100.4.143 <none> 53/UDP 12m 221 222 $ kubectl get ingress 223 NAME HOSTS ADDRESS PORTS AGE 224 nginx nginx.example.org 10.0.2.15 80 2m 225 226 $ kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools 227 If you don't see a command prompt, try pressing enter. 228 dnstools# dig @10.100.4.143 nginx.example.org +short 229 10.0.2.15 230 dnstools# 231 ```