Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
use some shell script based on existing elasticsearch upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlrt committed Nov 17, 2020
1 parent 7f90783 commit 750cb52
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 387 deletions.
4 changes: 3 additions & 1 deletion apm-server/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ default: test

include ../../../helpers/examples.mk

CHART := elastic/apm-server
RELEASE := helm-apm-server-upgrade
FROM := 7.6.0 # 7.6.0 is the first release for apm-server

install:
./scripts/upgrade.sh --release $(RELEASE)
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

test: install goss

Expand Down
59 changes: 0 additions & 59 deletions apm-server/examples/upgrade/scripts/upgrade.sh

This file was deleted.

1 change: 1 addition & 0 deletions apm-server/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apmConfig:
apm-server.yml: |
apm-server:
Expand Down
5 changes: 4 additions & 1 deletion elasticsearch/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ default: test

include ../../../helpers/examples.mk

CHART := elastic/elasticsearch
RELEASE := helm-es-upgrade
FROM := 7.4.0 # versions before 7.4.O aren't compatible with Kubernetes >= 1.16.0
TO := 7.10.0 # upgrade from 7.x to 8.0.0-SNAPSHOT currently doesn't work

install:
./scripts/upgrade.sh --release $(RELEASE)
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM) --to $(TO)

test: install goss

Expand Down
76 changes: 0 additions & 76 deletions elasticsearch/examples/upgrade/scripts/upgrade.sh

This file was deleted.

2 changes: 2 additions & 0 deletions elasticsearch/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
clusterName: upgrade
4 changes: 3 additions & 1 deletion filebeat/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ default: test

include ../../../helpers/examples.mk

CHART := elastic/filebeat
RELEASE := helm-filebeat-upgrade
FROM := 7.9.0 # registry file version 1 not supported error with previous version

install:
./scripts/upgrade.sh --release $(RELEASE)
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

test: install goss

Expand Down
58 changes: 0 additions & 58 deletions filebeat/examples/upgrade/scripts/upgrade.sh

This file was deleted.

1 change: 1 addition & 0 deletions filebeat/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
extraEnvs:
- name: ELASTICSEARCH_HOSTS
value: upgrade-master:9200
75 changes: 75 additions & 0 deletions helpers/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
#
# upgrade.sh deploy some Helm chart to a specific released version,
# then upgrade it.
#
# An optional version can be specified for Docker image tag to use for upgrade.
# This is required for master branch because upgrade from Elasticsearch 7.X
# to 8.0.0-SNAPSHOT doesn't work.
#
set -euo pipefail

TO=""

usage() {
cat <<-EOF
USAGE:
$0 --chart <chart-name> --release <release-name> --from <version> [--to <docker-image-version>]
$0 --help
OPTIONS:
--chart <chart-name>
Name of the Helm chart to install (ie: elastic/elasticsearch)
--release <release-name>
Name of the Helm release to install (ie: helm-upgrade-elasticsearch)
--from <version>
Version to use for first install (ie: 7.7.0)
--to <docker-image-version>
Version of the Docker images to use for upgrade (ie: 7.10.0)
EOF
exit 1
}

while [[ $# -gt 0 ]]
do
key="$1"

case $key in
--help)
usage
;;
--chart)
CHART="$2"
shift 2
;;
--release)
RELEASE="$2"
shift 2
;;
--from)
FROM="$2"
shift 2
;;
--to)
TO="--set imageTag=$2"
shift 2
;;
*)
log "Unrecognized argument: '$key'"
usage
;;
esac
done



helm repo add elastic https://helm.elastic.co

# Initial install
printf "Installing %s %s\n" "$RELEASE" "$FROM"
helm upgrade --wait --timeout=1200s --install --version "$FROM" --values values.yaml "$RELEASE" "$CHART"

# Upgrade
printf "Upgrading %s\n" "$RELEASE"
# shellcheck disable=SC2086
helm upgrade --wait --timeout=1200s --install --set terminationGracePeriod=121 $TO --values values.yaml "$RELEASE" ../../
4 changes: 3 additions & 1 deletion kibana/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ default: test

include ../../../helpers/examples.mk

CHART := elastic/kibana
RELEASE := helm-kibana-upgrade
FROM := 7.4.0 # versions before 7.4.O aren't compatible with Kubernetes >= 1.16.0

install:
./scripts/upgrade.sh --release $(RELEASE)
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

test: install goss

Expand Down
Loading

0 comments on commit 750cb52

Please sign in to comment.