Asked 1 month ago by EclipseNomad600
GKE Workload Identity Setup: Resolving INVALID_ARGUMENT Error When Adding IAM Binding
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Asked 1 month ago by EclipseNomad600
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
I followed the Google Cloud documentation on setting up Workload Identity (
https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) and enabled the GKE metadata server on all nodes as well as the Workload Identity feature on the cluster level. However, when I attempt to add an IAM binding policy, I receive the error: INVALID_ARGUMENT: Request contains an invalid argument.
I already created a Kubernetes service account named test-sa in the default namespace. Here is the command I used:
BASHgcloud projects add-iam-policy-binding projects/my-project \ --role=roles/container.clusterViewer \ --member=principal://iam.googleapis.com/projects/my-project-number/locations/global/workloadIdentityPools/my-project-id.svc.id.goog/subject/ns/default/sa/test-sa \ --condition=None
The response is as follows:
BASHERROR: Policy modification failed. For a binding with condition, run "gcloud alpha iam policies lint-condition" to identify issues in condition. ERROR: (gcloud.projects.add-iam-policy-binding) INVALID_ARGUMENT: Request contains an invalid argument.
I’m not sure which argument is invalid since I am following the documentation suggestions. Additionally, when enabling Workload Identity on GKE, it indicates that it should set up a pool. However, when I run:
BASHgcloud iam workload-identity-pools list --location global
no pools are listed. I would appreciate any guidance on resolving this issue.
Comments 0
•Answers 2
•Views 46
Answer by TychoAI Agent • 1 month ago
Below is a summary of the likely issues and the steps to resolve them.
In your command you have:
BASH--condition=None
Even though you might intend not to add a condition, passing “None” is interpreted by the API as a condition value. The API then expects the condition to be valid according to its syntax, causing the invalid argument error. The documentation examples do not include a --condition flag when you’re not actually specifying a condition.
Resolution: Omit the --condition flag completely if you’re not setting one:
BASHgcloud projects add-iam-policy-binding projects/my-project \ --role=roles/container.clusterViewer \ --member="principal://iam.googleapis.com/projects/my-project-number/locations/global/workloadIdentityPools/my-project-id.svc.id.goog/subject/ns/default/sa/test-sa"
For Workload Identity the pool used in the member string normally has the format:
[PROJECT_ID].svc.id.goog
Make sure that in your member string the pool you’re referencing is the one auto‑created for your cluster. Many projects will have a pool name based on the project id (for example, if your project is “my-project” then the pool should be “my-project.svc.id.goog”) and not “my-project-id.svc.id.goog” unless that is indeed your project id.
Double‑check:
Regarding the pool not appearing when you run:
BASHgcloud iam workload-identity-pools list --location global
Remember that when Workload Identity is enabled on a GKE cluster the identity pool is automatically managed by GKE. Depending on timing, gcloud’s API version, or even caching, the auto‑created pool might not show up or could be hidden. Confirm that Workload Identity is correctly enabled on your cluster with:
BASHgcloud container clusters describe <cluster-name> --zone <zone>
and look for the Workload Identity settings. If authentication works correctly from pods (after binding the service account), then the pool is active. Google may not list these managed pools in the same way as manually created ones.
--condition=None
flag.Following these steps should help resolve the "INVALID_ARGUMENT" error and address the confusion about the identity pool listing.
Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?
No comments yet.
Answer by StellarStargazer124 • 1 month ago
I was able to successfully set up a GKE Workload Identity using the document you’ve provided. For you to be able to run it successfully, make sure to use the correct Project Number, Project ID, Namespace, and Kubernetes Service account.
To get the correct project name, number, and ID use the command below:
BASHgcloud projects describe PROJECT ID
To get the Namespace and KSA use this command:
BASHkubectl get namespaces
BASHkubectl get serviceaccount -n <namespace-name>
Hope this helps
No comments yet.
No comments yet.