11
11
[ ![ GitHub stars] ( https://img.shields.io/github/stars/stackitcloud/external-dns-stackit-webhook.svg?style=social&label=Star&maxAge=2592000 )] ( https://github.com/stackitcloud/external-dns-stackit-webhook/stargazers )
12
12
[ ![ GitHub forks] ( https://img.shields.io/github/forks/stackitcloud/external-dns-stackit-webhook.svg?style=social&label=Fork&maxAge=2592000 )] ( https://github.com/stackitcloud/external-dns-stackit-webhook/network )
13
13
14
- ExternalDNS serves as an add-on for Kubernetes designed to automate the management of Domain Name System (DNS)
15
- records for Kubernetes services by utilizing various DNS providers. While Kubernetes traditionally manages DNS
16
- records internally, ExternalDNS augments this functionality by transferring the responsibility of DNS records
17
- management to an external DNS provider such as STACKIT. Consequently, the STACKIT webhook enables the management
18
- of your STACKIT domains within your Kubernetes cluster using
14
+ ExternalDNS serves as an add-on for Kubernetes designed to automate the management of Domain Name System (DNS)
15
+ records for Kubernetes services by utilizing various DNS providers. While Kubernetes traditionally manages DNS
16
+ records internally, ExternalDNS augments this functionality by transferring the responsibility of DNS records
17
+ management to an external DNS provider such as STACKIT. Consequently, the STACKIT webhook enables the management
18
+ of your STACKIT domains within your Kubernetes cluster using
19
19
[ ExternalDNS] ( https://github.com/kubernetes-sigs/external-dns ) .
20
20
21
- For utilizing ExternalDNS with STACKIT, it is mandatory to establish a STACKIT project, a service account
22
- within the project, generate an authentication token for the service account, authorize the service account
21
+ For utilizing ExternalDNS with STACKIT, it is mandatory to establish a STACKIT project, a service account
22
+ within the project, generate an authentication token for the service account, authorize the service account
23
23
to create and read dns zones, and finally, establish a STACKIT zone.
24
24
25
25
## Kubernetes Deployment
26
- The STACKIT webhook is presented as a standard Open Container Initiative (OCI) image released in the
27
- [ GitHub container registry] ( https://github.com/stackitcloud/external-dns-stackit-webhook/pkgs/container/external-dns-stackit-webhook ) .
28
- The deployment is compatible with all Kubernetes-supported methods. The subsequent example
29
- demonstrates the deployment as a
30
- [ sidecar container] ( https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods )
26
+
27
+ The STACKIT webhook is presented as a standard Open Container Initiative (OCI) image released in the
28
+ [ GitHub container registry] ( https://github.com/stackitcloud/external-dns-stackit-webhook/pkgs/container/external-dns-stackit-webhook ) .
29
+ The deployment is compatible with all Kubernetes-supported methods. The subsequent example
30
+ demonstrates the deployment as a
31
+ [ sidecar container] ( https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods )
31
32
within the ExternalDNS pod.
32
33
33
34
``` shell
34
35
kubectl create secret generic external-dns-stackit-webhook --from-literal=auth-token=' <Your-Token>'
36
+ ```
35
37
38
+ ``` shell
36
39
kubectl apply -f - << EOF
37
40
apiVersion: v1
38
41
kind: ServiceAccount
@@ -141,9 +144,8 @@ spec:
141
144
- --interval=1m
142
145
- --source=service
143
146
- --source=ingress
144
- - --policy=sync
147
+ - --policy=sync # set it upsert-only if you don't want it to delete records
145
148
- --provider=webhook
146
- - --webhook-provider-url=http://localhost:8888
147
149
ports:
148
150
- name: http
149
151
protocol: TCP
@@ -174,7 +176,7 @@ spec:
174
176
readOnlyRootFilesystem: true
175
177
runAsNonRoot: true
176
178
runAsUser: 65534
177
- image: ghcr.io/stackitcloud/external-dns-stackit-webhook:v0.1 .0
179
+ image: ghcr.io/stackitcloud/external-dns-stackit-webhook:v0.2 .0
178
180
imagePullPolicy: IfNotPresent
179
181
args:
180
182
- --project-id=c158c736-0300-4044-95c4-b7d404279b35 # your project id
@@ -210,20 +212,122 @@ EOF
210
212
```
211
213
212
214
## Configuration
213
- The configuration of the STACKIT webhook can be accomplished through command line arguments and environment variables.
215
+
216
+ The configuration of the STACKIT webhook can be accomplished through command line arguments and environment variables.
214
217
Below are the options that are available.
218
+
215
219
- ` --project-id ` /` PROJECT_ID ` (required): Specifies the project id of the STACKIT project.
216
220
- ` --auth-token ` /` AUTH_TOKEN ` (required): Defines the authentication token for the STACKIT API.
217
- - ` --worker ` /` WORKER ` (optional): Specifies the number of workers to employ for querying the API. Given that we
218
- need to iterate over all zones and records, it can be parallelized. However, it is important to avoid
219
- setting this number excessively high to prevent receiving 429 rate limiting from the API (default 10).
220
- - ` --base-url ` /` BASE_URL ` (optional): Identifies the Base URL for utilizing the API (default "https://dns.api.stackit.cloud ").
221
+ - ` --worker ` /` WORKER ` (optional): Specifies the number of workers to employ for querying the API. Given that we
222
+ need to iterate over all zones and records, it can be parallelized. However, it is important to avoid
223
+ setting this number excessively high to prevent receiving 429 rate limiting from the API (default 10).
224
+ - ` --base-url ` /` BASE_URL ` (optional): Identifies the Base URL for utilizing the API (
225
+ default "https://dns.api.stackit.cloud ").
221
226
- ` --api-port ` /` API_PORT ` (optional): Specifies the port to listen on (default 8888).
222
227
- ` --domain-filter ` /` DOMAIN_FILER ` (optional): Establishes a filter for DNS zone names (default [ ] ).
223
228
- ` --dry-run ` /` DRY_RUN ` (optional): Specifies whether to perform a dry run (default false).
229
+ - ` --log-level ` /` LOG_LEVEL ` (optional): Defines the log level (default "info"). Possible values are: debug, info, warn,
230
+ error".
231
+
232
+ ## FAQ
233
+
234
+ ### 1. Issue with Creating Service using External DNS Annotation
235
+
236
+ If your zone is ` example.runs.onstackit.cloud ` and you're trying to create a service with the following external DNS
237
+ annotation:
238
+
239
+ ```yaml
240
+ apiVersion: v1
241
+ kind: Service
242
+ metadata:
243
+ annotations:
244
+ external-dns.alpha.kubernetes.io/hostname: example.runs.onstackit.cloud
245
+ labels:
246
+ app.kubernetes.io/name: ingress-nginx
247
+ app.kubernetes.io/instance: nginx
248
+ app.kubernetes.io/part-of: ingress-nginx
249
+ app.kubernetes.io/component: controller
250
+ name: nginx-ingress-controller
251
+ namespace: nginx-ingress-controller
252
+ spec:
253
+ type: LoadBalancer
254
+ externalTrafficPolicy: Local
255
+ ipFamilyPolicy: SingleStack
256
+ ipFamilies:
257
+ - IPv4
258
+ ports:
259
+ - name: http
260
+ port: 80
261
+ protocol: TCP
262
+ targetPort: http
263
+ - name: https
264
+ port: 443
265
+ protocol: TCP
266
+ targetPort: https
267
+ selector:
268
+ app.kubernetes.io/component: controller
269
+ app.kubernetes.io/instance: nginx
270
+ app.kubernetes.io/name: ingress-nginx
271
+ ```
272
+
273
+ <b >Why isn't it working?</b >
274
+
275
+ <b >Answer</b >: The External DNS will try to create a TXT record named ` a-example.runs.onstackit.cloud ` , which will fail
276
+ because you can't establish a record outside the zone. The solution is to use a name that's within the zone, such as
277
+ ` nginx.example.runs.onstackit.cloud ` .
278
+
279
+ ### 2. Issues with Creating Ingresses not in the Zone
280
+
281
+ For a project containing the zone ` example.runs.onstackit.cloud ` , suppose you've created these two ingress:
282
+
283
+ ```yaml
284
+ apiVersion: networking.k8s.io/v1
285
+ kind: Ingress
286
+ metadata:
287
+ annotations:
288
+ ingress.kubernetes.io/rewrite-target: /
289
+ kubernetes.io/ingress.class: nginx
290
+ name: example-ingress-external-dns
291
+ namespace: default
292
+ spec:
293
+ rules:
294
+ - host: test.example.runs.onstackit.cloud
295
+ http:
296
+ paths:
297
+ - backend:
298
+ service:
299
+ name: example
300
+ port:
301
+ number: 80
302
+ path: /
303
+ pathType: Prefix
304
+ - host: test.example.stackit.rocks
305
+ http:
306
+ paths:
307
+ - backend:
308
+ service:
309
+ name: example
310
+ port:
311
+ number: 80
312
+ path: /
313
+ pathType: Prefix
314
+ ```
315
+
316
+ <b >Why isn't it working?</b >
317
+
318
+ <b >Answer</b >: External DNS will attempt to establish a record set for ` test.example.stackit.rocks ` . As the zone
319
+ ` example.stackit.rocks ` isn't within the project, it'll fail. There are two potential fixes:
320
+
321
+ - Incorporate the zone ` example.stackit.rocks ` into the project.
322
+ - Adjust the domain filter to ` example.runs.onstackit.cloud ` by setting the domain filter
323
+ flag ` --domain-filter="example.runs.onstackit.cloud" ` . This will exclude ` test.example.stackit.rocks ` and only
324
+ generate
325
+ the record set for ` test.example.runs.onstackit.cloud ` .
224
326
225
327
## Development
328
+
226
329
Run the app:
330
+
227
331
``` bash
228
332
export BASE_URL=" https://dns.api.stackit.cloud"
229
333
export PROJECT_ID=" c158c736-0300-4044-95c4-b7d404279b35"
@@ -233,11 +337,13 @@ make run
233
337
```
234
338
235
339
Lint the code:
340
+
236
341
``` bash
237
342
make lint
238
343
```
239
344
240
345
Test the code:
346
+
241
347
``` bash
242
348
make test
243
349
```
0 commit comments