Skip to content

Commit

Permalink
feat(crd): upgrade script for refactoring the CRD
Browse files Browse the repository at this point in the history
steps to upgrade :-

1. apply the crd yaml

$ kubectl apply -f upgrade/crd.yaml

2. run upgrade.sh

$ upgrade/upgrade.sh

3. upgrade the driver to v0.6

$ kubectl apply -f https://github.com/openebs/zfs-localpv/blob/v0.6.x/deploy/zfs-operator.yaml

4. if everything looks good run the cleanup.sh, it will clean old CRs and delete the CRD

$ upgrade/cleanup.sh

Signed-off-by: Pawan <pawan@mayadata.io>
  • Loading branch information
pawanpraka1 committed Mar 28, 2020
1 parent 27517c6 commit d2f565b
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
28 changes: 28 additions & 0 deletions upgrade/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

kubectl get zfsvolumes.openebs.io -n openebs -oyaml > volumes.yaml

# remove the finalizer from the old CR
sed -i "/zfs.openebs.io\/finalizer/d" volumes.yaml
kubectl apply -f volumes.yaml

# delete the old CR
kubectl delete -f volumes.yaml

# delete the CRD definition
kubectl delete crd zfsvolumes.openebs.io


kubectl get zfssnapshots.openebs.io -n openebs -oyaml > snapshots.yaml

# remove the finalizer from the old CR
sed -i "/zfs.openebs.io\/finalizer/d" snapshots.yaml
kubectl apply -f snapshots.yaml

# delete the old CR
kubectl delete -f snapshots.yaml

# delete the CRD definition
kubectl delete crd zfssnapshots.openebs.io
68 changes: 68 additions & 0 deletions upgrade/crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
##############################################
########### ############
########### ZFSVolume CRD ############
########### ############
##############################################
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: volumes.zfs.openebs.io
spec:
group: zfs.openebs.io
version: v1alpha1
scope: Namespaced
names:
plural: volumes
singular: volume
kind: Volume
shortNames:
- zfsvol
- zv
additionalPrinterColumns:
- JSONPath: .spec.poolName
name: ZPool
description: ZFS Pool where the volume is created
type: string
- JSONPath: .spec.ownerNodeID
name: Node
description: Node where the volume is created
type: string
- JSONPath: .spec.capacity
name: Size
description: Size of the volume
type: string
- JSONPath: .spec.volblocksize
name: volblocksize
description: volblocksize for the created zvol
type: string
- JSONPath: .spec.recordsize
name: recordsize
description: recordsize for the created zfs dataset
type: string
- JSONPath: .spec.fsType
name: Filesystem
description: filesystem created on the volume
type: string
---
##############################################
########### ############
########### Snapshot CRD ############
########### ############
##############################################

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: snapshots.zfs.openebs.io
spec:
group: zfs.openebs.io
version: v1alpha1
scope: Namespaced
names:
plural: snapshots
singular: snapshot
kind: Snapshot
shortNames:
- zfssnapshot
- zfssnap
---
32 changes: 32 additions & 0 deletions upgrade/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

# ZFSVolumes: create the new CR with apiVersion as zfs.openebs.io and kind as Volume

kubectl get zfsvolumes.openebs.io -n openebs -oyaml > volumes.yaml


# update the group name to zfs.openebs.io
sed -i "s/apiVersion: openebs.io/apiVersion: zfs.openebs.io/g" volumes.yaml
# update the kind to Volume
sed -i "s/kind: ZFSVolume/kind: Volume/g" volumes.yaml
# create the new CR
kubectl apply -f volumes.yaml

rm volumes.yaml


# ZFSSnapshots: create the new CR with apiVersion as zfs.openebs.io and kind as Snapshot

kubectl get zfssnapshots.openebs.io -n openebs -oyaml > snapshots.yaml


# update the group name to zfs.openebs.io
sed -i "s/apiVersion: openebs.io/apiVersion: zfs.openebs.io/g" snapshots.yaml
# update the kind to Snapshot
sed -i "s/kind: ZFSSnapshot/kind: Snapshot/g" snapshots.yaml
# create the new CR
kubectl apply -f snapshots.yaml

rm snapshots.yaml

0 comments on commit d2f565b

Please sign in to comment.