Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you configure custom-metrics-stackdriver-adapter to expose external metrics from a different project? #411

Open
karlkfi opened this issue Apr 15, 2021 · 1 comment

Comments

@karlkfi
Copy link

karlkfi commented Apr 15, 2021

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.

  1. Is it even possible to configure the project ID?
  2. Is it possible to monitor multiple projects with the same adapter?
  3. If the adapter can only monitor one project, can multiple adapters by used in parallel to monitor multiple projects?

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.

@karlkfi
Copy link
Author

karlkfi commented Apr 26, 2021

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. googleapis/google-cloud-go#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant