Skip to content

SASL/OAUTHBEARER Fails for GKE Workload Identity to Managed Kafka #50

Description

@solarpunkin

ERROR: The connection consistently fails during the SASL handshake, resulting in either a client-side KafkaError{code=_MSG_TIMED_OUT} or a broker-side SaslAuthenticationException: Authentication failed due to invalid credentials.

WIF is enabled on the cluster (workload_pool is set) and the node pool (mode: GKE_METADATA). A ServiceAccount is annotated with iam.gke.io/return-principal-id-as-email: “true” and is used by the application pods. A Google Service Account (GSA) has the roles/managedkafka.client and roles/iam.serviceAccountTokenCreator roles. The Kubernetes Service Account is bound to this GSA with the roles/iam.workloadIdentityUser role. The Python client is configured for SASL_SSL with sasl.mechanism: OAUTHBEARER and uses google.auth.default() within an oauth_cb callback to provide the authentication token.

I have validated network connectivity (via socket tests), all IAM/GKE/K8s policies and annotations, and Kafka ACLs (including User:*)—every component is correctly configured as per the docs.

the authentication fails with both the direct federation (return-principal-id-as-email annotation) and the KSA-to-GSA impersonation (gcp-service-account annotation) methods of Workload Identity.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions