From 29f17b1e5efc4c07535e2d62dbf14410adb45e2e Mon Sep 17 00:00:00 2001 From: llhuii Date: Tue, 14 Sep 2021 15:44:35 +0800 Subject: [PATCH] Optimize the install script 1. Add some usage doc comment. 2. Install Sedna latest release version when unspecified. Signed-off-by: llhuii --- scripts/installation/install.sh | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/scripts/installation/install.sh b/scripts/installation/install.sh index 905fa8ae5..bb197d574 100644 --- a/scripts/installation/install.sh +++ b/scripts/installation/install.sh @@ -14,22 +14,46 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Influential env vars: +# +# SEDNA_GM_NODE | required | The node which Sedna gm will be deployed at +# SEDNA_ACTION | optional | 'create'/'clean', default is 'create' +# SEDNA_VERSION | optional | The Sedna version to be installed. +# if not specified, it will get latest release version. +# SEDNA_ROOT | optional | The Sedna offline directory + set -o errexit set -o nounset set -o pipefail -SEDNA_VERSION=v0.3.0 -KB_VERSION=v0.3.0 - TMP_DIR=$(mktemp -d --suffix=.sedna) SEDNA_ROOT=${SEDNA_ROOT:-$TMP_DIR} GM_NODE_NAME=${SEDNA_GM_NODE:-} KB_NODE_NAME=${SEDNA_GM_NODE:-} +DEFAULT_SEDNA_VERSION=v0.4.0 + trap "rm -rf '$TMP_DIR'" EXIT +get_latest_version() { + # get Sedna latest release version + local repo=kubeedge/sedna + # output of this latest page: + # ... + # "tag_name": "v1.0.0", + # ... + { + curl -s https://api.github.com/repos/$repo/releases/latest | + awk '/"tag_name":/&&$0=$2' | + sed 's/[",]//g' + } || echo $DEFAULT_SEDNA_VERSION # fallback +} + +: ${SEDNA_VERSION:=$(get_latest_version)} +: ${KB_VERSION:=v0.3.0} + _download_yamls() { yaml_dir=$1 @@ -332,6 +356,7 @@ delete_lc() { } wait_ok() { + echo "Waiting control components to be ready..." kubectl -n sedna wait --for=condition=available --timeout=600s deployment/gm kubectl -n sedna wait pod --for=condition=Ready --selector=sedna kubectl -n sedna get pod @@ -396,6 +421,7 @@ do_check prepare case "$action" in create) + echo "Installing Sedna $SEDNA_VERSION..." prepare_install create_crds create_kb