22 lines
538 B
Bash
22 lines
538 B
Bash
#!/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
|