Skip to content

Commit

Permalink
enhancement: Optimize deployment scripts and support local deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
KingsonKai committed Jun 2, 2023
1 parent 99ec0ec commit 46ef921
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 15 deletions.
3 changes: 2 additions & 1 deletion chaosmeta-inject-operator/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

set -e

ROOT_PATH=$(dirname $(readlink -f $0))/..
BASE_DIR=`cd $(dirname $0); pwd`
ROOT_PATH=${BASE_DIR}/..
echo "${ROOT_PATH}"

kubectl create configmap chaosmeta-inject-config --from-file="${ROOT_PATH}"/config/chaosmeta-inject.json -n chaosmeta
Expand Down
43 changes: 33 additions & 10 deletions chaosmeta-inject-operator/build/deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
#!/bin/bash

set -e

NOW_DIR=`cd $(dirname $0); pwd`
VERSION=$1
if [ -z "$VERSION" ]; then
echo "version is empty"
exit 1
fi
echo "version: ${VERSION}"

function downloadfile() {
url=$1
filename=$2
echo "download from: ${url}"
if [ ! -e "${filename}" ]; then
curl -o "${filename}" "${url}"
fi
echo "download success: ${filename}"
}

ROOT_PATH=$(dirname $(readlink -f $0))/chaosmeta_build
echo "${ROOT_PATH}"
mkdir -p "${ROOT_PATH}"/build
mkdir -p "${ROOT_PATH}"/config
mkdir -p "${ROOT_PATH}"/yamls
ROOT_PATH=${NOW_DIR}/../
if [ "${VERSION}" != "local" ]; then
ROOT_PATH=${NOW_DIR}/chaosmeta_build
echo "${ROOT_PATH}"
mkdir -p "${ROOT_PATH}"/build "${ROOT_PATH}"/config "${ROOT_PATH}"/yamls
preurl=https://raw.githubusercontent.com/traas-stack/chaosmeta/"${VERSION}"/chaosmeta-inject-operator

curl -o "${ROOT_PATH}"/config/chaosmeta-inject.json https://raw.githubusercontent.com/traas-stack/chaosmeta/"${VERSION}"/chaosmeta-inject-operator/config/chaosmeta-inject.json
curl -o "${ROOT_PATH}"/build/build.sh https://raw.githubusercontent.com/traas-stack/chaosmeta/"${VERSION}"/chaosmeta-inject-operator/build/build.sh
curl -o "${ROOT_PATH}"/yamls/chaosmeta.yaml https://raw.githubusercontent.com/traas-stack/chaosmeta/"${VERSION}"/chaosmeta-inject-operator/build/yamls/chaosmeta.yaml
curl -o "${ROOT_PATH}"/yamls/chaosmeta-daemonset.yaml https://raw.githubusercontent.com/traas-stack/chaosmeta/"${VERSION}"/chaosmeta-inject-operator/build/yamls/chaosmeta-daemonset.yaml
downloadfile "${preurl}"/config/chaosmeta-inject.json "${ROOT_PATH}"/config/chaosmeta-inject.json
downloadfile "${preurl}"/build/build.sh "${ROOT_PATH}"/build/build.sh
downloadfile "${preurl}"/build/yamls/chaosmeta.yaml "${ROOT_PATH}"/yamls/chaosmeta.yaml
downloadfile "${preurl}"/build/yamls/chaosmeta-daemonset.yaml "${ROOT_PATH}"/yamls/chaosmeta-daemonset.yaml
fi

kubectl apply -f "${ROOT_PATH}"/yamls/chaosmeta.yaml
kubectl apply -f "${ROOT_PATH}"/yamls/chaosmeta-daemonset.yaml
sh "${ROOT_PATH}"/build/build.sh
if [ "${VERSION}" != "local" ]; then
sh "${ROOT_PATH}"/build/build.sh
else
sh "${ROOT_PATH}"/build.sh
fi
34 changes: 30 additions & 4 deletions chaosmeta-inject-operator/build/deploy/undeploy.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
#!/bin/bash

set -e

NOW_DIR=`cd $(dirname $0); pwd`
VERSION=$1
ROOT_PATH=$(dirname $(readlink -f $0))/chaosmeta_build
echo "${ROOT_PATH}"
mkdir -p "${ROOT_PATH}"/yamls
curl -o "${ROOT_PATH}"/yamls/chaosmeta.yaml https://raw.githubusercontent.com/traas-stack/chaosmeta/"${VERSION}"/chaosmeta-inject-operator/build/yamls/chaosmeta.yaml
if [ -z "$VERSION" ]; then
echo "version is empty"
exit 1
fi
echo "version: ${VERSION}"

function downloadfile() {
url=$1
filename=$2
echo "download from: ${url}"
if [ ! -e "${filename}" ]; then
curl -o "${filename}" "${url}"
fi
echo "download success: ${filename}"
}

ROOT_PATH=${NOW_DIR}/../
if [ "${VERSION}" != "local" ]; then
ROOT_PATH=${NOW_DIR}/chaosmeta_build
echo "${ROOT_PATH}"
mkdir -p "${ROOT_PATH}"/yamls
filename="${ROOT_PATH}"/yamls/chaosmeta.yaml

if [ ! -e "${filename}" ]; then
downloadfile https://raw.githubusercontent.com/traas-stack/chaosmeta/"${VERSION}"/chaosmeta-inject-operator/build/yamls/chaosmeta.yaml "${filename}"
fi
fi

kubectl delete -f "${ROOT_PATH}"/yamls/chaosmeta.yaml

0 comments on commit 46ef921

Please sign in to comment.