Open karlkfi opened 3 years ago
If I'm reading the source correctly, it looks like the adapter uses the https://godoc.org/cloud.google.com/go/compute/metadata#ProjectID function from the Go SDK to lookup the Project ID
https://github.com/GoogleCloudPlatform/k8s-stackdriver/blob/master/custom-metrics-stackdriver-adapter/adapter.go#L102 https://github.com/GoogleCloudPlatform/k8s-stackdriver/blob/master/custom-metrics-stackdriver-adapter/pkg/config/gce_config.go#L41
Unfortunately, it sounds like that function doesn't pay attention to any of the standard environment variables that are standard as overrides in the python SDK.
And when a common helper function was requested, the behavior was instead added into specific feature clients, instead of the generic function being used by the adapter. https://github.com/googleapis/google-cloud-go/issues/1294
So it seems like we may need to add explicit support for GOOGLE_CLOUD_PROJECT and/or GOOGLE_CLOUD_PROJECT into the adapter code to allow specifying a different project.
Also, with the new Workspace design that allows projects to be in multiple workspaces, we need to specify the workspace's host project, not just a member project.
The custom-metrics-stackdriver-adapter exposes Stackdriver metrics as Kubernetes Prometheus metrics using the External Metrics API.
But AFAICK, when deployed on GKE, the adapter only exposes metrics from the same project the GKE cluster is in.
I assume the adapter is configurable, and doesn't require using GKE, which means the project ID should probably be configurable, but I can't figure out how to configure it.
My use case is that on a multi-tenant GKE, each tenant has their own GCP Project, where they manage their SaaS, like databases and pubsub. So I want to be able to use custom metrics to autoscale based on metrics from multiple projects.