exoscale.md 3.88 KB
Newer Older
1
2
3
4
# Setting up ExternalDNS for Exoscale

## Prerequisites

5
Exoscale provider support was added via [this PR](https://github.com/kubernetes-sigs/external-dns/pull/625), thus you need to use external-dns v0.5.5.
6
7
8
9

The Exoscale provider expects that your Exoscale zones, you wish to add records to, already exists
and are configured correctly. It does not add, remove or configure new zones in anyway.

David Dymko's avatar
David Dymko committed
10
To do this please refer to the [Exoscale DNS documentation](https://community.exoscale.com/documentation/dns/).
11
12
13
14
15
16
17
18
19
20
21
22
23
24

Additionally you will have to provide the Exoscale...:

* API Key
* API Secret
* API Endpoint
* Elastic IP address, to access the workers

## Deployment

Deploying external DNS for Exoscale is actually nearly identical to deploying
it for other providers. This is what a sample `deployment.yaml` looks like:

```yaml
25
apiVersion: apps/v1
26
27
28
29
30
31
kind: Deployment
metadata:
  name: external-dns
spec:
  strategy:
    type: Recreate
32
33
34
  selector:
    matchLabels:
      app: external-dns
35
36
37
38
39
40
41
42
43
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      # Only use if you're also using RBAC
      # serviceAccountName: external-dns
      containers:
      - name: external-dns
44
        image: k8s.gcr.io/external-dns/external-dns:v0.7.6
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        args:
        - --source=ingress # or service or both
        - --provider=exoscale
        - --domain-filter={{ my-domain }}
        - --policy=sync # if you want DNS entries to get deleted as well
        - --txt-owner-id={{ owner-id-for-this-external-dns }}
        - --exoscale-endpoint={{ endpoint }} # usually https://api.exoscale.ch/dns
        - --exoscale-apikey={{ api-key}}
        - --exoscale-apisecret={{ api-secret }}
```

## RBAC

If your cluster is RBAC enabled, you also need to setup the following, before you can run external-dns:

```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: external-dns
  namespace: default

---

Kundan Kumar's avatar
Kundan Kumar committed
69
apiVersion: rbac.authorization.k8s.io/v1
70
71
72
73
74
kind: ClusterRole
metadata:
  name: external-dns
rules:
- apiGroups: [""]
Alfred Krohmer's avatar
Alfred Krohmer committed
75
  resources: ["services","endpoints","pods"]
76
  verbs: ["get","watch","list"]
77
- apiGroups: ["extensions","networking.k8s.io"]
78
79
  resources: ["ingresses"]
  verbs: ["get","watch","list"]
Christopher Schmidt's avatar
Christopher Schmidt committed
80
81
82
- apiGroups: [""]
  resources: ["nodes"]
  verbs: ["list"]
83
84
85

---

Kundan Kumar's avatar
Kundan Kumar committed
86
apiVersion: rbac.authorization.k8s.io/v1
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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: default
```

## Testing and Verification

**Important!**: Remember to change `example.com` with your own domain throughout the following text.

Spin up a simple nginx HTTP server with the following spec (`kubectl apply -f`):

```yaml
Kundan Kumar's avatar
Kundan Kumar committed
107
apiVersion: networking.k8s.io/v1
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
kind: Ingress
metadata:
  name: nginx
  annotations:
    kubernetes.io/ingress.class: nginx
    external-dns.alpha.kubernetes.io/target: {{ Elastic-IP-address }}
spec:
  rules:
  - host: via-ingress.example.com
    http:
      paths:
      - backend:
          serviceName: nginx
          servicePort: 80

---

apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: nginx

---

138
apiVersion: apps/v1
139
140
141
142
kind: Deployment
metadata:
  name: nginx
spec:
143
144
145
  selector:
    matchLabels:
      app: nginx
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        ports:
        - containerPort: 80
```

**Important!**: Don't run dig, nslookup or similar immediately (until you've
confirmed the record exists). You'll get hit by [negative DNS caching](https://tools.ietf.org/html/rfc2308), which is hard to flush.

161
Wait about 30s-1m (interval for external-dns to kick in), then check Exoscales [portal](https://portal.exoscale.com/dns/example.com)... via-ingress.example.com should appear as a A and TXT record with your Elastic-IP-address.