2020-09-08 20:37:59 +05:30
|
|
|
# Copyright © 2020 The OpenEBS Authors
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2020-04-01 13:53:13 +05:30
|
|
|
#!/bin/bash
|
|
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
# do not provision/deprovision anything while running the upgrade script.
|
|
|
|
|
|
2020-04-01 13:53:13 +05:30
|
|
|
set -e
|
|
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
if [ -z $1 ]; then
|
|
|
|
|
# default namespace is openebs when all the custom resources are created
|
|
|
|
|
ZFSPV_NAMESPACE="openebs"
|
|
|
|
|
else
|
|
|
|
|
ZFSPV_NAMESPACE=$1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Fetching ZFS Volumes"
|
|
|
|
|
numVol=`kubectl get zfsvolumes.openebs.io --no-headers -n $ZFSPV_NAMESPACE | wc -l`
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
if [ $numVol -gt 0 ]; then
|
|
|
|
|
# ZFSVolumes: create the new CR with apiVersion as zfs.openebs.io and kind as Volume
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
kubectl get zfsvolumes.openebs.io -n $ZFSPV_NAMESPACE -oyaml > volumes.yaml
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
# update the group name to zfs.openebs.io
|
|
|
|
|
sed -i "s/apiVersion: openebs.io/apiVersion: zfs.openebs.io/g" volumes.yaml
|
|
|
|
|
# create the new CR
|
|
|
|
|
kubectl apply -f volumes.yaml
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
rm volumes.yaml
|
|
|
|
|
fi
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
echo "Fetching ZFS Snapshots"
|
|
|
|
|
numSnap=`kubectl get zfssnapshots.openebs.io --no-headers -n $ZFSPV_NAMESPACE | wc -l`
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
if [ $numSnap -gt 0 ]; then
|
|
|
|
|
# ZFSSnapshots: create the new CR with apiVersion as zfs.openebs.io and kind as Snapshot
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
kubectl get zfssnapshots.openebs.io -n $ZFSPV_NAMESPACE -oyaml > snapshots.yaml
|
2020-04-01 13:53:13 +05:30
|
|
|
|
|
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
# update the group name to zfs.openebs.io
|
|
|
|
|
sed -i "s/apiVersion: openebs.io/apiVersion: zfs.openebs.io/g" snapshots.yaml
|
|
|
|
|
# create the new CR
|
|
|
|
|
kubectl apply -f snapshots.yaml
|
2020-04-01 13:53:13 +05:30
|
|
|
|
2020-04-17 13:59:28 +05:30
|
|
|
rm snapshots.yaml
|
|
|
|
|
fi
|