From 18133ee3017d1d64ad8fd9819393ac6487d7e53f Mon Sep 17 00:00:00 2001 From: gjmzj Date: Mon, 7 May 2018 09:50:11 +0800 Subject: [PATCH] add tool: trans_yml.sh --- README.md | 6 ++--- tools/trans_yml.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) create mode 100755 tools/trans_yml.sh diff --git a/README.md b/README.md index 1fa6175..38af89b 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,8 @@ - etcd v3.3.4 - docker 18.03.0-ce - calico v3.0.6 -- flannel v0.10.0 - -**注1:** 集群用到的所有二进制文件已打包好供下载 [https://pan.baidu.com/s/1c4RFaA](https://pan.baidu.com/s/1c4RFaA) - +- flannel v0.10.0 +**注1:** 集群用到的所有二进制文件已打包好供下载 [https://pan.baidu.com/s/1c4RFaA](https://pan.baidu.com/s/1c4RFaA) **注2:** 为提高集群网络插件安装的灵活性,使用`DaemonSet Pod`方式运行网络插件,目前支持`Calico` `flannel`可选 ## 快速指南 diff --git a/tools/trans_yml.sh b/tools/trans_yml.sh new file mode 100755 index 0000000..24ffdce --- /dev/null +++ b/tools/trans_yml.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# 不同k8s版本使用的'api-versions'版本不同,此脚本用于切换yaml文件使用的'api-versions' + +#set -x + +show_usage() +{ + echo -e "\nUsage: $0 <-v K8S_VER> <-f YAML_FILE>" + echo -e "\nK8S_VER: support 1.8/1.9/1.10" +} + +#check_arg ------------------------------------------------- +K8S_VER="" +YML_FILE="" + +while getopts "v:f:" arg +do + case $arg in + v) + K8S_VER=$OPTARG + ;; + f) + if [ -w "$OPTARG" ];then + YML_FILE=$OPTARG + else + echo File:"$OPTARG not found or not writeable." + exit 1 + fi + ;; + ?) + echo -e "unkown argument" + show_usage + exit 1 + ;; + esac +done + +if [ "$K8S_VER" = "" ] || [ "$YML_FILE" = "" ];then + echo "error argument" + show_usage + exit 1 +fi + +main() +{ + case "$K8S_VER" in + 1.8) + sed -i 's/apps\/v1/extensions\/v1beta1/g' $YML_FILE + exit 0 + ;; + 1.9) + echo "K8s_VER is $K8S_VER" + exit 0 + ;; + 1.10) + sed -i 's/extensions\/v1beta1/apps\/v1/g' $YML_FILE + exit 0 + ;; + ?) + ;; + esac + echo "not supported K8s_VER:$K8S_VER" + exit 1 +} + +main