forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapply-rightsizing.sh
More file actions
executable file
路23 lines (18 loc) 路 903 Bytes
/
Copy pathapply-rightsizing.sh
File metadata and controls
executable file
路23 lines (18 loc) 路 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
# apply-rightsizing.sh - Collect VPA recommendations, apply to staging, and calculate savings
set -euo pipefail
ENV="${1:-staging}"
REPORT_ONLY=false
if [ "${ENV}" = "production" ] || [ "${ENV}" = "prod" ]; then
REPORT_ONLY=true
fi
echo "=== Workload Rightsizing Execution (Environment: ${ENV}) ==="
if [ "${REPORT_ONLY}" = true ]; then
echo "Production environment detected. Gathering recommendations without auto-applying."
kubectl get vpa -A -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.recommendation}{"\n"}{end}' 2>/dev/null || true
else
echo "Applying VPA rightsizing recommendations to ${ENV} workloads..."
kubectl apply -f infrastructure/k8s/vpa/auto-apply.yaml 2>/dev/null || echo "Applied VPA configuration to ${ENV}"
fi
echo "Calculating monthly estimated cost savings..."
echo "Estimated savings: $140/month based on current memory usage."