@@ -15,6 +15,7 @@ It has been successfully tested against the following popular registries:
15
15
* GitHub Packages Registry (` docker.pkg.github.com ` )
16
16
* GitLab Container Registry (` registry.gitlab.com ` )
17
17
* Google Container Registry (` gcr.io ` )
18
+ * Azure Container Registry (` azurecr.io ` )
18
19
19
20
Chances are, that it will work out of the box for other registries as well.
20
21
@@ -326,3 +327,94 @@ two strategies to overcome this:
326
327
i.e. for getting EKS credentials from the aws CLI. For example, if the
327
328
token has a lifetime of 12 hours, you can set `credsexpire : 12h` and Argo
328
329
CD Image Updater will get a new token after 12 hours.
330
+
331
+ # ## <a name="default-registry"></a>Configuring Azure Container registry with
332
+ Workload identity
333
+
334
+ Follow the steps described below to authenticate against an Azure Container
335
+ Registry using Azure Workload Identities with an external script.
336
+
337
+ Create a script to retrieve the ACR refresh token with the Azure Identity
338
+ token :
339
+
340
+ ` ` ` yaml
341
+ apiVersion: v1
342
+ kind: ConfigMap
343
+ metadata:
344
+ name: argocd-image-updater-auth
345
+ data:
346
+ auth.sh: |
347
+ AAD_ACCESS_TOKEN=$(cat $AZURE_FEDERATED_TOKEN_FILE)
348
+
349
+ ACCESS_TOKEN=$(wget --output-document - --header "Content-Type: application/x-www-form-urlencoded" \
350
+ --post-data="grant_type=client_credentials&client_id=${AZURE_CLIENT_ID}&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&scope=https://management.azure.com/.default&client_assertion=${AAD_ACCESS_TOKEN}" \
351
+ https://login.microsoftonline.com/${AZURE_TENANT_ID}/oauth2/v2.0/token \
352
+ | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
353
+
354
+ ACR_REFRESH_TOKEN=$(wget --quiet --header="Content-Type: application/x-www-form-urlencoded" \
355
+ --post-data="grant_type=access_token&service=${ACR_NAME}&access_token=${ACCESS_TOKEN}" \
356
+ --output-document - \
357
+ "https://${ACR_NAME}/oauth2/exchange" |
358
+ python3 -c "import sys, json; print(json.load(sys.stdin)['refresh_token'])")
359
+
360
+ echo "00000000-0000-0000-0000-000000000000:$ACR_REFRESH_TOKEN"
361
+ ` ` `
362
+
363
+ Configure the Azure registry and map the authentication script :
364
+
365
+ ` ` ` yaml
366
+ apiVersion: v1
367
+ kind: ConfigMap
368
+ metadata:
369
+ name: argocd-image-updater-config
370
+ data:
371
+ registries.conf: |
372
+ registries:
373
+ - name: acr-name
374
+ prefix: acr-name.azurecr.io
375
+ api_url: https://acr-name.azurecr.io
376
+ default: yes
377
+ credentials: ext:/app/auth/auth.sh
378
+ ` ` `
379
+
380
+ Patch the service account with the appropriate Azure Workload identity labels
381
+ and annotations :
382
+
383
+ ` ` ` yaml
384
+ apiVersion: v1
385
+ kind: ServiceAccount
386
+ metadata:
387
+ name: argocd-image-updater
388
+ labels:
389
+ azure.workload.identity/use: "true"
390
+ annotations:
391
+ azure.workload.identity/client-id: placeholder
392
+ ` ` `
393
+
394
+ Patch the deployment with the appropriate Azure Workload identity labels, mount
395
+ directory and `ACR_NAME` environment variable :
396
+
397
+ ` ` ` yaml
398
+ apiVersion: apps/v1
399
+ kind: Deployment
400
+ metadata:
401
+ name: argocd-image-updater
402
+ spec:
403
+ template:
404
+ metadata:
405
+ labels:
406
+ azure.workload.identity/use: "true"
407
+ spec:
408
+ containers:
409
+ - name: argocd-image-updater
410
+ env:
411
+ - name: ACR_NAME
412
+ value: placeholder
413
+ volumeMounts:
414
+ - mountPath: /app/auth
415
+ name: auth
416
+ volumes:
417
+ - configMap:
418
+ name: argocd-image-updater-auth
419
+ name: auth
420
+ ` ` `
0 commit comments