Last active
September 11, 2024 06:43
-
-
Save akarca/1737303c8ae775376dec6b16165e2596 to your computer and use it in GitHub Desktop.
Automatic VPA generator for all deployments in namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: ./generate_vpa.sh namespace | |
# | |
# Generates yaml files for vpa and applies. | |
# | |
mkdir -p "yaml/"$1"/" | |
kubectl get deploy -n $1 | grep -v NAME | awk -v namespace=$1 '{print $1" "namespace}' | awk '{ system("sed -e \"s/\{namespace}/"$2"/\" -e \"s/\{name}/"$1"/\" vpa.tpl > yaml/"$2"/"$1".yaml") }' | |
find "yaml/"$1 -name "*.yaml" -exec kubectl apply -f {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: autoscaling.k8s.io/v1 | |
kind: VerticalPodAutoscaler | |
metadata: | |
namespace: {namespace} | |
name: {name} | |
spec: | |
targetRef: | |
apiVersion: "apps/v1" | |
kind: Deployment | |
name: {name} | |
updatePolicy: | |
updateMode: "Off" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment