Skip to content

Instantly share code, notes, and snippets.

@shubham14bajpai
Last active June 12, 2020 04:56
Show Gist options
  • Save shubham14bajpai/acc1331650f3be4538dc74577bde61a2 to your computer and use it in GitHub Desktop.
Save shubham14bajpai/acc1331650f3be4538dc74577bde61a2 to your computer and use it in GitHub Desktop.
Migrating OpenEBS setup to another namespace.

OpenEBS set with one jiva volume in default namespace.

mayadata:setup$ kubectl get pods
NAME                                                              READY   STATUS    RESTARTS   AGE
openebs-admission-server-8695fd778c-n4tw7                         1/1     Running   0          3m32s
openebs-apiserver-66f7f86b55-7fdtl                                1/1     Running   2          3m32s
openebs-localpv-provisioner-58cc756c78-tmfmp                      1/1     Running   0          3m32s
openebs-ndm-c2w7s                                                 1/1     Running   0          3m32s
openebs-ndm-operator-6f7f9c6778-qjhfn                             1/1     Running   1          3m32s
openebs-provisioner-5bd587c6c5-lhwrm                              1/1     Running   0          3m32s
openebs-snapshot-operator-7569cf77ff-5z8bx                        2/2     Running   0          3m32s
percona-2-74dc576fcb-wm9b4                                        1/1     Running   0          2m7s
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl-56b798d8fb-89rhh    2/2     Running   0          2m6s
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1-79dc684488-f8vlj   1/1     Running   0          115s

Steps for migration of OpenEBS setup.

  1. Uninstall OpenEBS using helm. After uninstall only the application and volume deployments remain.
mayadata:setup$ helm uninstall --namespace default openebs
release "openebs" uninstalled
mayadata:setup$ kubectl get pods
NAME                                                              READY   STATUS    RESTARTS   AGE
percona-2-74dc576fcb-wm9b4                                        1/1     Running   0          6m34s
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl-56b798d8fb-89rhh    2/2     Running   0          6m33s
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1-79dc684488-f8vlj   1/1     Running   0          6m22s
  1. Install OpenEBS in openebs namespace.
mayadata:setup$ kubectl create ns openebs
namespace/openebs created
mayadata:setup$ helm install --namespace openebs openebs stable/openebs --version 1.9.0
NAME: openebs
LAST DEPLOYED: Mon May  4 18:48:31 2020
NAMESPACE: openebs
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The OpenEBS has been installed. Check its status by running:
$ kubectl get pods -n openebs

For dynamically creating OpenEBS Volumes, you can either create a new StorageClass or
use one of the default storage classes provided by OpenEBS.

Use `kubectl get sc` to see the list of installed OpenEBS StorageClasses. A sample
PVC spec using `openebs-jiva-default` StorageClass is given below:"

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: demo-vol-claim
spec:
  storageClassName: openebs-jiva-default
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5G
---

Please note that, OpenEBS uses iSCSI for connecting applications with the
OpenEBS Volumes and your nodes should have the iSCSI initiator installed.

For more information, visit our Slack at https://openebs.io/community or view the documentation online at http://docs.openebs.io/.
mayadata:setup$ kubectl get pods -n openebs
NAME                                          READY   STATUS    RESTARTS   AGE
openebs-admission-server-8695fd778c-gm9bc     1/1     Running   0          86s
openebs-apiserver-66f7f86b55-wj4f5            1/1     Running   0          86s
openebs-localpv-provisioner-fd8bf7d65-vctlp   1/1     Running   0          86s
openebs-ndm-6zbc9                             1/1     Running   0          86s
openebs-ndm-operator-6f7f9c6778-lbhdn         1/1     Running   0          86s
openebs-provisioner-664b96f6fd-f8j9x          1/1     Running   0          86s
openebs-snapshot-operator-6f6966895c-qkdms    2/2     Running   0          85s

Steps for migrating Jiva volume resources from default to openebs namespace.

  1. Scale down any application that uses the volume. In this case scaled down percona-2 deployment.
mayadata:setup$ kubectl get deployments
NAME                                             READY   UP-TO-DATE   AVAILABLE   AGE
percona-2                                        0/0     0            0           13m
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl    1/1     1            1           13m
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1   1/1     1            1           13m
  1. Get the PV name for the PVC.
mayadata:setup$ kubectl get pvc
NAME               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
demo-vol-claim-2   Bound    pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665   5Gi        RWO            jiva-1r        14m

In this case the PV name will be pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665.

  1. List all volume related resources and copy them to a yaml file.
mayadata:setup$ kubectl get deployments,services -l openebs.io/persistent-volume=pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665
NAME                                                             READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl    1/1     1            1           16m
deployment.apps/pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1   1/1     1            1           16m

NAME                                                        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                      AGE
service/pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl-svc   ClusterIP   10.0.0.23    <none>        3260/TCP,9501/TCP,9500/TCP   16m

mayadata:setup$ kubectl get deployments,services -l openebs.io/persistent-volume=pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665 -oyaml > resources.yaml
  1. Now edit resources.yaml file and remove resourceVersion from all the objects and modify namespace to openebs

  2. Scale down all volume related deployments.

mayadata:setup$ kubectl get deployments -l openebs.io/persistent-volume=pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665
NAME                                             READY   UP-TO-DATE   AVAILABLE   AGE
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl    0/0     0            0           20m
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1   0/0     0            0           20m
  1. Delete the volume service from default namespace.
mayadata:setup$ kubectl delete svc pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl-svc 
service "pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl-svc" deleted
  1. Apply the edited resources.yaml
mayadata:setup$ kubectl apply -f resources.yaml 
deployment.apps/pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl created
deployment.apps/pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1 created
service/pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl-svc created
  1. Verify all deployments are running and then scale up the application.
mayadata:setup$ kubectl -n openebs get pods
NAME                                                              READY   STATUS    RESTARTS   AGE
openebs-admission-server-8695fd778c-gm9bc                         1/1     Running   0          11m
openebs-apiserver-66f7f86b55-wj4f5                                1/1     Running   0          11m
openebs-localpv-provisioner-fd8bf7d65-vctlp                       1/1     Running   0          11m
openebs-ndm-6zbc9                                                 1/1     Running   0          11m
openebs-ndm-operator-6f7f9c6778-lbhdn                             1/1     Running   0          11m
openebs-provisioner-664b96f6fd-f8j9x                              1/1     Running   0          11m
openebs-snapshot-operator-6f6966895c-qkdms                        2/2     Running   0          11m
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl-56b798d8fb-4nl88    2/2     Running   0          22s
pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1-79dc684488-rfgtp   1/1     Running   0          22s

mayadata:setup$ kubectl edit deployments percona-2 
deployment.apps/percona-2 edited
mayadata:setup$ kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
percona-2-74dc576fcb-zfr4m   1/1     Running   0          6m2s
  1. Delete volume deployments from default namespace.
mayadata:setup$ kubectl delete deployments -l openebs.io/persistent-volume=pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665 -n default
deployment.apps "pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-ctrl" deleted
deployment.apps "pvc-2fb7a1d8-e2f2-49b4-b38f-a5e365ce4665-rep-1" deleted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment