This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move upgrade logic into shell script to improve error handling
- Loading branch information
Showing
2 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
usage() { | ||
cat <<-EOF | ||
USAGE: | ||
$0 [--release <release-name>] [--from <elasticsearch-version>] --to <elasticsearch-version> | ||
$0 --help | ||
OPTIONS: | ||
--release <release-name> | ||
Name of the Helm release to install | ||
--from <elasticsearch-version> | ||
Elasticsearch version to use for first install | ||
EOF | ||
exit 1 | ||
} | ||
|
||
RELEASE="helm-es-upgrade" | ||
FROM="" | ||
|
||
while [[ $# -gt 0 ]] | ||
do | ||
key="$1" | ||
|
||
case $key in | ||
--help) | ||
usage | ||
;; | ||
--release) | ||
RELEASE="$2" | ||
shift 2 | ||
;; | ||
--from) | ||
FROM="$2" | ||
shift 2 | ||
;; | ||
*) | ||
log "Unrecognized argument: '$key'" | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
# Elasticsearch chart < 7.4.0 are not compatible with K8S >= 1.16) | ||
if [[ -z $FROM ]] | ||
then | ||
KUBE_MINOR_VERSION=$(kubectl version --client -o yaml | grep minor | sed 's/[^0-9]*//g') | ||
|
||
if [ "$KUBE_MINOR_VERSION" -lt 16 ] | ||
then | ||
FROM="7.0.0-alpha1" | ||
else | ||
FROM="7.4.0" | ||
fi | ||
fi | ||
|
||
helm repo add elastic https://helm.elastic.co | ||
|
||
# Initial install | ||
helm upgrade --wait --timeout=600 --install "$RELEASE" elastic/elasticsearch --version "$FROM" --set clusterName=upgrade -f ../docker-for-mac/values.yaml | ||
kubectl rollout status sts/upgrade-master --timeout=600s | ||
|
||
# Upgrade | ||
helm upgrade --wait --timeout=600 --set terminationGracePeriod=121 --install "$RELEASE" ../../ --set clusterName=upgrade -f ../docker-for-mac/values.yaml | ||
kubectl rollout status sts/upgrade-master --timeout=600s |