k8s集群v1.15.xx改v1.18.xx编排文件命令

k8s集群v1.15.xx改v1.18.xx编排文件命令

k8s集群v1.15.xx升级到v1.18.xx编排文件不一样了,可以使用下面命令替换,也可以批量替换

sed -i  's/v1beta1/&\napiVersion: apps\/v1/g'  "aaa-deployment.yaml"
sed -i  's/  template/  selector:\n&/g' "aaa-deployment.yaml"
sed -i  's/  template/    matchLabels:\n&/g' "aaa-deployment.yaml"
sed -i  "s/  template/      app: $NAME\n&/g" "aaa-deployment.yaml"
sed -i  '/v1beta1/d' "aaa-deployment.yaml"
sed -i '$d' "aaa-deployment.yaml"
echo "    app: $NAME" >> "aaa-deployment.yaml"

批量替换

for Project in $(cat Project2.log)
do

cd /opt/test/
if [[  -f "$Project.yaml" ]];then

NAME=$(cat $Project.yaml |grep name | head -n 1 | awk -F ' ' '{print $2}')
sed -i  's/v1beta1/&\napiVersion: apps\/v1/g'  "$Project.yaml"
sed -i  's/  template/  selector:\n&/g' "$Project.yaml"
sed -i  's/  template/    matchLabels:\n&/g' "$Project.yaml"
sed -i  "s/  template/      app: $NAME\n&/g" "$Project.yaml"
sed -i  '/v1beta1/d' "$Project.yaml"
sed -i '$d' "$Project.yaml"
echo "    app: $NAME" >> "$Project.yaml"

else
echo "$Project  nonono"
fi
done

 

给TA打赏
共{{data.count}}人
人已打赏
k8s编排文件

k8s集群v1.15.xx和v1.18.xx编排文件区别

2021-4-29 14:11:27

k8s编排文件

k8s部署金丝雀发布

2021-4-29 14:43:18

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索