Open withnale opened 9 months ago
Hi @withnale,
I did everything you mentioned in Git support to Google Cloud Source Repos using Workload Identity
Once I am trying to add a google source repository I can see a new secrets has been added with the name repo-
BTW, I added the repository with connection method HTTPS
what further steps I can do to debug the issue ?
what further steps I can do to debug the issue ?
It's very tricky to setup and there is next to no logging even at debug level when credentials are being used, making it especially difficult.
The first question I had was is the repo-gcloud-source
secret even being pickup correctly even before it tries to associate the gcloud credential. The easiest way I found for validating this was to change the credential_source.file
reference to a file that does not exist. In that event, you at least get an error in the logs telling you that it's trying to use a token file that doesn't exist.
After that, make sure you've replaced all the references such as __CLUSTER_PROJECT_ID__
with values specific to your setup.
You can always kubectl exec
or kubectl debug
into the pod and try some of the stuff interactively.
Can I get some feedback on this? It would be great to improve this flow.
Unfortunately I didn't get it working
No. I meant, can I get some feedback from one of the developers about whether we can get improvements to make this way easier!?
The above works for us consistently so it is possible. It's just amazingly kiunky.
Hi @withnale,
I was able to make it work :-) My problem was that I am using branch "main" and argocd by default tried to fetch branch "master" (which is the default one) How can I set ArgoCD to fetch the "main" branch ? I didn't find anything on GCP side to accomplish this
We make extensive use of ArgoCD to bootstrap our Kubernetes clusters and we have many clusters we are constantly deploying so our bootstrap code is exercised daily. Below are the steps required to enable ArgoCD throughout our estate.
Our main goals are:
NB: I have deliberately tried to consolidate all of the work to get Workload Identity working in the current ArgoCD release below, since this is not well documented at present and I had to piece together information deep within the comments of multiple issues as well as the source code to get this working.
I am aware of the discussion in the issue https://github.com/argoproj/argo-cd/issues/10218 and the preference not to "reinvent the wheel" and delegate the responsibility for this to a separate deployment of the External Secrets Operator. However, this doesn't provide for a very clean solution when you wish for ArgoCD to be the first thing to be bootstrapped onto a cluster and mastering subsequent payloads.
The work to support Workload Identity for Source Repositories introduced a
gcpServiceAccountKey
field to theSecret
manifest. Although this is still very verbose, it would be great if this approach would also work for OCI registries since it is possible to login to OCI registries using this token, and it is already available for git registries. However, after looking through the code it's clear that this is only useable for git repos.Would you accept a PR to allow this to be used for OCI repos? This feels like a relatively small change that would alleviate the need for an initContainer in the approaches outlined below.
In the longer term it would be great if this setup could be made much cleaner. There is a lot of complexity here and it would be very easy to mess up with so many moving parts. In particular the use of a gcpServiceAccount key seems very complex with a great deal of per-cluster substitution required just to consume a token that is already mounted within the container.
Current Implementation
We use helm to install ArgoCD and fortunately the chart is pretty flexible allowing for
initContainers
and additionalvolumes
to be defined from thevalues.yaml
and so these instructions below work without chart modification.Of course, with both approaches you need to have setup Workload Identity for the repoServer serviceAccount. You have access to
.repoServer.serviceAccount.annotations
within thevalues.yaml
file to configure WI from the KSA side.Helm OCI Support to Google Artifact Registry using Workload Identity
The approach to enable this is broadly outlined in the following issue: https://github.com/argoproj/argo-cd/issues/11492
This generates an initContainer to configure the repoServer with gcloud docker credentials, and shares the necessary volumes with the main container.
This is slightly different from the original issue since it is referencing a custom image for the initContainer instead of dynamically pulling the tarball down at runtime (and having an associated runtime dependency that might fail).
NB: I have deliberately used
docker-credential-gcr
rather thangcloud-cli
since installinggcloud-cli
generates an image over 2GB in size. We only need the credential helper and so this is a much smaller image anddocker-credential-gcr
is still maintained by Google.After that, if you copy the stefanprodan
podinfo
chart into your repo you should be able to run the followingApplication
manifest:Git support to Google Cloud Source Repos using Workload Identity
The approach to enable this is broadly outlined in the following issue: https://github.com/argoproj/argo-cd/issues/15361
This requires mounting a projected volume of the workload identity kubernetes service account token into the
argocd-repo-server
pod. Once present you can define an ArgoCD repository secret which includes a gcpServiceAccount payload of typeexternal_account
using the mounted token as the credential source.Then you need to create an ArgoCD external account secret that references the token (replacing the placeholders with your own values).
Once this is created you can then create an
Application
resource that uses this repo.Comparison to Flux Helm Workload Identity Support
The flux Helm OCI Workload Identity support is native as befits a system that is typically the first thing to be bootstrapped onto a cluster. It is also very concise with the WI support being enabled by the single
provider: gcp
directive in theHelmRepository
resource.