Skip to content

First attempt of apply recommendations#5

Merged
josefkarasek merged 12 commits into
kedify:mainfrom
josefkarasek:recommendations
Jun 23, 2026
Merged

First attempt of apply recommendations#5
josefkarasek merged 12 commits into
kedify:mainfrom
josefkarasek:recommendations

Conversation

@josefkarasek

@josefkarasek josefkarasek commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Add kedify apply recommendations for Helm values patching

kedify apply recommendations deployment/<NAME> \
  --namespace <NAMESPACE> \
  --chart-path <PATH> \
  --values-file <PATH> \
  --recommendations-file <PATH> \
  [--container <CONTAINER>] \
  [--resources cpu-requests,cpu-limits,memory-requests,memory-limits] \
  [--min-confidence 60] \
  [--format json|diff|override] \
  [--output-file <PATH>] \
  [--dry-run]

The command applies Kedify recommendations to a Helm values file for a specific workload.

Arguments

  • deployment/<NAME>
    Target workload in kind/name form. v1 currently supports deployment.
  • --namespace
    Namespace of the target workload.
  • --chart-path
    Path to the Helm chart to render and verify against.
  • --values-file
    Path to the Helm values file to patch.
  • --recommendations-file
    Path to a saved recommendations JSON/YAML file.
  • --container
    Optional container filter. If omitted, the command matches all recommendation-bearing containers in the workload.
  • --resources
    Optional comma-separated resource list:
    cpu-requests, cpu-limits, memory-requests, memory-limits.
    If omitted, all available recommendations are applied per matched container.
  • --min-confidence
    Inclusive confidence threshold. Defaults to 60.
  • --format
    Output mode:
    • json for machine-readable plan/result
    • diff for unified diff against the values file
    • override for a generated override values file
  • --output-file
    Required when --format override is used without --dry-run.
  • --dry-run
    Computes the result without writing files.

Behavior

  • Renders the Helm chart and verifies the workload/container mapping before patching.
  • Patches only explicit values mappings.
  • For multi-container workloads, patches all matched containers only if every matched container is safely patchable.
  • Fails with structured reasons like not_found, ambiguous, unsupported, and below_confidence_threshold.

Example

$ kedify apply recommendations deployment/keda-operator \
    --namespace keda \
    --chart-path ./test/chart \
    --values-file ./test/chart/values.yaml \
    --recommendations-file ./test/recommendations.json \
    --min-confidence 20 \
    --format override \
    --output-file override-values.yaml
deployments:
    kedaOperator:
        containers:
            auditSidecar:
                resources:
                    limits:
                        cpu: 50m
                        memory: 72Mi
                    requests:
                        cpu: 10m
                        memory: 24Mi
            operator:
                resources:
                    limits:
                        cpu: 100m
                        memory: 138Mi
                    requests:
                        cpu: 20m
                        memory: 46Mi

Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
@josefkarasek josefkarasek requested a review from a team as a code owner June 18, 2026 12:54
Copilot AI review requested due to automatic review settings June 18, 2026 12:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds initial support for discovering and applying Kedify rightsizing recommendations, including new CLI subcommands and improved text rendering for recommendation outputs.

Changes:

  • Introduces kedify apply recommendations to patch Helm values (diff/override/json modes) based on a recommendations payload.
  • Adds kedify list recommendations <cluster-id> and kedify auth token, and reorganizes auth commands under kedify auth ....
  • Extends output formatting to render recommendations as a table in text output, plus adds sample chart/data for testing.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/chart/values.yaml Adds a sample values file with explicit resource blocks for patching tests.
test/chart/templates/deployments.yaml Adds a minimal Helm template set used to validate rendered workload/container existence.
test/chart/Chart.yaml Adds a Helm chart definition for the test fixture.
recommendations.json Adds a sample recommendations payload used by tests and demos.
README.md Updates CLI usage docs for new auth subcommands and recommendations listing.
internal/output/output.go Adds heuristic text rendering for recommendation lists (table output).
internal/output/output_test.go Adds tests for recommendation table rendering and YAML fallbacks.
internal/cli/run.go Adds new top-level commands and introduces commandResultError handling with JSON payload output.
internal/cli/recommendations.go Implements list recommendations command wiring to API client + output formatting.
internal/cli/commands_test.go Extends fakes and adds tests for auth token and list recommendations.
internal/cli/auth_token.go Implements kedify auth token printing the resolved token to stdout.
internal/cli/apply_recommendations.go Implements the Helm values patching workflow for recommendations (diff/override/json).
internal/cli/apply_recommendations_test.go Adds end-to-end-ish tests for apply modes using the sample chart + recommendations.
internal/api/client.go Refactors pagination into generic helpers and adds recommendations endpoint support.
internal/api/client_test.go Adds tests for recommendations endpoint behavior incl. pagination/non-paginated fallback.
docs/apply-recommendation.md Documents the v1 design/shape for applying recommendations.
AGENTS.md Documents a new repo convention: automatically read all pages for paginated API endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/output/output.go
Comment thread internal/api/client.go
Comment thread internal/cli/apply_recommendations.go Outdated
Comment thread internal/cli/apply_recommendations.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread docs/apply-recommendation.md
Comment thread docs/apply-recommendation.md
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Comment thread internal/cli/apply_recommendations.go Fixed
Comment thread internal/cli/apply_recommendations.go Fixed
Comment thread internal/cli/apply_recommendations.go Fixed
Comment thread internal/cli/apply_recommendations.go Fixed
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 22, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 8 comments.

Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations.go
Comment thread docs/apply-recommendation.md
Comment thread docs/apply-recommendation.md
Comment thread internal/api/client.go Outdated
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 23, 2026 12:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.

Comment thread internal/cli/apply_recommendations.go
Comment thread internal/cli/apply_recommendations.go
Comment thread internal/output/output.go
Comment thread internal/cli/apply_recommendations.go
Comment thread internal/cli/apply_recommendations.go Outdated
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 23, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 6 comments.

Comment thread internal/output/output.go
Comment thread internal/output/output.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread docs/apply-recommendation.md
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 23, 2026 15:00
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.

Comment thread internal/output/output.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations_test.go
Comment thread internal/cli/apply_recommendations_test.go
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 23, 2026 15:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Comment thread internal/cli/apply_recommendations.go Outdated
Comment thread internal/api/client.go Outdated
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
@josefkarasek josefkarasek merged commit 2802d4b into kedify:main Jun 23, 2026
2 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.

4 participants