Zhixin Wen
Zhixin Wen

Reputation: 105

How To Use GKE IAM in k8s client-go

I am using k8s go client (https://github.com/kubernetes/client-go) to create jobs on GKE cluster (the code is running inside a pod). But I am having this error:

{
  "error": "2 UNKNOWN: jobs.batch is forbidden: User \"system:serviceaccount:default:default\" cannot create resource \"jobs\" in API group \"batch\" in the namespace \"default\""
}

Looks like I am using system:serviceaccount:default:default, but how can I use a GCP IAM account instead?

I have already set up GOOGLE_APPLICATION_CREDENTIALS following https://cloud.google.com/kubernetes-engine/docs/tutorials/authenticating-to-cloud-platform. But looks like it only works with GCP client not with k8s client

Upvotes: 0

Views: 513

Answers (1)

Jofre
Jofre

Reputation: 3898

You probably want to use the gcpAuthProvider plugin when creating the auth client.

Upvotes: 1

Related Questions