-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add --opencost
flag to setup standard OpenCost configuration
#173
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I no longer work at Kubecost, but this is how I would have done it. LGTM.
if o.OpenCost { | ||
o.ServiceName = OpenCostServiceName | ||
o.KubecostNamespace = OpenCostServiceNamespace | ||
o.ServicePort = OpenCostServicePort | ||
o.AllocationPath = OpenCostAllocationPath | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done, I appreciate that the opencost defaults first, and then additional flags can override field-by-field.
pkg/query/options.go
Outdated
@@ -92,6 +109,7 @@ func AddQueryBackendOptionsFlags(cmd *cobra.Command, options *QueryBackendOption | |||
cmd.Flags().BoolVar(&options.UseProxy, "use-proxy", false, "Instead of temporarily port-forwarding, proxy a request to Kubecost through the Kubernetes API server.") | |||
cmd.Flags().StringVar(&options.AllocationPath, "allocation-path", "/model/allocation", "URL path at which Allocation queries can be served from the configured service. If using OpenCost, you may want to set this to '/allocation/compute'") | |||
cmd.Flags().StringVar(&options.PredictSpecCostPath, "predict-speccost-path", "/model/prediction/speccost", "URL path at which Prediction queries can be served from the configured service.") | |||
cmd.Flags().BoolVar(&options.OpenCost, "opencost", false, " Set true to configure Kubecost parameters according to the OpenCost default specification.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth calling out the defaulting behavior in the help text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially thought it would be a little too verbose, but it will indeed make things clearer. I will commit the changes as soon as I get the chance. Thanks for the review!
What does this PR change?
This Pull Request adds the
--opencost
flag to the cost command to setup standard OpenCost configuration. It is essentially an alias for the following flags:--service-port 9003 --service-name opencost --kubecost-namespace opencost --allocation-path /allocation/compute
Does this PR rely on any other PRs?
N/A
How does this PR impact users? (This is the kind of thing that goes in release notes!)
The user will have the possibility to easily set OpenCost as the target service to the
kubectl cost
command by simply setting the--opencost
instead of configuring the OpenCost default settings flag-by-flag.Links to Issues or ZD tickets this PR addresses or fixes
--opencost
flag to specify standard OpenCost settings #156How was this PR tested?
This Pull Request was tested in an Oracle Kubernetes Engine (OKE)-based Kubernetes cluster configured with OpenCost and identical behaviour with providing the following flags was asserted:
--service-port 9003 --service-name opencost --kubecost-namespace opencost --allocation-path /allocation/compute
Have you made an update to documentation?
An update was made in the README.md file.