You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Bump container images to v0.13.1
* Add example with kubernetes service and `external-dns.alpha.kubernetes.io/hostname` annotation
* Add example with `external-dns.alpha.kubernetes.io/internal-hostname`
* Add example used in combination with `service.beta.kubernetes.io/azure-load-balancer-internal`
The parameter `controller.publishService.enabled` needs to be set to `true.`
32
-
33
-
It will make the ingress controller update the endpoint records of ingress-resources to contain the external-ip of the loadbalancer serving the ingress-controller.
34
-
This is crucial as ExternalDNS reads those endpoints records when creating DNS-Records from ingress-resources.
35
-
In the subsequent parameter we will make use of this. If you don't want to work with ingress-resources in your later use, you can leave the parameter out.
36
-
37
-
Verify the correct propagation of the loadbalancer's ip by listing the ingresses.
38
-
39
-
```
40
-
$ kubectl get ingress
41
-
```
42
-
43
-
The address column should contain the ip for each ingress. ExternalDNS will pick up exactly this piece of information.
44
-
45
-
```
46
-
NAME HOSTS ADDRESS PORTS AGE
47
-
nginx1 sample1.aks.com 52.167.195.110 80 6d22h
48
-
nginx2 sample2.aks.com 52.167.195.110 80 6d21h
49
-
```
50
-
51
-
If you do not want to deploy the ingress controller with Helm, ensure to pass the following cmdline-flags to it through the mechanism of your choice:
52
-
53
-
```
54
-
flags:
55
-
--publish-service=<namespace of ingress-controller >/<svcname of ingress-controller>
-[Azure CLI 2.0](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) and `kubectl` installed on the box to execute the subsequent steps
61
20
62
21
## Provision Azure Private DNS
63
22
@@ -72,7 +31,7 @@ $ az group create -n externaldns -l westeurope
72
31
73
32
Substitute a more suitable location for the resource group if desired.
74
33
75
-
As a prerequisite for Azure Private DNS to resolve records is to define links with VNETs.
34
+
As a prerequisite for Azure Private DNS to resolve records is to define links with VNETs.
76
35
Thus, first create a VNET.
77
36
78
37
```
@@ -101,11 +60,11 @@ $ az network private-dns link vnet create -g externaldns -n mylink \
101
60
```
102
61
103
62
## Configure service principal for managing the zone
104
-
ExternalDNS needs permissions to make changes in Azure Private DNS.
63
+
ExternalDNS needs permissions to make changes in Azure Private DNS.
105
64
These permissions are roles assigned to the service principal used by ExternalDNS.
106
65
107
66
A service principal with a minimum access level of `Private DNS Zone Contributor` to the Private DNS zone(s) and `Reader` to the resource group containing the Azure Private DNS zone(s) is necessary.
108
-
More powerful role-assignments like `Owner` or assignments on subscription-level work too.
67
+
More powerful role-assignments like `Owner` or assignments on subscription-level work too.
109
68
110
69
Start off by **creating the service principal** without role-assignments.
111
70
```
@@ -119,8 +78,7 @@ $ az ad sp create-for-rbac --skip-assignment -n http://externaldns-sp
119
78
```
120
79
> Note: Alternatively, you can issue `az account show --query "tenantId"` to retrieve the id of your AAD Tenant too.
121
80
122
-
123
-
Next, assign the roles to the service principal.
81
+
Next, assign the roles to the service principal.
124
82
But first **retrieve the ID's** of the objects to assign roles on.
125
83
126
84
```
@@ -134,17 +92,17 @@ $ az network private-dns zone show --name example.com -g externaldns --query id
134
92
Now, **create role assignments**.
135
93
```
136
94
# 1. as a reader to the resource group
137
-
$ az role assignment create --role "Reader" --assignee <appId GUID> --scope <resource group resource id>
95
+
$ az role assignment create --role "Reader" --assignee <appId GUID> --scope <resource group resource id>
138
96
139
97
# 2. as a contributor to DNS Zone itself
140
-
$ az role assignment create --role "Private DNS Zone Contributor" --assignee <appId GUID> --scope <dns zone resource id>
98
+
$ az role assignment create --role "Private DNS Zone Contributor" --assignee <appId GUID> --scope <dns zone resource id>
141
99
```
142
100
143
101
## Deploy ExternalDNS
144
-
Configure `kubectl` to be able to communicate and authenticate with your cluster.
102
+
Configure `kubectl` to be able to communicate and authenticate with your cluster.
145
103
This is per default done through the file `~/.kube/config`.
146
104
147
-
For general background information on this see [kubernetes-docs](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/).
105
+
For general background information on this see [kubernetes-docs](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/).
148
106
Azure-CLI features functionality for automatically maintaining this file for AKS-Clusters. See [Azure-Docs](https://docs.microsoft.com/de-de/cli/azure/aks?view=azure-cli-latest#az-aks-get-credentials).
149
107
150
108
Follow the steps for [azure-dns provider](./azure.md#creating-configuration-file) to create a configuration file.
@@ -338,11 +296,12 @@ Create the deployment for ExternalDNS:
338
296
$ kubectl create -f externaldns.yaml
339
297
```
340
298
341
-
## Deploying sample service
299
+
## Create an nginx deployment
342
300
343
-
Create a service file called 'nginx.yaml' with the following contents:
301
+
This step creates a demo workload in your cluster. Apply the following manifest to create a deployment that we are going to expose later in this tutorial in multiple ways:
344
302
345
303
```yaml
304
+
---
346
305
apiVersion: apps/v1
347
306
kind: Deployment
348
307
metadata:
@@ -357,15 +316,92 @@ spec:
357
316
app: nginx
358
317
spec:
359
318
containers:
360
-
- image: nginx
361
-
name: nginx
362
-
ports:
363
-
- containerPort: 80
319
+
- image: nginx
320
+
name: nginx
321
+
ports:
322
+
- containerPort: 80
323
+
```
324
+
325
+
## Expose the nginx deployment with a load balancer
326
+
327
+
Apply the following manifest to create a service of type `LoadBalancer`. This will create a public load balancer in Azure that will forward traffic to the nginx pods.
In the service we used multiple annptations. The annotation `service.beta.kubernetes.io/azure-load-balancer-internal` is used to create an internal load balancer. The annotation `external-dns.alpha.kubernetes.io/hostname` is used to create a DNS record for the load balancer that will point to the internal IP address in the VNET allocated by the internal load balancer. The annotation `external-dns.alpha.kubernetes.io/internal-hostname` is used to create a private DNS record for the load balancer that will point to the cluster IP.
350
+
351
+
## Install NGINX Ingress Controller (Optional)
352
+
353
+
Helm is used to deploy the ingress controller.
354
+
355
+
We employ the popular chart [ingress-nginx](https://github.com/kubernetes/ingress-nginx/tree/main/charts/ingress-nginx).
The parameter `controller.publishService.enabled` needs to be set to `true.`
365
+
366
+
It will make the ingress controller update the endpoint records of ingress-resources to contain the external-ip of the loadbalancer serving the ingress-controller.
367
+
This is crucial as ExternalDNS reads those endpoints records when creating DNS-Records from ingress-resources.
368
+
In the subsequent parameter we will make use of this. If you don't want to work with ingress-resources in your later use, you can leave the parameter out.
369
+
370
+
Verify the correct propagation of the loadbalancer's ip by listing the ingresses.
371
+
372
+
```
373
+
$ kubectl get ingress
374
+
```
375
+
376
+
The address column should contain the ip for each ingress. ExternalDNS will pick up exactly this piece of information.
377
+
378
+
```
379
+
NAME HOSTS ADDRESS PORTS AGE
380
+
nginx1 sample1.aks.com 52.167.195.110 80 6d22h
381
+
nginx2 sample2.aks.com 52.167.195.110 80 6d21h
382
+
```
383
+
384
+
If you do not want to deploy the ingress controller with Helm, ensure to pass the following cmdline-flags to it through the mechanism of your choice:
## Expose the nginx deployment with the ingress (Optional)
396
+
397
+
Apply the following manifest to create an ingress resource that will expose the nginx deployment. The ingress resource backend points to a `ClusterIP` service that is needed to select the pods that will receive the traffic.
398
+
399
+
```yaml
400
+
---
401
+
apiVersion: v1
402
+
kind: Service
403
+
metadata:
404
+
name: nginx-svc-clusterip
369
405
spec:
370
406
ports:
371
407
- port: 80
@@ -374,7 +410,7 @@ spec:
374
410
selector:
375
411
app: nginx
376
412
type: ClusterIP
377
-
413
+
378
414
---
379
415
apiVersion: networking.k8s.io/v1
380
416
kind: Ingress
@@ -389,7 +425,7 @@ spec:
389
425
paths:
390
426
- backend:
391
427
service:
392
-
name: nginx-svc
428
+
name: nginx-svc-clusterip
393
429
port:
394
430
number: 80
395
431
pathType: Prefix
@@ -403,7 +439,7 @@ Create the deployment, service and ingress object:
403
439
$ kubectl create -f nginx.yaml
404
440
```
405
441
406
-
Since your external IP would have already been assigned to the nginx-ingress service, the DNS records pointing to the IP of the nginx-ingress service should be created within a minute.
442
+
Since your external IP would have already been assigned to the nginx-ingress service, the DNS records pointing to the IP of the nginx-ingress service should be created within a minute.
Since your external IP would have already been assigned to the nginx-ingress service, the DNS records pointing to the IP of the nginx-ingress service should be created within a minute.
588
588
589
+
## Azure Load Balancer option: Expose an nginx service with a load balancer
590
+
591
+
Create a file called `nginx.yaml` with the following contents:
The annotation `external-dns.alpha.kubernetes.io/hostname` is used to specify the DNS name that should be created for the service. The annotation value is a comma separated list of host names.
631
+
589
632
## Verifying Azure DNS records
590
633
591
634
Run the following command to view the A records for your Azure DNS zone:
0 commit comments