From d0e2f644321cd97eef60ae6bbe1038bf9c558ca2 Mon Sep 17 00:00:00 2001 From: Srishti Thakkar Date: Fri, 4 Sep 2020 18:02:05 +0530 Subject: [PATCH] Issue 445: Reuse values for helm releases in post-upgrade script (#446) * ISsue 445: Reuse values for helm releases in post-upgrade script Signed-off-by: SrishT * Issue 445: Adding fix for leader election issue Signed-off-by: SrishT Co-authored-by: SrishT --- doc/operator-upgrade.md | 3 ++- doc/upgrade-cluster.md | 3 ++- scripts/post-upgrade.sh | 9 +++++---- scripts/pre-upgrade.sh | 1 + tools/operatorUpgrade.sh | 6 ++++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/operator-upgrade.md b/doc/operator-upgrade.md index 1d3b3ef4a..7513cd49f 100644 --- a/doc/operator-upgrade.md +++ b/doc/operator-upgrade.md @@ -121,7 +121,7 @@ kubectl describe PravegaCluster ``` Execute the script `post-upgrade.sh` inside the [scripts](https://github.com/pravega/pravega-operator/blob/master/scripts) folder. The format of the command is ``` -./post-upgrade.sh +./post-upgrade.sh ``` This script patches the `PravegaCluster` and `BookkeeperCluster` resources with the required annotations and labels, and updates their corresponding helm releases. This script needs the following arguments 1. Name of the PravegaCluster or BookkeeperCluster resource (check the output of `kubectl get PravegaCluster` to obtain this name). @@ -130,6 +130,7 @@ This script patches the `PravegaCluster` and `BookkeeperCluster` resources with 4. Version of the PravegaCluster or BookkeeperCluster resources (check the output of `kubectl get PravegaCluster` to obtain the version number). 5. Namespace in which PravegaCluster and BookkeeperCluster resources are deployed (this is an optional parameter and its default value is `default`). 6. Name of the zookeeper client service (this is an optional parameter and its default value is `zookeeper-client`). +7. Number of replicas in the BookkeeperCluster (this is an optional parameter and its default value is 3). #### Upgrade manually diff --git a/doc/upgrade-cluster.md b/doc/upgrade-cluster.md index 0d2ff8426..274f0b8d5 100644 --- a/doc/upgrade-cluster.md +++ b/doc/upgrade-cluster.md @@ -36,8 +36,9 @@ To understand the valid upgrade paths for a pravega cluster, refer to the [versi The upgrade can be triggered via helm using the following command ``` -$ helm upgrade --timeout 600s +$ helm upgrade --reuse-values --timeout 600s ``` +By specifying the `--reuse-values` option, the values of all parameters are retained across upgrades. However if some values need to be modified during the upgrade, the `--set` flag can be used to specify the new values of these parameters. ### Upgrading manually diff --git a/scripts/post-upgrade.sh b/scripts/post-upgrade.sh index 6baae9bee..022debae5 100755 --- a/scripts/post-upgrade.sh +++ b/scripts/post-upgrade.sh @@ -1,9 +1,9 @@ #! /bin/bash set -ex -if [[ "$#" -lt 4 || "$#" -gt 6 ]]; then +if [[ "$#" -lt 4 || "$#" -gt 7 ]]; then echo "Error : Invalid number of arguments" - Usage: "./post-upgrade.sh " + Usage: "./post-upgrade.sh " exit 1 fi @@ -13,6 +13,7 @@ bkname=$3 version=$4 namespace=${5:-default} zksvc=${6:-zookeeper-client} +replicas=${7:-3} echo "Checking that the PravegaCluster resource is in ready state" kubectl describe PravegaCluster $name -n $namespace @@ -46,6 +47,6 @@ kubectl label ConfigMap $name-configmap app.kubernetes.io/managed-by=Helm -n $na helm repo add pravega https://charts.pravega.io helm repo update echo "Upgrading the pravega charts" -helm upgrade $pname pravega/pravega --version=$version --set fullnameOverride=$name --set zookeeperUri="$zksvc:2181" --set bookkeeperUri="$name-bookie-headless:3181" +helm upgrade $pname pravega/pravega --version=$version --set fullnameOverride=$name --set zookeeperUri="$zksvc:2181" --set bookkeeperUri="$name-bookie-headless:3181" -n $namespace --reuse-values echo "Installing the bookkeeper charts" -helm install $bkname pravega/bookkeeper --version=$version --set fullnameOverride=$name --set zookeeperUri="$zksvc:2181" --set pravegaClusterName=$name +helm install $bkname pravega/bookkeeper --version=$version --set fullnameOverride=$name --set zookeeperUri="$zksvc:2181" --set pravegaClusterName=$name --set replicas=$replicas --set options.journalDirectories="/bk/journal" --set options.ledgerDirectories="/bk/ledgers" -n $namespace diff --git a/scripts/pre-upgrade.sh b/scripts/pre-upgrade.sh index f07ba2420..ca6c40be2 100755 --- a/scripts/pre-upgrade.sh +++ b/scripts/pre-upgrade.sh @@ -13,3 +13,4 @@ namespace=$2 kubectl annotate Service pravega-webhook-svc meta.helm.sh/release-name=$name -n $namespace --overwrite kubectl annotate Service pravega-webhook-svc meta.helm.sh/release-namespace=$namespace -n $namespace --overwrite kubectl label Service pravega-webhook-svc app.kubernetes.io/managed-by=Helm -n $namespace --overwrite +kubectl delete cm pravega-operator-lock diff --git a/tools/operatorUpgrade.sh b/tools/operatorUpgrade.sh index 5c77509df..b45d72ce0 100755 --- a/tools/operatorUpgrade.sh +++ b/tools/operatorUpgrade.sh @@ -25,7 +25,7 @@ local temp_string_for_dns=pravega-webhook-svc.${namespace} sed -i "s/pravega-webhook-svc.default/${temp_string_for_dns}"/ ./manifest_files/secret.yaml -#Installing the secrets +#Installing the secrets kubectl apply -f ./manifest_files/secret.yaml #reverting the changes back in the secret.yaml file @@ -65,9 +65,11 @@ sed -i "s/value:.*/value: $op_name "/ ./manifest_files/patch.yaml sed -i "/imagePullPolicy:.*/{n;s/name.*/name: $op_name/}" ./manifest_files/patch.yaml +kubectl delete cm pravega-operator-lock + #updating the operator using patch file kubectl patch deployment $op_name --namespace ${namespace} --type merge --patch "$(cat ./manifest_files/patch.yaml)" } -UpgradingToPoperator $1 $2 $3 +UpgradingToPoperator $1 $2 $3