Skip to content

[GKE Connect Gateway] Bad Request 400, albeit correct resource name #13852

Open
@Pithikos

Description

@Pithikos

Determine this is the right repository

  • I determined this is the correct repository in which to report this bug.

Summary of the issue

Context

I'm trying to use Connect Gateway to programmatically connect to Kubernetes.

Following the official documentation here and using the (assuming) correct name, I get a Bad Request 400 response like below.

Response

BadRequest: 400 GET https://connectgateway.googleapis.com/v1/projects/myproject-1234/locations/us-east1/memberships/cluster-dev-us-e1-aa11ff:generateCredentials?%24alt=json%3Benum-encoding%3Dint: Request contains an invalid argument.

For reference I login as project owner and have enabled services gkeconnect.googleapis.com, gkehub.googleapis.com , anthos.googleapis.com. Corresponding gcloud, kubectl and other python clients work fine (e.g. gkehub).

API client name and version

google-cloud-gke-connect-gateway v0.10.3

Reproduction steps: code

file: main.py

from google.cloud.gkeconnect import gateway_v1

project_id = "myproject-1234"
location = "us-east1"
cluster_name = "cluster-dev-us-e1-aa11ff"
name = f"projects/{project_id}/locations/{location}/memberships/{cluster_name}"

client = gateway_v1.GatewayControlClient()
request = gateway_v1.GenerateCredentialsRequest(name=name)
response = client.generate_credentials(request=request)

Result:

BadRequest: 400 GET https://connectgateway.googleapis.com/v1/projects/myproject-1234/locations/us-east1/memberships/cluster-dev-us-e1-aa11ff:generateCredentials?%24alt=json%3Benum-encoding%3Dint: Request contains an invalid argument.

Same behaviour using for correct region us-east1 or even global.

Corresponding gcloud command works fine:

> gcloud container fleet memberships get-credentials cluster-dev-us-e1-aa11ff --project myproject-1234
Fetching Gateway kubeconfig...
A new kubeconfig entry "connectgateway_myproject-1234_us-east1_cluster-dev-us-e1-aa11ff" has been generated and set as the current context.

A similar gkehub client works fine for the same membership_name

from google.cloud import gkehub_v1

client = gkehub_v1.GkeHubClient()

membership_name = f'projects/{project_id}/locations/{location}/memberships/{cluster_name}'
request = gkehub_v1.GetMembershipRequest(name=membership_name)
response = client.get_membership(request=request)

print(response)

Reproduction steps: supporting files

No response

Reproduction steps: actual results

No response

Reproduction steps: expected results

No response

OS & version + platform

Ubuntu 24.04

Python environment

Python 3.12.3

Python dependencies

google-cloud-gke-connect-gateway

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions