Skip to content

Add HPA example and fix autoscaling support (#13) - #56

Merged
ricardozanini merged 2 commits into
kubesmarts:mainfrom
ricardozanini:issues/13
Oct 1, 2026
Merged

ricardozanini merged 2 commits into
kubesmarts:mainfrom
ricardozanini:issues/13

Conversation

@ricardozanini

Copy link
Copy Markdown
Contributor

Summary

Complete issue #13: Runtime Autoscaling support by:

  1. Removing kubebuilder default from ApplicationSpec.Replicas to allow HPA override
  2. Adding comprehensive HPA example to production checklist
  3. Documenting that users create HPA themselves (operator doesn't)

Changes

  • api/v1/deployment_types.go — Remove +kubebuilder:default=1 from Replicas field; update doc to clarify HPA behavior
  • config/crd/bases/ — Regenerated CRDs without default replica value
  • docs/antora/modules/ROOT/pages/deployment/production.adoc — Add HPA example and clarify operator's lease management

How it works

When spec.replicas is omitted:

  • Kubernetes Deployment defaults to 1 replica (no operator override)
  • HorizontalPodAutoscaler can freely scale the Deployment
  • Operator reconciliation doesn't interfere (no revert to 1)

Existing lease management (scale up/down) already handles dynamic replica changes.

E2E Coverage

Autoscaling is tested in test/e2e/durable_test.go:

  • Verifies 3 replicas with leases created
  • Scales down to 1 replica
  • Verifies excess leases safely removed

Closes #13

… override

When users omit `spec.replicas`, the field stays nil and the controller
doesn't enforce a value, allowing HorizontalPodAutoscaler to manage scaling
freely without interference from reconciliation loops.

Updates ApplicationSpec documentation to clarify this behavior and regenerates CRDs.

Closes kubesmarts#13
Copilot AI balanced review requested due to automatic review settings October 1, 2026 19:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The documented HPA target bypasses durable lease scaling, while removing the default undermines the existing scale subresource.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Updates runtime autoscaling defaults and documentation, but currently targets the Deployment instead of the runtime scale subresource.

Changes:

  • Removes the default replica value from shared application schemas.
  • Regenerates affected CRDs.
  • Adds an HPA production example.
File Description
api/​v1/​deployment_types.go Changes replica defaulting behavior.
config/​crd/​bases/​logic.kubesmarts.org_logicplatforms.yaml Regenerates platform schemas.
config/​crd/​bases/​logic.kubesmarts.org_logicflowruntimes.yaml Regenerates runtime schema.
docs/​antora/​modules/​ROOT/​pages/​deployment/​production.adoc Documents HPA configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread api/v1/deployment_types.go Outdated
Comment thread docs/antora/modules/ROOT/pages/deployment/production.adoc Outdated
…eting

- Add mutating webhook to default LogicFlowRuntime.spec.replicas=1
- Remove kubebuilder default from ApplicationSpec to allow LogicPlatform.DataIndex HPA management
- Register defaulter in webhook manager and test setup
- Regenerate CRDs with updated ApplicationSpec (no default)

Update HPA documentation:
- Clarify that LogicFlowRuntime HPA must target the CR (not Deployment) for lease reconciliation
- Add separate Data Index HPA section targeting the Deployment
- Explain why: leases derive desired count from spec.replicas, so HPA must update the CR
- Data Index can omit replicas to let HPA manage freely

This enables HPA on both runtimes (via scale subresource) and Data Index (via nil replicas).
@ricardozanini
ricardozanini merged commit 229964c into kubesmarts:main Oct 1, 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.

Runtime Autoscaling

2 participants