https://github.com/ExpediaGroup/container-startup-autoscaler how to use
- User
- Assistant
- User
no i want somthin for calcuate and fix the cpu and memory request and limite
- Assistant
no i want somthin for calcuate and fix the cpu and memory request and limite
The container-startup-autoscaler is a tool developed by Expedia Group designed to handle autoscaling of Kubernetes pods during their startup phase. It helps reduce the startup burst of containerized applications by dynamically adjusting the number of pods being started, improving stability and resource usage.
The container-startup-autoscaler watches Kubernetes pods and scales deployments/statefulsets based on their startup progress. It delays or throttles the startup of new pods until existing pods reach a running state, avoiding resource contention and startup spikes.
kubectl configured and access to your clusterYou can install the autoscaler either using Helm or by applying Kubernetes manifests.
helm repo add expediagroup https://expediagroup.github.io/container-startup-autoscaler/
helm repo update
helm install container-startup-autoscaler expediagroup/container-startup-autoscaler --namespace container-startup-autoscaler --create-namespace
This installs the autoscaler in the namespace container-startup-autoscaler.
Check the running pods:
kubectl get pods -n container-startup-autoscaler
Clone the repo and apply manifests manually:
git clone https://github.com/ExpediaGroup/container-startup-autoscaler.git
cd container-startup-autoscaler/deploy
kubectl apply -f rbac.yaml
kubectl apply -f deployment.yaml
To enable autoscaling on your Kubernetes workload, add an annotation to the pod template spec in your Deployment or StatefulSet.
Example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 10
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
annotations:
container-startup-autoscaler.expediagroup.com/enabled: "true"
# Optional: max starters at any time (default: 1)
container-startup-autoscaler.expediagroup.com/max-starting-pods: "3"
spec:
containers:
- name: myapp-container
image: myapp-image:latest
This tells the autoscaler to limit how many pods can be starting simultaneously.
| Annotation | Description | Default |
|---|---|---|
container-startup-autoscaler.expediagroup.com/enabled | Enables the autoscaler on this workload | "false" |
container-startup-autoscaler.expediagroup.com/max-starting-pods | Maximum number of pods allowed to be in the startup phase at once | 1 |
container-startup-autoscaler.expediagroup.com/count-ready-pods | Whether to count pods as ready or running (boolean "true"/"false") | false |
You can customize these annotations as needed.
kubectl get pods -l app=myapp
To see autoscaler logs:
kubectl logs deploy/container-startup-autoscaler -n container-startup-autoscaler
These logs can help debug whether the autoscaler is working correctly.
Pending or ContainerCreating phase as "starting."Running (and optionally Ready), the autoscaler will allow spawning of new pods.If you want me to help with specific configuration or deployment steps, just ask!
Got it! You want a tool or approach to calculate and fix the CPU and memory requests and limits for your Kubernetes pods or containers—not autoscaling startup behavior.
Kubernetes resource requests and limits are critical to ensure your pods get the right amount of CPU and memory, avoiding over-provisioning (wasting resources) or under-provisioning (causing OOM kills, throttling).
To calculate and fix these values, the common approach is:
Here are a few popular tools and best practices to help with this:
kubectl topkubectl top pod to get current CPU and memory usage.Example:
kubectl top pods -n your-namespace
Use this data to manually estimate resource requests and limits (requests should cover baseline usage, limits cover max observed).
Install VPA:
kubectl apply -f https://github.com/kubernetes/autoscaler/releases/download/vpa-release-0.13.0/vpa-v0.13.0.yaml
Define VPA for your deployment:
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: myapp-vpa
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: myapp
updatePolicy:
updateMode: "Off" # Just recommend, don't update automatically
After running, check VPA recommendations:
kubectl describe vpa myapp-vpa
It will recommend CPU and memory requests based on usage, which you can apply to pod specs.
Installation:
kubectl apply -f https://raw.githubusercontent.com/FairwindsOps/goldilocks/master/deploy/goldilocks-install.yaml
Then label your namespace:
kubectl label namespace your-namespace goldilocks.fairwinds.com/enabled="true"
Goldilocks will generate VPA recommendations for deployments in that namespace and provide a dashboard.
kubectl top pod or monitoring dashboards to check usage.requests and limits accordingly.| Resource | Request Recommendation | Limit Recommendation |
|---|---|---|
| CPU | Minimum CPU required under normal load | Slightly above max observed CPU (~10%) |
| Memory | Stable memory usage under normal load | Max observed memory + safety margin (e.g. 20%) |
If you want, I can help you with installation commands or sample YAML for Vertical Pod Autoscaler or Goldilocks setup! Would you like that?