Kubernetes Autoscaling
Configure Kubernetes autoscaling with HPA, VPA, and KEDA. Use for horizontal/vertical pod autoscaling, event-driven scaling, and capacity management.
Rohit Ghumare
@rohitg00
Install
$ openclaw skills install @rohitg00/k8s-autoscalingKubernetes Autoscaling
Comprehensive autoscaling using HPA, VPA, and KEDA with kubectl-mcp-server tools.
Requires the
cost,kedatoolsets: start kubectl-mcp-server with--toolsets default,cost,keda(orMCP_TOOLSETS=default,cost,keda).
When to Apply
Use this skill when:
- User mentions: "HPA", "VPA", "KEDA", "autoscale", "scale to zero"
- Operations: configuring autoscaling, checking scaling status
- Keywords: "scale automatically", "event-driven", "right-size"
Priority Rules
| Priority | Rule | Impact | Tools |
|---|---|---|---|
| 1 | Verify metrics-server for HPA | CRITICAL | kubectl_top |
| 2 | Set resource requests before HPA | CRITICAL | kubectl_describe |
| 3 | Use KEDA for scale-to-zero | HIGH | keda_scaledobjects_list |
| 4 | Check VPA recommendations | MEDIUM | get_resource_recommendations |
Quick Reference
| Task | Tool | Example |
|---|---|---|
| List KEDA ScaledObjects | keda_scaledobjects_list | keda_scaledobjects_list(namespace) |
| Get ScaledObject | keda_scaledobject_get | keda_scaledobject_get(name, namespace) |
| List ScaledJobs | keda_scaledjobs_list | keda_scaledjobs_list(namespace) |
| Check KEDA | detect_ecosystem | detect_ecosystem() |
HPA (Horizontal Pod Autoscaler)
Basic CPU-based scaling:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
Apply and verify:
kubectl_apply(hpa_yaml, namespace)
kubectl_get(resource_type="hpa", namespace)
VPA (Vertical Pod Autoscaler)
Right-size resource requests:
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: my-app-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
updatePolicy:
updateMode: "Auto"
KEDA (Event-Driven Autoscaling)
Detect KEDA Installation
detect_ecosystem()
List ScaledObjects
keda_scaledobjects_list(namespace)
keda_scaledobject_get(name, namespace)
List ScaledJobs
keda_scaledjobs_list(namespace)
Trigger Authentication
keda_triggerauths_list(namespace)
keda_triggerauth_get(name, namespace)
KEDA-Managed HPAs
keda_hpa_list(namespace)
See KEDA-TRIGGERS.md for trigger configurations.
Common KEDA Triggers
Queue-Based Scaling (AWS SQS)
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: sqs-scaler
spec:
scaleTargetRef:
name: queue-processor
minReplicaCount: 0
maxReplicaCount: 100
triggers:
- type: aws-sqs-queue
metadata:
queueURL: https://sqs.region.amazonaws.com/...
queueLength: "5"
Cron-Based Scaling
triggers:
- type: cron
metadata:
timezone: America/New_York
start: 0 8 * * 1-5
end: 0 18 * * 1-5
desiredReplicas: "10"
Prometheus Metrics
triggers:
- type: prometheus
metadata:
serverAddress: http://prometheus:9090
metricName: http_requests_total
query: sum(rate(http_requests_total{app="myapp"}[2m]))
threshold: "100"
Scaling Strategies
| Strategy | Tool | Use Case |
|---|---|---|
| CPU/Memory | HPA | Steady traffic patterns |
| Custom metrics | HPA v2 | Business metrics |
| Event-driven | KEDA | Queue processing, cron |
| Vertical | VPA | Right-size requests |
| Scale to zero | KEDA | Cost savings, idle workloads |
Cost-Optimized Autoscaling
Scale to Zero with KEDA
Reduce costs for idle workloads:
keda_scaledobjects_list(namespace)
Right-Size with VPA
Get recommendations and apply:
get_resource_recommendations(namespace)
Troubleshooting
HPA Not Scaling
kubectl_get(resource_type="hpa", namespace)
kubectl_top(name, namespace)
kubectl_describe(name, namespace)
KEDA Not Triggering
keda_scaledobject_get(name, namespace)
kubectl_get(resource_type="events", namespace)
Common Issues
| Symptom | Check | Resolution |
|---|---|---|
| HPA unknown | Metrics server | Install metrics-server |
| KEDA no scale | Trigger auth | Check TriggerAuthentication |
| VPA not updating | Update mode | Set updateMode: Auto |
| Scale down slow | Stabilization | Adjust stabilizationWindowSeconds |
Best Practices
- Always Set Resource Requests - HPA requires requests to calculate utilization
- Use Multiple Metrics - Combine CPU + custom metrics for accuracy
- Stabilization Windows - Prevent flapping with scaleDown stabilization
- Scale to Zero Carefully - Consider cold start time
Related Skills
- k8s-cost - Cost optimization
- k8s-troubleshoot - Debug scaling issues
Top skills in this category
API Gateway
@byungkyuCall third-party APIs through the Maton gateway, which injects the credential for an app the user has already connected. Use this skill when the user names a connected app and a concrete action in it - read a mailbox, query a CRM, file an issue, update a spreadsheet, etc.
Marketing Mode
@thesethroseMarketing Mode combines 23 comprehensive marketing skills covering strategy, psychology, content, SEO, conversion optimization, and paid growth. Use when users need marketing strategy, copywriting, SEO help, conversion optimization, paid advertising, or any marketing tactic.
Blogwatcher
@steipeteMonitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.
Marketing Skills
@jchopard69Access 23 marketing modules offering checklists, frameworks, and ready-to-use deliverables for CRO, SEO, copywriting, analytics, launches, ads, and social me...
diagram-generator
@matthewyinGenerate and edit diagrams with the mcp-diagram-generator MCP server. Use this skill for new diagrams, existing .drawio/.mmd/.excalidraw edits, network topology, architecture, flowchart, swimlane, sequence, class, ER, and Excalidraw whiteboard work. Always use this skill when the user asks to draw,