1111[ ![ 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 )
1212[ ![ 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 )
1313
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
1919[ ExternalDNS] ( https://github.com/kubernetes-sigs/external-dns ) .
2020
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
2323to create and read dns zones, and finally, establish a STACKIT zone.
2424
2525## 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 )
3132within the ExternalDNS pod.
3233
3334``` shell
3435kubectl create secret generic external-dns-stackit-webhook --from-literal=auth-token=' <Your-Token>'
36+ ```
3537
38+ ``` shell
3639kubectl apply -f - << EOF
3740apiVersion: v1
3841kind: ServiceAccount
@@ -141,9 +144,8 @@ spec:
141144 - --interval=1m
142145 - --source=service
143146 - --source=ingress
144- - --policy=sync
147+ - --policy=sync # set it upsert-only if you don't want it to delete records
145148 - --provider=webhook
146- - --webhook-provider-url=http://localhost:8888
147149 ports:
148150 - name: http
149151 protocol: TCP
@@ -174,7 +176,7 @@ spec:
174176 readOnlyRootFilesystem: true
175177 runAsNonRoot: true
176178 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
178180 imagePullPolicy: IfNotPresent
179181 args:
180182 - --project-id=c158c736-0300-4044-95c4-b7d404279b35 # your project id
@@ -210,20 +212,122 @@ EOF
210212```
211213
212214## 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.
214217Below are the options that are available.
218+
215219- ` --project-id ` /` PROJECT_ID ` (required): Specifies the project id of the STACKIT project.
216220- ` --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 ").
221226- ` --api-port ` /` API_PORT ` (optional): Specifies the port to listen on (default 8888).
222227- ` --domain-filter ` /` DOMAIN_FILER ` (optional): Establishes a filter for DNS zone names (default [ ] ).
223228- ` --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 ` .
224326
225327## Development
328+
226329Run the app:
330+
227331``` bash
228332export BASE_URL=" https://dns.api.stackit.cloud"
229333export PROJECT_ID=" c158c736-0300-4044-95c4-b7d404279b35"
@@ -233,11 +337,13 @@ make run
233337```
234338
235339Lint the code:
340+
236341``` bash
237342make lint
238343```
239344
240345Test the code:
346+
241347``` bash
242348make test
243349```
0 commit comments