Skip to content

Commit dc2543d

Browse files
authored
Merge pull request #34 from stackitcloud/feature/update-readme-sa-key
docs: update README to use SA key instead of token for authorisation.
2 parents 6da7d4c + 95e8f52 commit dc2543d

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ of your STACKIT domains within your Kubernetes cluster using
1919
[ExternalDNS](https://github.com/kubernetes-sigs/external-dns).
2020

2121
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-
to create and read dns zones, and finally, establish a STACKIT zone.
22+
within the project, generate a service account key, authorize the service account with DNS Admin role,
23+
and finally establish a STACKIT zone.
2424

2525
## Kubernetes Deployment
2626

@@ -32,9 +32,10 @@ demonstrates the deployment as a
3232
within the ExternalDNS pod.
3333

3434
```shell
35-
# We create a Secret from an auth token. Alternatively, you can also
36-
# use keys to authenticate the webhook - see "Authentication" below.
37-
kubectl create secret generic external-dns-stackit-webhook --from-literal=auth-token='<Your-Token>'
35+
# Create a Secret containing the STACKIT service-account key JSON (as a file).
36+
# This Secret will be mounted into the webhook container; AUTH_KEY_PATH will point to that mounted file.
37+
kubectl -n default create secret generic external-dns-stackit-webhook \
38+
--from-file=sa.json=/path/to/stackit-service-account-key.json
3839
```
3940

4041
```shell
@@ -129,6 +130,13 @@ spec:
129130
serviceAccountName: external-dns
130131
securityContext:
131132
fsGroup: 65534
133+
volumes:
134+
- name: stackit-sa-key
135+
secret:
136+
secretName: external-dns-stackit-webhook
137+
items:
138+
- key: sa.json
139+
path: sa.json
132140
containers:
133141
- name: external-dns
134142
securityContext:
@@ -205,11 +213,12 @@ spec:
205213
successThreshold: 1
206214
timeoutSeconds: 5
207215
env:
208-
- name: AUTH_TOKEN
209-
valueFrom:
210-
secretKeyRef:
211-
name: external-dns-stackit-webhook
212-
key: auth-token
216+
- name: AUTH_KEY_PATH
217+
value: /var/run/secrets/stackit/sa.json
218+
volumeMounts:
219+
- name: stackit-sa-key
220+
mountPath: /var/run/secrets/stackit
221+
readOnly: true
213222
EOF
214223
```
215224

@@ -219,8 +228,9 @@ The configuration of the STACKIT webhook can be accomplished through command lin
219228
Below are the options that are available.
220229

221230
- `--project-id`/`PROJECT_ID` (required): Specifies the project id of the STACKIT project.
222-
- `--auth-token`/`AUTH_TOKEN` (required if `auth-key-path` is not set): Defines the authentication token for the STACKIT API. Mutually exclusive with 'auth-key-path'.
223-
- `--auth-key-path`/`AUTH_KEY_PATH` (required if `auth-token` is not set): Defines the file path of the service account key for the STACKIT API. Mutually exclusive with 'auth-token'.
231+
- `--auth-key-path`/`AUTH_KEY_PATH` (required): Defines the file path of the service account key for the STACKIT API.
232+
Prefer using a Kubernetes Secret mounted as a file and set `AUTH_KEY_PATH` to the in-container path
233+
(e.g. `/var/run/secrets/stackit/sa.json`).
224234
- `--worker`/`WORKER` (optional): Specifies the number of workers to employ for querying the API. Given that we
225235
need to iterate over all zones and records, it can be parallelized. However, it is important to avoid
226236
setting this number excessively high to prevent receiving 429 rate limiting from the API (default 10).
@@ -334,7 +344,7 @@ Run the app:
334344
```bash
335345
export BASE_URL="https://dns.api.stackit.cloud"
336346
export PROJECT_ID="c158c736-0300-4044-95c4-b7d404279b35"
337-
export AUTH_TOKEN="your-auth-token"
347+
export AUTH_KEY_PATH="/absolute/path/to/stackit-service-account-key.json"
338348

339349
make run
340350
```

0 commit comments

Comments
 (0)