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

Enable Custom Pricing Provider in OpenCost for Public Cloud Kubernetes Clusters #2434

Merged
merged 10 commits into from
May 16, 2024

Conversation

janlauber
Copy link
Contributor

@janlauber janlauber commented Jan 4, 2024

What does this PR change?

This PR introduces the ability to enforce the use of a custom pricing provider in OpenCost when deployed on GCP or other public cloud Kubernetes clusters. Previously, deploying on these platforms automatically defaulted to their respective public cloud providers, requiring API keys for pricing information. Now, users can activate a custom provider by setting USE_CUSTOM_PROVIDER=true, enabling custom pricing without the need for API keys.

Does this PR relate to any other PRs?

  • No

How will this PR impact users?

  • This change affects users who opt to use the custom provider feature by setting the environment variable USE_CUSTOM_PROVIDER=true in the OpenCost container.
  • Allows greater flexibility and control over pricing data sources, particularly beneficial for users who prefer not to use public cloud provider API keys.

Does this PR address any GitHub or Zendesk issues?

How was this PR tested?

Tested using a custom OpenCost image (ghcr.io/janlauber/opencost:v1.109.0) deployed in a GCP cluster, confirming the ability to utilize custom pricing with USE_CUSTOM_PROVIDER set to "true".

Does this PR require changes to documentation?

  • I think not, but it would be nice to set a note anywhere

Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?

Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
Copy link

vercel bot commented Jan 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
opencost ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2024 4:30pm

@AjayTripathy
Copy link
Contributor

Seems reasonable. Thanks for this PR! @thomasvn mind picking up this review when you get a moment?

Copy link

sonarcloud bot commented Jan 4, 2024

@thomasvn
Copy link
Contributor

thomasvn commented Jan 5, 2024

Thanks @janlauber for the PR! I've added some comments to the associated Github issue.

@thomasvn
Copy link
Contributor

@janlauber So the intended effect here is that if the user specifies USE_CUSTOM_PROVIDER=true and are not using a CSV provider, then OpenCost will default to using the pricing found in default.json?

@janlauber
Copy link
Contributor Author

@thomasvn yes, this is the intended effect.

@mattray mattray added opencost OpenCost issues vs. external/downstream P2 Estimated Priority (P0 is highest, P4 is lowest) kubecost Relevant to Kubecost's downstream project E2 Estimated level of Effort (1 is easiest, 4 is hardest) labels Jan 16, 2024
Copy link
Contributor

@thomasvn thomasvn left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

@janlauber
Copy link
Contributor Author

Any news so far?

Copy link
Contributor

@michaelmdresser michaelmdresser left a comment

Choose a reason for hiding this comment

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

This seems logical, but I'd like to hear Sean's thoughts. I also just approved this PR to run CI, so we want to make sure that passes too (I assume it will).

Comment on lines 282 to 289
// Check for custom provider settings
if env.IsUseCustomProvider() {
// Use CSV provider if set
if env.IsUseCSVProvider() {
cp.provider = kubecost.CSVProvider
}
return cp
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@Sean-Holcomb do you see any downside to this short-circuit?

Copy link

github-actions bot commented May 1, 2024

This pull request has been marked as stale because it has been open for 90 days with no activity. Please remove the stale label or comment or this pull request will be closed in 5 days.

@github-actions github-actions bot added the Stale label May 1, 2024
@janlauber
Copy link
Contributor Author

any news here?

@mattray
Copy link
Collaborator

mattray commented May 1, 2024

Do any @opencost/opencost-maintainers want to weigh in on this (assuming the test ges fixed)?

@github-actions github-actions bot removed the Stale label May 2, 2024
Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
@janlauber
Copy link
Contributor Author

I've fixed the code

@janlauber
Copy link
Contributor Author

So let's get this merged?

Copy link

sonarcloud bot commented May 16, 2024

@mattray mattray merged commit 318fe4c into opencost:develop May 16, 2024
4 checks passed
@janlauber janlauber deleted the fix-custom-provider branch May 19, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2 Estimated level of Effort (1 is easiest, 4 is hardest) kubecost Relevant to Kubecost's downstream project needs-follow-up opencost OpenCost issues vs. external/downstream P2 Estimated Priority (P0 is highest, P4 is lowest)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opencost auto-defines cluster as GCP and crushes due to the missing GCP key
6 participants