shell - 导出k8s yaml

2021-07-05
#!/bin/bash
path="/tmp/old"
mkdir -p ${path}
cd ${path}
if [[ $? -eq 0 ]];then
    rm -rf *
fi
namespaces="qa qa2 qa3 devops"
kinds="service deployment configmap secret"
for namespace in ${namespaces}
do
    for kind in ${kinds}
    do
        kubectl -n ${namespace} get ${kind} --export -o yaml > ${path}/${namespace}-${kind}.yaml
    done
done
scp -r /tmp/old 192.168.150.180:/tmp/

exit

nodes="192.168.150.186 192.168.150.206 192.168.150.4 192.168.150.185 "
for node in ${nodes}
do
    scp -r /opt/share ${node}:/opt/
done