Files
zeaslity 437acbeb63 add
2024-10-30 16:30:51 +08:00

24 lines
1.2 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 获取命令空间 uavcloud-uat 中所有部署deployment的镜像名称
kubectl get deployments -n uavcloud-demo -o=jsonpath='{range .items[*]}{.spec.template.spec.containers[*].image}{"\n"}{end}'
# 获取命名空间 uavcloud-uat种所有的configmap并且保存为独立的文件文件名为configmap名
mkdir configmaps
kubectl get configmaps -n uavcloud-uat -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}' | while read configmap; do
kubectl get configmap $configmap -n uavcloud-uat -o yaml > ./configmaps/$configmap.yaml
done
# 获取命名空间 uavcloud-uat种所有的ingress并且保存为独立的文件文件名为ingress名
mkdir ingresses
kubectl get ingress -n uavcloud-uat -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}' | while read ingress; do
kubectl get ingress $ingress -n uavcloud-uat -o yaml > ./ingresses/$ingress.yaml
done
# kubectl删除所有命名空间的状态不正常的pod
kubectl get pods --all-namespaces | awk '{ if($3 != "Running" && $3 != "Completed") print "kubectl delete pod " $2 " -n " $1 }' | sh
# 获取demo空间所有deployment的名称
kubectl get deployments -n uavcloud-demo -o=jsonpath='{.items [*].metadata.name}'