vcluster icon indicating copy to clipboard operation
vcluster copied to clipboard

keep-pvc option is not keeping the pvc inside vcluster

Open ericjee opened this issue 3 years ago • 4 comments

Hi, I think this is more like a feature request. Currently, after I delete the vcluster by vcluster delete, only the PVC of the vcluster itself can be retained, all other PVCs used inside the vcluster have been deleted, So after recreating the vcluster, my statefulset app can't go back to running state because it cannot bound the correct PV. Thx for creating this magic suite, any response will be appreciated :)

ericjee avatar Dec 10 '21 08:12 ericjee

@ericjee thanks for creating this issue! You can retain all objects by using the syncer flag (make sure you use the v0.5.0-alpha.7 version):

Create a values.yaml and then apply with vcluster create ... --upgrade -f values.yaml

syncer:
  extraArgs:
    - '--set-owner=false'

This will keep all objects the vcluster has created running including PVCs

FabianKramm avatar Dec 10 '21 10:12 FabianKramm

@FabianKramm hi, I tried to set the option --set-owner=false in v0.5.0-alpha.7, After I delete vcluster, all objects inside vcluster are still alive, the status of all pods list in the lower cluster namespace is running, It's this normal behavior?

ericjee avatar Dec 11 '21 13:12 ericjee

@ericjee Are you using reclaimPolicy: Retain on your storage class? That should instruct Kubernetes to not delete volumes unless you do that manually https://kubernetes.io/docs/concepts/storage/storage-classes/#reclaim-policy

However some extra logic might be still needed to make sure that same resources are used after re-creating vcluster.

olljanat avatar Dec 14 '21 20:12 olljanat

@ericjee Are you using reclaimPolicy: Retain on your storage class? That should instruct Kubernetes to not delete volumes unless you do that manually https://kubernetes.io/docs/concepts/storage/storage-classes/#reclaim-policy

However some extra logic might be still needed to make sure that same resources are used after re-creating vcluster.

Yes, I'm using Retain policy, That's exactly what I want, I want objects(statefulsets) inside k3s can be terminated when I deleted vcluster, All objects inside k3s can be restored to its normal running state after I recreated vcluster with same volume.

ericjee avatar Dec 17 '21 03:12 ericjee

@ericjee vcluster CLI has two commands that might work for your use case. Instead of deleting the vcluster you could pause it:

Usage:
  vcluster [command]
  ...
  pause       Pauses a virtual cluster
  resume      Resumes a virtual cluster

matskiv avatar Sep 22 '22 09:09 matskiv

@ericjee Do the vcluster pause and vcluster resume commands that I mentioned in the previous comment satisfy your use case?

matskiv avatar Oct 14 '22 14:10 matskiv

Let us know if the suggestions from the previous two comments don't satisfy your use case, and I will reopen the issue if you are still interested in this feature.

matskiv avatar Feb 03 '23 09:02 matskiv