From 266c92c8fc79fa1600d9fc0acc4b6065ba658990 Mon Sep 17 00:00:00 2001 From: Xtigyro Date: Sun, 5 Jul 2020 17:55:12 +0300 Subject: [PATCH] add reset old temp cfg param --- local-cluster/create-cluster.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/local-cluster/create-cluster.sh b/local-cluster/create-cluster.sh index c4f93b3..2066872 100644 --- a/local-cluster/create-cluster.sh +++ b/local-cluster/create-cluster.sh @@ -2,7 +2,10 @@ set -e LIGHT_GREEN='\033[1;32m' -NC='\033[0m' # No Color +LIGHT_RED='\033[1;31m' +NC='\033[0m' # No Color +KIND_CFG="./kind-cfg.yaml" # base config file + if [[ -z "$1" ]]; then printf "\nAt least no. of K8s nodes must be set. \nUse ${LIGHT_GREEN}\"bash $0 --help\"${NC} for details.\n" @@ -27,8 +30,18 @@ while [ $# -gt 0 ]; do fi K8S_VER="${1#*=}" ;; + --reset|-r) + if [[ -f "${KIND_CFG}.backup" ]]; then + yes | mv "${KIND_CFG}.backup" "${KIND_CFG}" + printf "\nReset: ${LIGHT_GREEN}OK${NC}.\n" + exit 0 + else + printf "\nSkipping reset - ${LIGHT_GREEN}no old temporary configuration${NC}.\n" + exit 0 + fi + ;; --help|-h) - printf "\nUsage:\n ${LIGHT_GREEN}--k8s_ver,-v${NC} Set K8s version to be deployed.\n ${LIGHT_GREEN}--nodes,-n${NC} Set number of K8s nodes to be created.\n ${LIGHT_GREEN}--help,-h${NC} Prints this message.\nExample:\n ${LIGHT_GREEN}bash $0 -n=1 -v=1.18.2${NC}\n" # Flag argument + printf "\nUsage:\n ${LIGHT_GREEN}--k8s_ver,-v${NC} Set K8s version to be deployed.\n ${LIGHT_GREEN}--nodes,-n${NC} Set number of K8s nodes to be created.\n ${LIGHT_GREEN}--reset,-r${NC} Resets any old temporary configuration.\n ${LIGHT_GREEN}--help,-h${NC} Prints this message.\nExample:\n ${LIGHT_GREEN}bash $0 -n=1 -v=1.18.2${NC}\n" # Flag argument exit 0 ;; *) @@ -39,8 +52,6 @@ while [ $# -gt 0 ]; do shift done -KIND_CFG="./kind-cfg.yaml" - if [[ -z "$K8S_VER" ]]; then KIND_CTRL_CFG=$'\n - role: control-plane\n extraMounts:\n - hostPath: /var/run/docker.sock\n containerPath: /var/run/docker.sock' KIND_WRKR_CFG=$'\n - role: worker\n extraMounts:\n - hostPath: /var/run/docker.sock\n containerPath: /var/run/docker.sock'