#1 Global Leader in Data Protection & Ransomware Recovery

How to Add a Blueprint Target Using Execution Hooks From the Policy API

KB ID: 4597
Product: Veeam Kasten for Kubernetes
Published: 2024-06-11
Last Modified: 2024-06-11
mailbox
Get weekly article updates
By subscribing, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.

Cheers for trusting us with the spot in your mailbox!

Now you’re less likely to miss what’s been brewing in our knowledge base with this weekly digest

error icon

Oops! Something went wrong.

Please, try again later.

Purpose

This article explains how to set resources other than namespaces as the hooks for blueprint subjects. By default, hooks sets the namespace as the target for the blueprint unless specified otherwise.

Solution

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.

  • Before
  • After - On Success
  • After - On Failure
advanced settings

Why is it important to set the blueprint subject?

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.

Setting the Blueprint Subject in Policy API

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.

configure
To submit feedback regarding this article, please click this link: Send Article Feedback
To report a typo on this page, highlight the typo with your mouse and press CTRL + Enter.

Spelling error in text

This site is protected by hCaptcha and its Privacy Policy and Terms of Service apply except as noted in our Privacy Policy.
Thank you!

Thank you!

Your feedback has been received and will be reviewed.

Oops! Something went wrong.

Please, try again later.

You have selected too large block!

Please try select less.

KB Feedback/Suggestion

This form is only for KB Feedback/Suggestions, if you need help with the software open a support case

By submitting, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.
This site is protected by hCaptcha and its Privacy Policy and Terms of Service apply except as noted in our Privacy Policy.
Verify your email to continue your product download
We've sent a verification code to:
  • Incorrect verification code. Please try again.
An email with a verification code was just sent to
Didn't receive the code? Click to resend in sec
Didn't receive the code? Click to resend
Thank you!

Thank you!

Your feedback has been received and will be reviewed.

error icon

Oops! Something went wrong.

Please, try again later.