From b3c95a68377ddcbe50444a0b6396ea5b4a28f6b4 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Tue, 26 Mar 2019 08:56:52 +0800 Subject: [PATCH] =?UTF-8?q?easzctl=E9=9B=86=E6=88=90upgrade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/easzctl | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/easzctl b/tools/easzctl index e36f330..5b12b3e 100755 --- a/tools/easzctl +++ b/tools/easzctl @@ -16,11 +16,12 @@ Commands 1 (cluster-wide operation): setup To setup a cluster using the current context start-aio To quickly setup an all-in-one cluster for testing (like minikube) Commands 2 (in-cluster opration): - add-node To add a kube-node(work node) to the k8s cluster - add-master To add a kube-master(master node) to the k8s cluster add-etcd To add a etcd-node to the etcd cluster - del-etcd To delete a etcd-node from the etcd cluster + add-master To add a kube-master(master node) to the k8s cluster + add-node To add a kube-node(work node) to the k8s cluster clean-node To clean a node, whatever role the node plays + del-etcd To delete a etcd-node from the etcd cluster + upgrade To upgrade the k8s cluster Use "easzctl help " for more information about a given command. EOF @@ -139,6 +140,13 @@ function clean-node() { save_context } +function upgrade() { + echo -e "[INFO] prepare the new binaries in advance" + echo -e "[INFO] upgrade begin in 5s, press any key to abort\n:" + ! (read -t5 -n1 ANS) || { echo "[WARN] upgrade aborted"; return 1; } + ansible-playbook -t upgrade_k8s $BASEPATH/22.upgrade.yml || return 1 + save_context +} ### cluster-wide operation functions ############################ function save_context() { @@ -219,8 +227,8 @@ function setup() { save_context CLUSTER=$(cat $BASEPATH/.cluster/current_cluster) echo -e "\n[INFO] setup cluster with context: $CLUSTER" - echo -e "[INFO] setup begin in 5s, press 'Enter' to abort\n:" - ! (read -t 5 ANS) || { echo "[WARN] setup aborted"; return 1; } + echo -e "[INFO] setup begin in 5s, press any key to abort\n:" + ! (read -t5 -n1 ANS) || { echo "[WARN] setup aborted"; return 1; } ansible-playbook $BASEPATH/90.setup.yml || return 1 save_context } @@ -318,6 +326,10 @@ case "$1" in ACTION="Action: clean a node" CMD="clean-node $2" ;; + (upgrade) + ACTION="Action: upgrade the cluster" + CMD="upgrade" + ;; ### cluster-wide operations ####################### (checkout) [ "$#" -gt 1 ] || { usage >&2; exit 2; }