Cloning volumes from an existing PersistentVolumeClaim

If the source cloud-ready image is converted from a manually-created PersistentVolumeClaim and CSI Volume Cloning is supported in your cluster and storage, you can clone volumes from the existing cloud-ready image to create another cloud-ready image in the same namespace. The cloning option is much faster than copying volumes from an existing PersistentVolumeClaim; therefore, use this option if CSI cloning is available.

Before you begin, ensure requirements mentioned in Preparing for sandbox instances provisioning are met. Note that the PersistentVolumeClaim to be used as the source must be created manually by a developer or the cluster administrator, that is, a PersistentVolumeClaim created by the Sandbox Operator automatically is not supported as the source.

Cloning volumes from an existing PersistentVolumeClaim is the fastest way to create a copy of a cloud-ready image for backup or use by another sandbox instance. Confirm with your cluster administrator whether the CSI Volume Cloning is available for your cluster and the storage. For more information about CSI Volume Cloning, see the Kubernetes documentation.

Note: Only a PersistentVolumeClaim in the same namespace can be cloned. If you need to create a cloudy-ready image in a different namespace, you need to use SFTP as described in Copying volumes from an SFTP server.
If the cloning function is available, complete the following procedure.
  1. If the source PersistentVolumeClaim is being used by a sandbox instance, complete the following steps to delete the sandbox instance before you clone volumes.
    1. Shut down the z/OS® system running on the sandbox instance.
    2. (Optional) Save the WaziSandboxSystem Custom Resource YAML file for the sandbox instance as backup.
    3. Delete the sandbox instance. For more information, see Deleting a sandbox instance.
  2. Create a YAML file with the following template.
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      # The name for the new PersistentVolumeClaim, must be unique in your
      # namespace
      name: my-sandbox-clone
      labels:
        # Copy any labels of the form "image.sandbox.wazi.ibm.com/*" from
        # the source claim ("my-sandbox-storage" in this example)
        image.sandbox.wazi.ibm.com/status: ready
        image.sandbox.wazi.ibm.com/type: complete
        image.sandbox.wazi.ibm.com/version: v1
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          # This must be same size or larger than the source claim
          # (the size of "my-sandbox-storage" in this example)
          storage: 300Gi
      # This must be same storage class as the source claim
      # (the storage class of "my-sandbox-storage" in this example)
      storageClassName: rook-ceph-block
      volumeMode: Filesystem
      dataSource:
        kind: PersistentVolumeClaim
        name: my-sandbox-storage

    To complete the template, you need to check the source PersistentVolumeClaim from the Red Hat® OpenShift® web console or from the command line.

  3. Create the clone with one of the following ways.
    • Run the oc command, for example, oc apply -f your_clone.yaml.

      Or, run kubectl command, for example, kubectl apply -f your_clone.yaml.

    • Use the Red Hat OpenShift web console from the Administrator perspective. Administrator privilege is required.
      1. Select the Administrator.
      2. Click Storage > Persistent Volume Claims.
      3. Click Create Persistent Volume Claim.
      4. Click Edit YAML.
      5. Copy and paste the contents of your modified YAML file over the template that is shown in the UI. Then, click Create.