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

[meta] add support for k8s 1.16 #635

Merged
merged 14 commits into from
May 29, 2020
11 changes: 1 addition & 10 deletions elasticsearch/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@ include ../../../helpers/examples.mk

RELEASE := helm-es-upgrade

# Right now the version is hardcoded because helm install will ignore
# anything with an alpha tag when trying to install the latest release
# This hardcoding can be removed once we drop the alpha tag
# The "--set terminationGracePeriod=121" always makes sure that a rolling
# upgrade is forced for this test
install:
helm repo add elastic https://helm.elastic.co && \
helm upgrade --wait --timeout=600 --install $(RELEASE) elastic/elasticsearch --version 7.0.0-alpha1 --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
Expand Down
13 changes: 9 additions & 4 deletions elasticsearch/examples/upgrade/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Upgrade

This example deploy a 3 nodes Elasticsearch cluster using [7.0.0-alpha1][] chart
version, then upgrade it to 7.7.0 version.
This example will deploy a 3 node Elasticsearch cluster using an old chart version,
then upgrade it to version 7.7.0.

The following upgrades are tested:
- Upgrade from [7.0.0-alpha1][] version on K8S <1.16
- Upgrade from [7.4.0][] version on K8S >=1.16 (Elasticsearch chart < 7.4.0 are
not compatible with K8S >= 1.16)


## Usage

Running `make install` command will do both 7.0.0-alpha1 install and 7.7.0
upgrade
Running `make install` command will do first install and 7.7.0 upgrade


## Testing
Expand All @@ -16,4 +20,5 @@ You can also run [goss integration tests][] using `make test`


[7.0.0-alpha1]: https://github.com/elastic/helm-charts/releases/tag/7.0.0-alpha1
[7.4.0]: https://github.com/elastic/helm-charts/releases/tag/7.4.0
[goss integration tests]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/upgrade/test/goss.yaml
67 changes: 67 additions & 0 deletions elasticsearch/examples/upgrade/scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

set -eo pipefail
Conky5 marked this conversation as resolved.
Show resolved Hide resolved

usage() {
cat <<-EOF
USAGE:
$0 [--release <release-name>] [--from <elasticsearch-version>] --to <elasticsearch-version>
$0 --help

OPTIONS:
--release <release-name>
Conky5 marked this conversation as resolved.
Show resolved Hide resolved
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')
Conky5 marked this conversation as resolved.
Show resolved Hide resolved

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
1 change: 1 addition & 0 deletions helpers/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ APM_SERVER_SUITE:
KUBERNETES_VERSION:
- '1.14'
- '1.15'
- '1.16'
Copy link
Contributor

@Conky5 Conky5 May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could define the chart versions for upgrade testing here somehow so it is very clear what the test cases are, something like this

 - kubernetes_version: '1.14'
   upgrade_from_chart_version: '7.0.0-alpha1'
 - kubernetes_version: '1.15'
   upgrade_from_chart_version: '7.0.0-alpha1'
 - kubernetes_version: '1.16'
   upgrade_from_chart_version: '7.4.0'

But I think we can only fit this logic into the jenkins job inline shell script, or the Makefile inline shell script the way the job axes work, so adding into the Makefile makes sense to me.

2 changes: 1 addition & 1 deletion helpers/terraform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM centos:7

ENV VAULT_VERSION 0.9.3
ENV TERRAFORM_VERSION=0.11.7
ENV KUBECTL_VERSION=1.15.4
ENV KUBECTL_VERSION=1.16.10
ENV HELM_VERSION=2.16.7
ENV DOCKER_VERSION=18.09.7

Expand Down