Skip to content

Add HPA (Horizontal Pod Autoscaler) support — replicas currently can only be changed manually #20

@tangxiaoxin06

Description

@tangxiaoxin06

Background

ApplicationPerformanceConfig.EnvironmentConfig (src/main/java/com/github/wellch4n/oops/data/ApplicationPerformanceConfig.java) only exposes:

  • replicas
  • cpuRequest / cpuLimit
  • memoryRequest / memoryLimit

Replicas are a static number. When traffic spikes, operators have to manually change replicas in the UI and redeploy, which is below the baseline expectation for a
modern PaaS.

Problems

  1. No reaction to traffic spikes: flash sales / external events require someone watching dashboards and scaling manually — slow response risks outages.
  2. Waste during off-peak: no automatic scale-down at night / weekends → idle CPU and memory.
  3. Breaks the single source of truth: HPA is a core K8s primitive. Since OOPS doesn't expose it, users either accept the limitation or create HPAs out-of-band with
    kubectl, which bypasses OOPS's management model.

Proposal

Add an optional autoscaling sub-object on EnvironmentConfig. When absent, behavior is identical to today:

public static class AutoscalingConfig {
private Boolean enabled;
private Integer minReplicas;
private Integer maxReplicas;
private Integer targetCpuUtilization; // e.g. 70 for 70%
private Integer targetMemoryUtilization; // optional
}

In ArtifactDeployTask:

  • autoscaling.enabled false / null → keep writing spec.replicas as today
  • autoscaling.enabled true → also create/update a HorizontalPodAutoscaler (autoscaling/v2); stop forcing spec.replicas to avoid fighting the HPA controller

Frontend: in the Performance tab, add an "Enable autoscaling" toggle per environment, revealing min / max / target utilization fields.

Compatibility

  • New fields are optional — existing records are untouched
  • Disabling the toggle should delete the HPA to avoid orphans
  • StatefulSet + HPA is supported by autoscaling/v2

Scope

  • Backend: ApplicationPerformanceConfig, ArtifactDeployTask, possibly a new HpaManager
  • Frontend: application-performance-info.tsx, schema.ts
  • DB: new fields inside the JSON blob — no migration needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions