From e48ded84df1d8350c41201851d270547f7e37b78 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Sun, 23 Jun 2019 08:18:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20add-node/add-master/add-etcd=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E8=8A=82=E7=82=B9=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/easzctl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/easzctl b/tools/easzctl index 3245629..2733a65 100755 --- a/tools/easzctl +++ b/tools/easzctl @@ -76,7 +76,7 @@ function add-node() { [[ $1 =~ ^(2(5[0-5]{1}|[0-4][0-9]{1})|[0-1]?[0-9]{1,2})(\.(2(5[0-5]{1}|[0-4][0-9]{1})|[0-1]?[0-9]{1,2})){3}$ ]] || { echo "[ERROR] Invalid ip address!"; return 1; } # check if the new node already exsited - sed -n '/^\[kube-master/,/^\[harbor/p' $BASEPATH/hosts|grep "^$1" && { echo "[ERROR] node $1 already existed!"; return 2; } + sed -n '/^\[kube-master/,/^\[harbor/p' $BASEPATH/hosts|grep "^$1[^0-9]*$" && { echo "[ERROR] node $1 already existed!"; return 2; } # add a node into 'kube-node' group sed -i "/\[kube-node/a $1 NEW_NODE=yes" $BASEPATH/hosts @@ -94,7 +94,7 @@ function add-master() { [[ $1 =~ ^(2(5[0-5]{1}|[0-4][0-9]{1})|[0-1]?[0-9]{1,2})(\.(2(5[0-5]{1}|[0-4][0-9]{1})|[0-1]?[0-9]{1,2})){3}$ ]] || { echo "[ERROR] Invalid ip address!"; return 2; } # check if the new master already exsited - sed -n '/^\[kube-master/,/^\[kube-node/p' $BASEPATH/hosts|grep "^$1" && { echo "[ERROR] master $1 already existed!"; return 2; } + sed -n '/^\[kube-master/,/^\[kube-node/p' $BASEPATH/hosts|grep "^$1[^0-9]*$" && { echo "[ERROR] master $1 already existed!"; return 2; } # add a node into 'kube-master' group sed -i "/\[kube-master/a $1 NEW_MASTER=yes" $BASEPATH/hosts @@ -115,7 +115,7 @@ function add-etcd() { [[ $1 =~ ^(2(5[0-5]{1}|[0-4][0-9]{1})|[0-1]?[0-9]{1,2})(\.(2(5[0-5]{1}|[0-4][0-9]{1})|[0-1]?[0-9]{1,2})){3}$ ]] || { echo "[ERROR] Invalid ip address!"; return 2; } # check if the new node already exsited - sed -n '/^\[etcd/,/^\[kube-master/p' $BASEPATH/hosts|grep "^$1" && { echo "[ERROR] node $1 already existed!"; return 2; } + sed -n '/^\[etcd/,/^\[kube-master/p' $BASEPATH/hosts|grep "^$1[^0-9]*$" && { echo "[ERROR] etcd $1 already existed!"; return 2; } # input an unique NODE_NAME of the node in etcd cluster echo "Please input an UNIQUE name(string) for the new node: "