HorizontalPodAutoscaler (HPA) automatically adjusts a Kubernetes workload’s replica count as resource demand changes: scaling up under pressure and scaling down when activity quiets. section 8.2.3
A practical HPA workflow for a Spin application is:
- Create a Spin application with a route that generates sustained CPU activity. section 8.2.3
- Build the application, push its OCI image to a registry, and expose it through an Ingress. section 8.2.3
- Scaffold SpinKube resources with one replica, a ten-replica maximum, CPU and memory requests, and HPA support. section 8.2.3
- Set CPU and memory targets to 60 percent utilization, then inspect the HPA and deployment while traffic increases. section 8.2.3
Scaling a Spin application
A generated manifest enables autoscaling for scaling-spin, targets its Deployment, permits 1–10 replicas, and monitors CPU and memory at 60 percent average utilization. Sending concurrent requests to /load can drive the deployment from one replica toward the configured maximum. section 8.2.3
Listing 8.8 scaling-spin.yaml
apiVersion: core.spinkube.dev/v1alpha1
kind: SpinApp
metadata:
name: scaling-spin
spec:
image: "ghcr.io/danbugs/serverside-wasm-book-code/scaling-spin:latest"
executor: containerd-shim-spin
enableAutoscaling: true
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 50m
memory: 64Mi
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: scaling-spin-autoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: scaling-spin
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 60
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 60
The manifest shows the connection between a SpinApp, its resource requests and limits, and the autoscaling/v2 HPA resource. section 8.2.3


