externalname.md 1.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
# Setting up ExternalDNS for ExternalName Services

This tutorial describes how to setup ExternalDNS for usage in conjunction with an ExternalName service.

## Usecases

The main use cases that inspired this feature is the necessity for having a subdomain pointing to an external domain. In this scenario, it makes sense for the subdomain to have a CNAME record pointing to the external domain.

## Setup

### External DNS
```yaml
13
apiVersion: apps/v1
14 15 16 17 18 19
kind: Deployment
metadata:
  name: external-dns
spec:
  strategy:
    type: Recreate
20 21 22
  selector:
    matchLabels:
      app: external-dns
23
  template:
24 25 26
    metadata:
      labels:
        app: external-dns
27 28 29 30 31
    spec:
      containers:
      - name: external-dns
        image: registry.opensource.zalan.do/teapot/external-dns:latest
        args:
32
        - --log-level=debug
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
        - --source=service
        - --source=ingress
        - --namespace=dev
        - --domain-filter=example.org.
        - --provider=aws
        - --registry=txt
        - --txt-owner-id=dev.example.org
```

### ExternalName Service

```yaml
kind: Service
apiVersion: v1
metadata:
  name: aws-service
  annotations:
    external-dns.alpha.kubernetes.io/hostname: tenant1.example.org,tenant2.example.org
spec:
  type: ExternalName
Tiago Matias's avatar
Tiago Matias committed
53
  externalName: aws.example.org
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
```

This will create 2 CNAME records pointing to `aws.example.org`:
```
tenant1.example.org
tenant2.example.org
```

### ExternalName Service with an IP address

If `externalName` is an IP address, External DNS will create A records instead of CNAME.

```yaml
kind: Service
apiVersion: v1
metadata:
  name: aws-service
  annotations:
    external-dns.alpha.kubernetes.io/hostname: tenant1.example.org,tenant2.example.org
spec:
  type: ExternalName
  externalName: 111.111.111.111
```

This will create 2 A records pointing to `111.111.111.111`:
```
tenant1.example.org
tenant2.example.org
```