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: support multi account Datadog metrics provider #3787

Merged
merged 12 commits into from
Aug 27, 2024

Conversation

ariadnarouco
Copy link
Contributor

@ariadnarouco ariadnarouco commented Aug 13, 2024

Summary

This pull adds ability to use namespaced credentials for Datadog metrics provider.

Background

Our use case involves an Argo Rollout that operates across multiple namespaces, each managed by tenants with distinct Datadog accounts. As a result, multiple credentials are needed to integrate seamlessly with Datadog.

Implementation

This setup will allow users to use different credentials than the one setup as default, which is a secret named "datadog" deployed in the same namespaces as the rollouts controller [refer to doc].

This way the users can manage their datadog credentials with the name they want and in their own namespace.

The process suggested within this PR for retrieving Datadog credentials is as follows:
1. If a secretRef is defined in the AnalysisTemplate: Argo Rollouts will search for the secret with the specified name in the namespace where the template resides.
2. If the secret is not found in the specified namespace: Argo Rollouts will then check the environment variables.
3. If the credentials are not found in environment variables: Argo Rollouts will look for a secret named "Datadog" in the namespace where Argo Rollouts itself is deployed.

Notes:
Based on the code, to have more than one set of credentials is not possible. I also created a question for this which remains unanswered

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional with a list of types and scopes found here, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 93.65079% with 4 lines in your changes missing coverage. Please review.

Project coverage is 83.89%. Comparing base (23e186e) to head (52dc2e6).
Report is 56 commits behind head on master.

Files with missing lines Patch % Lines
metricproviders/datadog/datadog.go 90.90% 1 Missing and 1 partial ⚠️
metricproviders/metricproviders.go 50.00% 1 Missing ⚠️
pkg/kubectl-argo-rollouts/info/pod_info.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3787      +/-   ##
==========================================
+ Coverage   83.87%   83.89%   +0.02%     
==========================================
  Files         162      163       +1     
  Lines       18524    18548      +24     
==========================================
+ Hits        15537    15561      +24     
+ Misses       2119     2117       -2     
- Partials      868      870       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Aug 13, 2024

Published E2E Test Results

  4 files    4 suites   3h 13m 39s ⏱️
113 tests 104 ✅  7 💤 2 ❌
458 runs  424 ✅ 28 💤 6 ❌

For more details on these failures, see this check.

Results for commit 52dc2e6.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Aug 13, 2024

Published Unit Test Results

2 270 tests   2 270 ✅  2m 58s ⏱️
  128 suites      0 💤
    1 files        0 ❌

Results for commit 52dc2e6.

♻️ This comment has been updated with latest results.

@zachaller zachaller added this to the v1.8 milestone Aug 13, 2024
interval: 5m
secretRef:
name: "mysecret"
namespaced: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

I knid of think we just drop this field namespaced, i think the presence of a secretRef just means look up secret in the namespace of the AnalysisTemplate. At a later date we can then add a namespace field to secretRef if we want to support cross namespace lookups. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @zachaller
Thanks for the review and the input.

When implementing this feature we discussed the different use-cases and we thought about the following ones:

  1. As an argo rollout owner, you also own the integration with a single DataDog account.
  2. As an argo rollout owner, you also own the integration with several DataDog accounts
  3. As an argo rollout owner, you only own argo rollout and your users own the DataDog ones.

The first case is the currently supported case.

The second case corresponds to namespaced: false, and let the "rollouts administrator" to manage different DataDog integrations by providing well-known secret names to the namespace users.

The third one corresponds to namespaced: true, where namespace users were completely autonomous to manage the DataDog account integration.

We did consciously exclude the option to have a configurable namespace string to maximise security.
Indeed, we want the owners of, say, namespace-a AnalysisTemplates and DataDog integrations to have confidence that they will control who can access their metrics.

Having a configurable free text namespace would allow users of any other namespace to indirectly access DataDog metrics, which would then break the namespace principles.

WDYT?

@ariadnarouco ariadnarouco force-pushed the datadog-multi-account branch 3 times, most recently from dd3fc56 to c1ade6a Compare August 20, 2024 13:35
ariadnarouco and others added 12 commits August 27, 2024 13:27
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
…sis template.

Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
Co-authored-by: Thibault Jamet <tjamet@users.noreply.github.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
(cherry picked from commit 36a9c06)
Signed-off-by: Ariadna Rouco <ariadna.rouco@adevinta.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@gmail.com>
(cherry picked from commit 7703ff9)
Signed-off-by: Ariadna Rouco <ariadna.rouco@adevinta.com>
(cherry picked from commit eab99be)
Signed-off-by: Ariadna Rouco <ariadna.rouco@adevinta.com>
Signed-off-by: Ariadna Rouco <ariadna.rouco@adevinta.com>
@ariadnarouco ariadnarouco force-pushed the datadog-multi-account branch from 4a8e86c to 52dc2e6 Compare August 27, 2024 11:28
Copy link

@zachaller zachaller merged commit bfef7f0 into argoproj:master Aug 27, 2024
25 checks passed
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.

3 participants