Skip to content

Add savings subcommand for request sizing recommendations#224

Open
pierluigilenoci wants to merge 2 commits intokubecost:mainfrom
pierluigilenoci:feat/savings-command
Open

Add savings subcommand for request sizing recommendations#224
pierluigilenoci wants to merge 2 commits intokubecost:mainfrom
pierluigilenoci:feat/savings-command

Conversation

@pierluigilenoci
Copy link
Copy Markdown

Summary

  • Adds a new kubectl cost savings subcommand that queries the Kubecost /model/savings/requestSizingV2 API
  • Displays container-level request sizing recommendations with current vs recommended CPU/RAM requests, efficiency percentages, and estimated monthly savings
  • Follows the existing command pattern (predict-style) with --window flag (default 2d) and standard query backend flags

New files

  • pkg/query/savings.go — query layer for the savings/requestSizingV2 API
  • pkg/cmd/display/savings.go — table rendering with go-pretty (sorted by savings descending, total in footer)
  • pkg/cmd/savings.go — cobra command with options struct, Complete/Validate/Run lifecycle

Modified files

  • pkg/cmd/cost.go — registers the new savings subcommand

Example output columns

Namespace | Controller | Container | Current CPU | Rec. CPU | Current RAM | Rec. RAM | CPU Eff. | RAM Eff. | Savings/mo

Closes #84

cc @dwbrown2 @michaelmdresser

Adds `kubectl cost savings` which queries the Kubecost
/model/savings/requestSizingV2 API and displays container-level
request sizing recommendations with estimated monthly savings.

Closes kubecost#84

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
- Add unit tests for MakeSavingsTable and WriteSavingsTable covering
  empty input, single record, multiple records with sort order, and
  total calculation
- Fix descending sort by pre-sorting the recommendations slice instead
  of relying on go-pretty's DscNumeric which doesn't work correctly
  with Transformer-formatted values
- Add savings command to integration test script

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@pierluigilenoci
Copy link
Copy Markdown
Author

@michaelmdresser @kaelanspatel @cliffcolvin could you please take a look at this PR when you get a chance? Thanks!

@pierluigilenoci
Copy link
Copy Markdown
Author

Gentle ping — this PR has been open for over a week now. Could someone take a look when you get a chance? Happy to address any feedback. Thank you!

@pierluigilenoci
Copy link
Copy Markdown
Author

Hi @michaelmdresser, @kaelanspatel, @cliffcolvin -- friendly follow-up. CI is green and this PR has been waiting for review for a few weeks now. Would love to get this moving forward. Happy to address any feedback or make adjustments. Thank you!

@pierluigilenoci
Copy link
Copy Markdown
Author

Hi @thomasvn — friendly ping on this PR which adds a savings subcommand for request sizing recommendations. Happy to address any feedback or make changes. Thanks!

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.

[FR] Savings statistics available with CLI

1 participant