add
This commit is contained in:
24
998-常用脚本/uavcloud-被cmii_operator替代/K8S相关脚本.sh
Normal file
24
998-常用脚本/uavcloud-被cmii_operator替代/K8S相关脚本.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/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}'
|
||||
Reference in New Issue
Block a user