Solved

Trigger Policy Automatically from Helm hook


Userlevel 3

Dear,

We have an application on witch we have create a scheduled policy (every day at midnight).

 

However we would like to trigger the policy automatically every time the application is upgraded via helm chart, using the pre-upgrade hook of helm.

 

This would allow to take a backup before any upgrade is performed and being able to rollback if something goes wrong.

 

Triggering the policy manually is not feasible in our context because clusters are managed via GitOps striving for minimal human activities.

 

I have searched over the web but didn’t find nothing to trigger the policy from helm.

 

Thank you in advance.

Matteo.

icon

Best answer by Anonymous 25 May 2022, 11:04

View original

2 comments

Hi @Matteo.Gazzadi 

I believe you need our “RunAction” API call which is associated with running a policy manually.  This is similar to hitting “Run Once” in the UI.

https://docs.kasten.io/latest/api/actions.html#runaction

It looks something like this which you can put into your pre-hook (just change the name of your policy from ‘postgresql-backup’ to something else:

kind: RunAction
apiVersion: actions.kio.kasten.io/v1alpha1
metadata:
name: run-once
spec:
subject:
apiVersion: config.kio.kasten.io/v1alpha1
kind: Policy
name: postgresql-backup
namespace: kasten-io

If you wanted to run a manual backup not associated with a Policy, you’d use the similar API “BackupAction”: https://docs.kasten.io/latest/api/actions.html#backupaction

Note: in both cases, because we leverage GFS retention, all manually executed backups are retained forever and do not affect scheduled retention policies.  This does mean you need to make use of our RestorePoint and RestorePointContent “Delete” API: https://docs.kasten.io/latest/api/restorepoints.html to restore storage capacity.  We are looking into some feature enhancement in this area to expire manual backups.

As a workaround, our support engineer @jaiganeshjk wrote a helpful article on cleaning up manual backups using Kubectl: https://docs.google.com/document/d/1rSpS74_3jFyV4ipuKn6FblivtglVKvxMFPP_sTBDBSw/edit#heading=h.o6352eqd3nyp

Hope this helps!

Hi @Matteo.Gazzadi - kindly refer to https://kb.kasten.io/knowledge/cleaning-up-the-manual-backups-taken-by-kasten-k10 for the official means of manually cleaning up backups. 

Comment