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
kind: TransformSet
  name: sample-transformset
  namespace: kasten-io
  comment: "Transform Set Example"
    - subject:
        resource: deployments
      name: progressDeadlineSeconds5m
        - op: replace
          path: /spec/progressDeadlineSeconds
          value: 300
    - subject:
        resource: deployments
      name: scaleDeployment3
        - op: replace
          path: /spec/replicas
          value: 3

$ kubectl apply -f sample-transform-set.yaml created

# make sure it initializes and validates properly
$ kubectl get --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 configured

Once the change is submitted, K10 will re-validate the TransformSet and update .status.validation accordingly.

$ kubectl get --namespace kasten-io -w
NAME                  STATUS    AGE
sample-transformset   Failed    25m
sample-transformset   Success   30m

Since K10 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.


A transform set is invalid if it has no transforms or if one of the transforms it contains is invalid.

Using a TransformSet

The following example illustrates how to use a TransformSet in a RestoreAction.

$ cat > restore-action-with-transform-set.yaml <<EOF
kind: RestoreAction
  generateName: restore-nginx-
  namespace: nginx
    kind: RestorePoint
    name: backup-nginx-sdxg2
    namespace: nginx
  targetNamespace: nginx
    - json: []
        name: sample-transformset
        namespace: kasten-io

$ kubectl create -f restore-action-with-transform-set.yaml 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 K10 installed in "kasten-io"
$ kubectl delete sample-transformset --namespace 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.
# Standard Kubernetes Kind declaration. Required.
kind: TransformSet
# Standard Kubernetes metadata. Required.
  # 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.
  # User friendly comment describing the transform set. Optional.
  # The list of transforms. Required.
    # 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.
        # 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.
  # 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