Skip to content

Commit

Permalink
Issue 445: Reuse values for helm releases in post-upgrade script (#446)
Browse files Browse the repository at this point in the history
* ISsue 445: Reuse values for helm releases in post-upgrade script

Signed-off-by: SrishT <[email protected]>

* Issue 445: Adding fix for leader election issue

Signed-off-by: SrishT <[email protected]>

Co-authored-by: SrishT <[email protected]>
  • Loading branch information
SrishT and SrishT authored Sep 4, 2020
1 parent 7662f09 commit d0e2f64
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion doc/operator-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PravegaCluster resource name> <PravegaCluster release name> <BookkeeperCluster release name> <version> <namespace> <zookeeper svc name>
./post-upgrade.sh <PravegaCluster resource name> <PravegaCluster release name> <BookkeeperCluster release name> <version> <namespace> <zookeeper svc name> <bookkeeper replica count>
```
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).
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion doc/upgrade-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pravega cluster release name> <location of modified charts> --timeout 600s
$ helm upgrade <pravega cluster release name> <location of modified charts> --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

Expand Down
9 changes: 5 additions & 4 deletions scripts/post-upgrade.sh
Original file line number Diff line number Diff line change
@@ -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 <pravegacluster name> <pravega-release-name> <bookkeeper-release-name> <version> <namespace> <zk-svc-name>"
Usage: "./post-upgrade.sh <pravegacluster name> <pravega-release-name> <bookkeeper-release-name> <version> <namespace> <zk-svc-name> <bk-replicas>"
exit 1
fi

Expand All @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions scripts/pre-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions tools/operatorUpgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit d0e2f64

Please sign in to comment.