优化代码

This commit is contained in:
zeaslity
2025-03-05 17:34:09 +08:00
parent 84ecf9d0e6
commit 77cafaf0a1
17 changed files with 414 additions and 43 deletions

View File

@@ -0,0 +1,21 @@
#!/bin/bash
namespace=jxyd
# 优雅地处理Deployment缩容
scale_deployments() {
echo "Scaling Deployments in namespace: $namespace"
kubectl get deployments -n "$namespace" -o name |
xargs -I {} kubectl scale --replicas=0 -n "$namespace" {}
}
# 高效处理StatefulSet缩容
scale_statefulsets() {
echo "Scaling StatefulSets in namespace: $namespace"
kubectl get statefulsets -n "$namespace" -o name |
xargs -I {} kubectl scale --replicas=0 -n "$namespace" {}
}
scale_deployments
scale_statefulsets