diff --git a/elasticsearch/examples/upgrade/Makefile b/elasticsearch/examples/upgrade/Makefile index 3c6b0c9ff..f890d502c 100644 --- a/elasticsearch/examples/upgrade/Makefile +++ b/elasticsearch/examples/upgrade/Makefile @@ -3,15 +3,9 @@ default: test include ../../../helpers/examples.mk RELEASE := helm-es-upgrade -KUBE_MINOR_VERSION := $(shell kubectl version --client -o yaml | grep minor | sed 's/[^0-9]*//g') -VERSION := $(shell test $(KUBE_MINOR_VERSION) -lt 16 && echo 7.0.0-alpha1 || echo 7.4.0) install: - helm repo add elastic https://helm.elastic.co && \ - helm upgrade --wait --timeout=600 --install $(RELEASE) elastic/elasticsearch --version $(VERSION) --set clusterName=upgrade ; \ - kubectl rollout status sts/upgrade-master --timeout=600s - helm upgrade --wait --timeout=600 --set terminationGracePeriod=121 --install $(RELEASE) ../../ --set clusterName=upgrade ; \ - kubectl rollout status sts/upgrade-master --timeout=600s + ./scripts/upgrade.sh --release $(RELEASE) init: helm init --client-only diff --git a/elasticsearch/examples/upgrade/scripts/upgrade.sh b/elasticsearch/examples/upgrade/scripts/upgrade.sh new file mode 100755 index 000000000..b4b31624f --- /dev/null +++ b/elasticsearch/examples/upgrade/scripts/upgrade.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +set -eo pipefail + +usage() { + cat <<-EOF + USAGE: + $0 [--release ] [--from ] --to + $0 --help + + OPTIONS: + --release + Name of the Helm release to install + --from + 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