Volume Snapshots
By default, this is disabled.
Sync VolumeSnapshot resources from the virtual cluster to the host cluster.
Until enabled, creating a VolumeSnapshot custom resource in the virtual cluster has no effect on the host cluster.
Host prerequisites​
- You should install the volume snapshots validating webhook in your host cluster and alternatively use the central admission controller feature within your vCluster.
- Your host cluster must have all relevant snapshot CRDs installed, without which the vCluster instance fails to start when volume snapshots sync is enabled.
- You should install a common snapshot controller on your host cluster, as well as a compatible CSI driver. Without these, vCluster cannot create the volume snapshots in the storage backend.
Sync VolumeSnapshots from the virtual to host cluster​
sync:
toHost:
volumeSnapshots:
enabled: true
Patches​
This feature is available in the vCluster Pro tier. Contact us for more details and to start a trial.
You can modify the sync behaviour with patches that target specific paths. Currently there is 2 different kinds of patches supported.
You can use *
in paths to select all entries of an array or object, e.g. spec.containers[*].name
or spec.containers[*].volumeMounts[*]
. vCluster calls the patch multiple times when using the wildcard reference.
JavaScript Expression Patches​
These are powerful JavaScript ES6 compatible expression patches that can be used to change a field while syncing. You define how it changes when syncing from the virtual cluster into the host cluster or when syncing from the host cluster into the virtual cluster. To change the path metadata.annotations[*] you can do:
sync:
toHost:
volumeSnapshots:
enabled: true
patches:
- path: metadata.annotations[*]
expression: '"my-prefix-"+value'
# optional reverseExpression to reverse the change from the host cluster
# reverseExpression: 'value.slice("my-prefix".length)'
There is also a variable called context
besides value
that can be used to access specific data of the virtual cluster:
context.vcluster.name
: Name of the virtual clustercontext.vcluster.namespace
: Namespace of the virtual clustercontext.vcluster.config
: Config of the virtual cluster, basicallyvcluster.yaml
merged with the defaultscontext.hostObject
: Host object (can be null if not available)context.virtualObject
: Virtual object (can be null if not available)context.path
: The matched path on the object, useful when using wildcard path selectors (*)
Reference patches​
A reference patch can be used to have a specific field of one resource point to a different resource that should get rewritten. vCluster automatically imports the referenced resource to the virtual cluster if it can find it in the host cluster. For example:
sync:
toHost:
volumeSnapshots:
enabled: true
patches:
- path: metadata.annotations["my-secret-ref"]
reference:
apiVersion: v1
kind: Secret
With this yaml, vCluster translates the path metadata.annotations["my-secret-ref"]
as it points to a secret. If the secret is created in the host cluster, vCluster automatically imports it into the virtual cluster.
With multi-namespace-mode you only need to rewrite references that include a namespace. You can use the namespacePath
option to specify the path of the namespace of the reference.
Config reference​
volumeSnapshots
required object pro​
VolumeSnapshots defines if volume snapshots created within the virtual cluster should get synced to the host cluster.
volumeSnapshots
required object pro​