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

feat(scaler/prometheus): support authentication for Google Managed Prometheus #4675

Merged

Conversation

nettoclaudio
Copy link
Contributor

@nettoclaudio nettoclaudio commented Jun 9, 2023

This PR adds Google's authentication in order to access metrics from Google Managed Prometheus.

Checklist

Fixes #4674

Relates to kedacore/keda-docs#1153

@nettoclaudio nettoclaudio requested a review from a team as a code owner June 9, 2023 13:50
@github-actions
Copy link

github-actions bot commented Jun 9, 2023

Thank you for your contribution! 🙏 We will review your PR as soon as possible.

While you are waiting, make sure to:

Learn more about:

Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
@nettoclaudio nettoclaudio force-pushed the feat/support-google-managed-prometheus branch from b1387ca to d856d49 Compare June 9, 2023 13:56
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
@nettoclaudio nettoclaudio force-pushed the feat/support-google-managed-prometheus branch from d4f74cd to bf5e83b Compare June 9, 2023 14:06
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
Copy link
Member

@JorTurFer JorTurFer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! ❤️
Could you add an e2e test too? You can add any required service/permission using the testing-infrastructure repository. We manage the infrestructure using terraform 😄

@nettoclaudio
Copy link
Contributor Author

Sure, I do. Although I think I'll need an extra hand to configure it correctly. 😬

Firstly, can you clarify some doubts about the infrastructure?

  1. As far as I understood in the GCP module of testing-infrastructure, we just configure IAM to access stuff from the AKS cluster. All the e2e tests run there (AKS), right? Is there some chance to run a GKE cluster as well? If not, we will need configure a Prometheus (e.g. Prometheus Agent) to export to metrics to Google Managed Prometheus. (read more)

  2. Just double checking. In the GCP module I see a few resources configuring the workload identity pools/providers. Is that a federation between Azure and GCP IAM? If so, the resulting service account key in the ouput output.e2e_user_credentials has admin permission in the e2e's GCP project? If a just create a Deployment in the AKS cluster, they will be able to successfully autheticate in the GCP using workload identity?

@JorTurFer
Copy link
Member

Sure, you can ask whatever you need 😄 (we have a Slack channel in Kubernetes workspace for development stuff if you prefer that channel to be faster during the development)

As far as I understood in the GCP module of testing-infrastructure, we just configure IAM to access stuff from the AKS cluster. All the e2e tests run there (AKS), right? Is there some chance to run a GKE cluster as well? If not, we will need configure a Prometheus (e.g. Prometheus Agent) to export to metrics to Google Managed Prometheus. (read more)

We prefer to run all the test in AKS if it's possible, otherwise we'd need to manage multiple clusters in different platforms for main and also for PRs (there are 2 different clusters). If we need to export metrics, we could use opentelemetry collector to export the metrics to there using the googlemanagedprometheusexporter but I don't think that's necessary. I mean, as this test won't test the prometheus scaler behavior itself but the authentication, we could just use an scalar query in the ScaledObject and just update it updating the scaled object. We are already doing it for some tests: https://github.com/kedacore/keda/blob/main/tests/scalers/azure/azure_log_analytics/azure_log_analytics_test.go#L119

Just double checking. In the GCP module I see a few resources configuring the workload identity pools/providers. Is that a federation between Azure and GCP IAM? If so, the resulting service account key in the ouput output.e2e_user_credentials has admin permission in the e2e's GCP project? If a just create a Deployment in the AKS cluster, they will be able to successfully autheticate in the GCP using workload identity?

The federation between KEDA and GCP is already done. KEDA can access to GCP resources using workload identity federation (for example, this). I think that for this tests you need to:

  • create the managed prometheus resource
  • assign the required roles to the already existing account (this maybe it's not needed because the account is already owner)
  • export the required variables like the prometheus url as GH secret
  • as we mount all the secrets as envs during e2e tests, you can read them directly from there during the e2e tests and setup the tests
  • execute the test

As I said, the federation is already done , the mutating webhook is already there, and everything should be working for just adding the extra required info for the new tests

@nettoclaudio
Copy link
Contributor Author

Got it... thank you so much, Jorge.

I mean, as this test won't test the prometheus scaler behavior itself but the authentication, we could just use an scalar query in the ScaledObject and just update it updating the scaled object.

I absolutely agree. Whaterever rather than unauthenticated status code should be enough in this test case. So gimme a bunch of minutes trying to create it.

@JorTurFer
Copy link
Member

Sure, let me know if I can help with something 😄

Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
Signed-off-by: Claudio Netto <nettinhorama@gmail.com>
@JorTurFer
Copy link
Member

JorTurFer commented Jun 13, 2023

/run-e2e gcp
Update: You can check the progress here

@JorTurFer JorTurFer merged commit b8a8d57 into kedacore:main Jun 13, 2023
@nettoclaudio nettoclaudio deleted the feat/support-google-managed-prometheus branch June 13, 2023 23:50
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

Successfully merging this pull request may close these issues.

Support for Google Managed Prometheus on Prometheus Scaler
2 participants