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

[RFE] Add support for OpenCost in KubePlus #1287

Open
Tracked by #683
chiukapoor opened this issue Jun 2, 2024 · 5 comments
Open
Tracked by #683

[RFE] Add support for OpenCost in KubePlus #1287

chiukapoor opened this issue Jun 2, 2024 · 5 comments

Comments

@chiukapoor
Copy link
Contributor

Description:

As KubePlus aims to provide a comprehensive solution for managing multi-instance multi-tenancy (MIMT) applications on Kubernetes, it would be beneficial to integrate support for OpenCost into the project.

Overview:

OpenCost is a cost management platform that provides insights and analytics into resource utilization and spending within Kubernetes clusters. By adding support for OpenCost into KubePlus, users will gain visibility into the resource consumption and associated costs of each application instance deployed using KubePlus.

Proposal:

Integration: Implement functionality within KubePlus to capture resource consumption data for each application instance.
Data Export: Define an interface for exporting resource consumption data to OpenCost in a compatible format.
Documentation: Update KubePlus documentation to include instructions on configuring and using the OpenCost integration.
Testing: Conduct thorough testing to ensure the reliability and accuracy of the OpenCost integration.

Benefits:

Cost Visibility: Users will have clear insights into each application instance's resource usage and associated costs.
Optimization: With visibility into resource consumption, users can optimize their deployments to minimize costs and maximize efficiency.
Billing: Enables billing and chargeback mechanisms based on actual resource usage.

@devdattakulkarni
Copy link
Contributor

Do we know what is the data format expected by opencost?

We have a kubectl plugin (kubectl metrics), which collects per-application resource consumption metrics (CPU, memory, storage, network ingress, network egress). We can enhance this plugin to generate output that is expected by opencost.

@devdattakulkarni devdattakulkarni mentioned this issue Jun 5, 2024
16 tasks
@chiukapoor
Copy link
Contributor Author

chiukapoor commented Jul 10, 2024

@devdattakulkarni I deployed opencost with default pricing and it is working out of the box.
image

For more deep integration with kubeplus we can use opencost api or kubectl plugin

We can use a hybrid approach of using opencost kubectl plugin and wrapping it around by kubeplus additionally if we require custom kubeplus oriented features which are not already present in opencost kubectl plugin we can implement it using opencost API.

@devdattakulkarni
Copy link
Contributor

Thanks for trying out opencost @chiukapoor

Is the cost calculated from the time the application/namespace is created? Also, can opencost tell us what all Pods are considered when calculating the cost for a given namespace? (I assume that all the Pods in a namespace are being used, but it will be good to verify).

I think it will be good to add a kubeplus kubectl plugin, rather than telling users to install opencost and then use opencost plugin. From multi-instance multi-tenancy perspective, knowing the ongoing spend per application instance will be useful for application providers. So we should provide this functionality as part of kubeplus.

We can call the plugin kubectl appcost, similar to kubectl appresources.

The input for the plugin can look as follows:
kubectl appcost <Custom Resource> <instance-name> –k <provider-kubeconfig>
e.g.:
kubectl appcost WordpressService wp-tenant1 –k kubeplus-saas-provider.json

The command inputs are similar to kubectl appresources plugin that we currently have.

The plugin will check if opencost is running on the cluster first. If it is running then it can call the opencost api to retrieve cost for the namespace corresponding to the app name.

Share your thoughts.

I am excited to get this functionality included as part of KubePlus. Also, it seems it will be straightforward to add.

@chiukapoor
Copy link
Contributor Author

Also, can opencost tell us what all Pods are considered when calculating the cost for a given namespace?

Yes, it considers that the cost for all the pods is calculated for a given namespace.

rather than telling users to install opencost and then use opencost plugin.

The user will need to install opencost to use the functionality, what we can do is have a script which installs Kubeplus and the script will have a parameter that the user can pass to install opencost as well for the cost calculation functionality.

I think it will be good to add a kubeplus kubectl plugin

Yes, I am looking for the possibility of wrapping kubecost plugin in kubeplus kubectl plugin so that we can use all the kubecost plugin commands directly inside kubeplus kubectl plugin.

@devdattakulkarni
Copy link
Contributor

@chiukapoor Sounds like a good plan.

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

2 participants