k8s配置文件导出脚本
# 导出资源配置#!/bin/bashresource_types="configmap deploy svc ingress"ns="nmaespace_name"for resource_type in $resource_typesdomkdir $resource_typeresource_names=`kubectl get $resource_type -n $ns | awk 'NR
·
# 导出资源配置
#!/bin/bash
resource_types="configmap deploy svc ingress"
ns="nmaespace_name"
for resource_type in $resource_types
do
mkdir $resource_type
resource_names=`kubectl get $resource_type -n $ns | awk 'NR>1{print $1}'`
for resource_name in $resource_names
do
kubectl get $resource_type $resource_name -n $ns -o yaml > ${resource_type}/${resource_name}.yaml
done
done
#删除多余字段-自行选择
sed -i /resourceVersion/d ./*
sed -i /selfLink/d ./*
sed -i /uid/d ./*
sed -i /kubectl.kubernetes.io/d ./*
sed -i /annotations/d ./*
sed -i /creationTimestamp/d ./*
sed -i /generation/d ./*
sed -i '/status/,$d' ./*
sed -i'/status/,+2d' ./*
更多推荐
已为社区贡献4条内容
所有评论(0)