Skip to content

Commit

Permalink
Fix dev deployment script for operator (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
weenxin authored and tamalsaha committed Jul 22, 2019
1 parent ed7e2eb commit b673c6c
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
1 change: 1 addition & 0 deletions hack/deploy/doc.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ To deploy operator in self-hosted:
To run operator in local machine to connect minikube:

$ ./hack/deploy/setup.sh --minikube (--run)
$ ./hack/deploy/install-catalog.sh

To uninstall:

Expand Down
95 changes: 95 additions & 0 deletions hack/deploy/install-catalog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash
set -eou pipefail

crds=(
dormantdatabases.kubedb.com
elasticsearches.kubedb.com
etcds.kubedb.com
memcacheds.kubedb.com
mongodbs.kubedb.com
mysqls.kubedb.com
postgreses.kubedb.com
redises.kubedb.com
snapshots.kubedb.com
elasticsearchversions.catalog.kubedb.com
etcdversions.catalog.kubedb.com
memcachedversions.catalog.kubedb.com
mongodbversions.catalog.kubedb.com
mysqlversions.catalog.kubedb.com
postgresversions.catalog.kubedb.com
redisversions.catalog.kubedb.com
appbindings.appcatalog.appscode.com
)

echo "checking kubeconfig context"
kubectl config current-context || {
echo "Set a context (kubectl use-context <context>) out of the following:"
echo
kubectl config get-contexts
exit 1
}
echo ""

# http://redsymbol.net/articles/bash-exit-traps/
function cleanup() {
rm -rf $ONESSL ca.crt ca.key server.crt server.key
}
trap cleanup EXIT


onessl_found() {
# https://stackoverflow.com/a/677212/244009
if [ -x "$(command -v onessl)" ]; then
onessl wait-until-has -h >/dev/null 2>&1 || {
# old version of onessl found
echo "Found outdated onessl"
return 1
}
export ONESSL=onessl
return 0
fi
return 1
}

onessl_found || {
echo "Downloading onessl ..."
# ref: https://stackoverflow.com/a/27776822/244009
case "$(uname -s)" in
Darwin)
curl -fsSL -o onessl https://github.com/kubepack/onessl/releases/download/0.10.0/onessl-darwin-amd64
chmod +x onessl
export ONESSL=./onessl
;;

Linux)
curl -fsSL -o onessl https://github.com/kubepack/onessl/releases/download/0.10.0/onessl-linux-amd64
chmod +x onessl
export ONESSL=./onessl
;;

CYGWIN* | MINGW* | MSYS*)
curl -fsSL -o onessl.exe https://github.com/kubepack/onessl/releases/download/0.10.0/onessl-windows-amd64.exe
chmod +x onessl.exe
export ONESSL=./onessl.exe
;;
*)
echo 'other OS'
;;
esac
}

GOPATH=$(go env GOPATH)
REPO_ROOT=`git rev-parse --show-toplevel`
INSTALLER_ROOT="$GOPATH/src/github.com/kubedb/installer"

source "$REPO_ROOT/hack/deploy/settings"

echo "waiting until kubedb crds are ready"
for crd in "${crds[@]}"; do
$ONESSL wait-until-ready crd ${crd} || {
echo "$crd crd failed to be ready"
exit 1
}
done

cat $INSTALLER_ROOT/deploy/kubedb-catalog/* | $ONESSL envsubst | kubectl apply -f - || true
3 changes: 3 additions & 0 deletions hack/deploy/settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ export INSTALLER_BRANCH="release-0.12"
# if APPSCODE_ENV=dev then git_tag will be used as CUSTOM_OPERATOR_TAG
export CUSTOM_OPERATOR_TAG="0.9.0-beta.0"
export KUBEDB_CATALOG=all

#Custom registry by setting DOCKER_REGISTRY enviroment
export KUBEDB_DOCKER_REGISTRY=${DOCKER_REGISTRY:-kubedb}
5 changes: 3 additions & 2 deletions hack/deploy/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ if [ "$SELF_HOSTED" -eq 1 ]; then
fi

if [ "$MINIKUBE" -eq 1 ]; then
#Some enviroment we need
export KUBEDB_DOCKER_REGISTRY=kubedb

cat $INSTALLER_ROOT/deploy/validating-webhook.yaml | $ONESSL envsubst | kubectl apply -f -
cat $INSTALLER_ROOT/deploy/mutating-webhook.yaml | $ONESSL envsubst | kubectl apply -f -
cat $REPO_ROOT/hack/dev/apiregistration.yaml | $ONESSL envsubst | kubectl apply -f -
# Following line may give error if DBVersions CRD already not created
cat $INSTALLER_ROOT/hack/deploy/kubedb-catalog/* | $ONESSL envsubst | kubectl apply -f - || true

if [ "$MINIKUBE_RUN" -eq 1 ]; then
$REPO_ROOT/hack/make.py
Expand Down

0 comments on commit b673c6c

Please sign in to comment.