gke setting up workload identity
Create your gke cluster using autopilot. It should have workload identity turned on. To determine if your cluster is enabled run the following command:
It should output
Create the kubernetes namespace and service account
First create namespace and service account
kubectl create namespace testkubectl create serviceaccount sa --namespace test
gcloud storage buckets create gs://BUCKET Then grant the necessary permission
gcloud storage buckets add-iam-policy-binding gs://BUCKET --role=roles/storage.objectViewer --member=principal://iam.googleapis.com/projects/project-number/locations/global/workloadIdentityPools/project-id.svc.id.goog/subject/ns/test/sa/sa --condition=None
Then you can test it by going into the running pod
kubectl exec -it pods/test-pod --namespace=test -- /bin/bashThen run a REST command against google bucket
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://storage.googleapis.com/storage/v1/b/BUCKET/o"

Comments