feat: add script to manage hpa #1318
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature: Versatile HPA Management Script with Dry Run
This commit introduces the comprehensive manage_hpa.sh utility to safely lock and unlock Kubernetes Horizontal Pod Autoscalers (HPAs) across all namespaces. This is primarily intended for pre-maintenance operations where unexpected scaling must be prevented.
The script's core function is to set maxReplicas equal to minReplicas (locking the HPA) and then reliably restore the original maxReplicas value.
Key Features and Improvements
Execution Instructions
The script requires jq to be installed.
Saves original settings and sets maxReplicas = minReplicas.
Bash
Preview changes first (Recommended)
./manage_hpa.sh lock --dry-run
Execute actual lock using default config file
./manage_hpa.sh lock
Reads settings from the config file, restores maxReplicas, and deletes the config file.
Bash
Preview restoration
./manage_hpa.sh unlock --dry-run
Execute actual unlock using a custom config file
./manage_hpa.sh unlock my-maintenance-hpas.json