# 导出资源配置
#!/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' ./*
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐