harness - setting up connector to gcp


Configuring gcp worker pool

As part of this setup, we need to create pool in GCP that be able to do OIDC authentications with harness.io. Lets start by 

Create the pool using the following command 


gcloud iam workload-identity-pools create harness-pool \
  --location=global \
  --project=project-number \
  --display-name="Harness Pool" \
  --description="Workload identity pool for Harness OIDC"

Then we need to create the providers using the following command 


gcloud iam workload-identity-pools providers create-oidc harness-provider-oidc \
  --workload-identity-pool=harness-pool \
  --location=global \
  --project=project-number \
  --issuer-uri="https://app.harness.io/ng/api/oidc/account/UlEEm2GaTPaJNlYAV6NDkg" \
  --attribute-mapping="google.subject=assertion.sub" \
  --allowed-audiences="//iam.googleapis.com/projects/project-id/locations/global/workloadIdentityPools/harness-pool/providers/harness-provider-oidc"


Create service account and then associate service account to it 

 
gcloud iam service-accounts create harness-sa
--project="project-number" --display-name="Harness io dev Service Account"

And add policy bindings 

gcloud iam service-accounts add-iam-policy-binding
harness-sa@your-project-id.iam.gserviceaccount.com
--project="project-f54eacb9-b4e5-40b9-b0c" --role="roles/iam.workloadIdentityUser"
--member="principalSet://iam.googleapis.com/projects/1092851139093/locations/
global/workloadIdentityPools/harness-pool/*"



And then you need to provide the following detail for your gcp conector service :-




And if all goes well, then we can see the followings :-



Further validation that we can do by running the following command :-


gcloud iam workload-identity-pools providers describe harness-provider-oidc --workload-identity-pool=harness-pool --location=global --project=project-number --format="yaml(oidc.allowedAudiences,oidc.issuerUri,state)"



oidc:
  allowedAudiences:
  - https://iam.googleapis.com/projects/project-id/locations/global/workloadIdentityPools/harness-pool/providers/harness-provider-oidc
  issuerUri: https://app.harness.io/ng/api/oidc/account/your-account-id-in-harness
state: ACTIVE
















Comments

Popular posts from this blog

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

android build issue with version compatibility with agp and hilt : An exception occurred applying plugin request [id: 'com.google.dagger.hilt.android', version: '2.52']