Okteto Registry with Google Cloud Storage
This guide will walk you through the process of setting up the Okteto Registry with Google Cloud Storage to store your container images.
The first step is creating a Cloud Storage bucket in GCP. You can follow the steps mentioned here to do that. It is okay to proceed with the default settings. Just make sure that your bucket does not have public access enabled.
Create a Google Cloud service account with access to your bucket, for example GSA_NAME@GSA_PROJECT.iam.gserviceaccount.com. The commands on this page use $GSA_NAME and $GSA_PROJECT for the name and the project of that service account, and $GCP_PROJECT for the project of your GKE cluster.
Run the following command to let the okteto-registry Kubernetes service account impersonate that Google Cloud service account through Workload Identity. With the roles/iam.workloadIdentityUser role binding, the Kubernetes service account authenticates as the Google Cloud service account, so it accesses the Cloud Storage bucket securely without long-lived service account keys:
gcloud iam service-accounts add-iam-policy-binding \
$GSA_NAME@$GSA_PROJECT.iam.gserviceaccount.com \
--role roles/iam.workloadIdentityUser \
--member "serviceAccount:$GCP_PROJECT.svc.id.goog[okteto/okteto-registry]" \
--project $GCP_PROJECT
Important: Make sure you have Workload Identity enabled in your cluster for this to work. Workload Identity in Google Kubernetes Engine (GKE), allows for seamless and secure communication between Kubernetes workloads and Google Cloud services.
Configure the Okteto Registry to use Workload Identity in your Okteto Helm configuration file:
registry:
storage:
provider:
gcp:
enabled: true
bucket: <bucket-name>
project: <<your-project-id>>
workloadIdentity:
enabled: true
serviceAccount:
annotations:
iam.gke.io/gcp-service-account: "GSA_NAME@GSA_PROJECT.iam.gserviceaccount.com"
Finally, upgrade your Okteto instance for the new configuration to be applied. We recommend that you upgrade to the same version that you already have to minimize the changes and help you troubleshoot any issues.