Veeam Kasten for Kubernetes supports kanister execution hooks through Policy API. Kanister Blueprints can be used to execute arbitrary functionality before or after Kasten Actions.
It can be used to run pre/post hook actions for backup as well as restore(incase of import policies).
There are three types of hooks that Veeam Kasten for Kubernetes policy API supports.
One of the blueprint examples in Veeam Kasten for Kubernetes documentation has the application consistent backup blueprint for MongoDB. This blueprint uses template parameters like the following to render the namespace name and name of the pods created by the deployment, respectively.
{{. deployment.Namespace }} and {{ index .Deployment.Pods 0 }}
However, while reusing these blueprints for pre/post hook action in the Policy API, these templates fail to render with the error:
executing "config" at <.Deployment.Name>: nil pointer evaluating *param.DeploymentParams.Name'
This occurs because the deployment cannot be referenced with template parameters when the namespace is the subject of the blueprint.
In such a situation, it is important to specify the deployment as the blueprint subject.
The blueprint subject can be manually patched or added to the YAML manifest by adding the type of the hook, actionName, and blueprint and then specifying the subject under the hooks field, as shown in the code block below.
hooks: preHook: actionName: backupPrehook blueprint: mongo-hooks subject: name: mongodb-app-consistent namespace: mongodb-app-consistent type: deployment
After adding the blueprint subjects, the policy should look like the following code block.
apiVersion: config.kio.kasten.io/v1alpha1 kind: Policy metadata: name: mongodb-app-consistent-backup namespace: kasten-io spec: actions: - action: backup backupParameters: hooks: preHook: actionName: backupPrehook blueprint: mongo-hooks subject: name: mongodb-app-consistent namespace: mongodb-app-consistent type: deployment onFailure: actionName: backupPosthook blueprint: mongo-hooks subject: name: mongodb-app-consistent namespace: mongodb-app-consistent type: deployment profile: name: test-jai1 namespace: kasten-io frequency: '@hourly' retention: daily: 7 hourly: 24 monthly: 12 weekly: 4 yearly: 7 selector: matchExpressions: - key: k10.kasten.io/appNamespace operator: In values: - mongodb-app-consistent
Note: The target resource (blueprint subject) can be set in the import+restore policy from the UI itself. However, Veeam Kasten for Kubernetes doesn’t have this option in the backup/export policy form in the UI yet. This may be added to the product in a future release. Until then, Subjects have to be manually added to the policy manifest, as explained above.
This form is only for KB Feedback/Suggestions, if you need help with the software open a support case