Transform Sets
A TransformSet custom resource (CR) is used to save and reuse the set of Transforms to be used in Restore Actions, Restore Cluster Actions and Policies.
Example TransformSet Operations
Create a TransformSet
The following example illustrates how to create a transform set that contains two transforms, one of which changes the deadline parameter value to 300 seconds and another one scales deployments to 3 replicas.
$ cat > sample-transform-set.yaml <<EOF
apiVersion: config.kio.kasten.io/v1alpha1
kind: TransformSet
metadata:
name: sample-transformset
namespace: kasten-io
spec:
comment: "Transform Set Example"
transforms:
- subject:
resource: deployments
name: progressDeadlineSeconds5m
json:
- op: replace
path: /spec/progressDeadlineSeconds
value: 300
- subject:
resource: deployments
name: scaleDeployment3
json:
- op: replace
path: /spec/replicas
value: 3
EOF
$ kubectl apply -f sample-transform-set.yaml
transformset.config.kio.kasten.io/sample-transformset created
# make sure it initializes and validates properly
$ kubectl get transformsets.config.kio.kasten.io --namespace kasten-io -w
NAME STATUS AGE
sample-transformset Success 30s
Update a TransformSet
To update a TransformSet, edit the spec portion of a TransformSet CR using your preferred method of submitting resource changes with kubectl.
$ kubectl apply -f sample-transform-set-updated.yaml
transformset.config.kio.kasten.io/sample-transformset configured
Once the change is submitted, Veeam Kasten will re-validate the TransformSet and update .status.validation accordingly.
$ kubectl get transformsets.config.kio.kasten.io --namespace kasten-io -w
NAME STATUS AGE
sample-transformset Failed 25m
sample-transformset Success 30m
Since Veeam Kasten processes API object changes asynchronously, to avoid confusion with a previous TransformSet status, it is recommended as convention that the status portion of the TransformSet is omitted when submitting changes.
Warning
Using a TransformSet
The following example illustrates how to use a TransformSet in a RestoreAction.
$ cat > restore-action-with-transform-set.yaml <<EOF
apiVersion: actions.kio.kasten.io/v1alpha1
kind: RestoreAction
metadata:
generateName: restore-nginx-
namespace: nginx
spec:
subject:
kind: RestorePoint
name: backup-nginx-sdxg2
namespace: nginx
targetNamespace: nginx
transforms:
- json: []
transformSetRef:
name: sample-transformset
namespace: kasten-io
EOF
$ kubectl create -f restore-action-with-transform-set.yaml
restoreaction.actions.kio.kasten.io/restore-nginx-l69nd created
The TransformSet will be applied to the restored application.
Delete a TransformSet
A TransformSet can be deleted using the following command.
# delete transformset "sample-transformset" for Veeam Kasten installed in "kasten-io"
$ kubectl delete transformsets.config.kio.kasten.io sample-transformset --namespace kasten-io
transformset.config.kio.kasten.io "sample-transformset" deleted
TransformSet API Type
The following is a complete specification of a TransformSet CR.
To learn more about the transforms structure, see Transforms.
# Standard Kubernetes API Version declaration. Required.
apiVersion: config.kio.kasten.io/v1alpha1
# Standard Kubernetes Kind declaration. Required.
kind: TransformSet
# Standard Kubernetes metadata. Required.
metadata:
# TransformSet name. May be any valid Kubernetes object name. Required.
# TransformSet name is not mutable once created.
name: sample-transformset
# TransformSet namespace. Required.
namespace: kasten-io
# TransformSet parameters. Required.
spec:
# User friendly comment describing the transform set. Optional.
comment:
# The list of transforms. Required.
transforms:
# Specifies which resource artifacts to apply this transform to. Required.
# At least one filter should be set.
- subject:
# Resource group. Optional.
group: apps
# Resource version. Optional.
version: v1
# Resource type. Optional.
resource: deployments
# Resource name. Optional.
name: my-app
# The name of the transform. Required.
name: 'copyRelease'
# An array of RFC-6902 JSON patch-like operations. Required.
json:
# Operation name. Required.
# Transforms support six command operations:
# # 'test' - checks that an element exists (and equals the value / matches the regexp if specified)
# # 'add' - inserts a new element to the resource definition
# # 'remove' - deletes an existing element from the resource definition
# # 'copy' - duplicates an element, overwriting the value in the new path if it already exists
# # 'move' - relocates an element, overwriting the value in the new path if it already exists
# # 'replace' - replaces an existing element with a new element
- op: copy
# Source reference for operation. Optional.
# Required and valid only for 'move' and 'copy' operations.
from: '/metadata/labels/release'
# Target reference for operation. Required for every operation.
path: '/spec/template/metadata/labels/release'
# Regex to match expression. Optional.
# When used with 'copy', 'move' or 'replace' operation,
# the transform will match the target text against the `regex`
# and substitute regex capturing groups with `value`.
# When used with 'test' operation,
# the transform will match the target text against the `regex`.
regex: 'prod-v.*'
# Value is any valid JSON. Optional.
# Required for 'add' and 'replace' operations.
# Required for 'copy' and 'move' operations only when used along with `regex`.
# 'test' operation can use either `regex` or `value`.
value: 'prod'
# Status of the TransformSet. Users should not set any data here.
status:
# Object generation last observed by the controller
observedGeneration: 2
# Validation status of the TransformSet
# Valid values are:
# # Success – successfully initialized and validated
# # Failed - not properly initialized or validated
# # Indeterminate – indicate an indeterminate validation status for multi-cluster TransformSets.
validation: Success
# An array of any validation or initialization errors encountered.
error: null