mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-08 00:57:19 +00:00
Merge pull request #795 from wwitzel3/hooks-with-pv
Update Pre/Post hooks example.
This commit is contained in:
+34
-5
@@ -14,11 +14,6 @@ As of version v0.7.0, Ark also supports "post" hooks - these execute after all c
|
||||
completed, as well as after all the additional items specified by custom actions have been backed
|
||||
up.
|
||||
|
||||
An example of when you might use both pre and post hooks is freezing a file system. If you want to
|
||||
ensure that all pending disk I/O operations have completed prior to taking a snapshot, you could use
|
||||
a pre hook to run `fsfreeze --freeze`. Next, Ark would take a snapshot of the disk. Finally, you
|
||||
could use a post hook to run `fsfreeze --unfreeze`.
|
||||
|
||||
There are two ways to specify hooks: annotations on the pod itself, and in the Backup spec.
|
||||
|
||||
### Specifying Hooks As Pod Annotations
|
||||
@@ -51,4 +46,38 @@ Ark v0.7.0+ continues to support the original (deprecated) way to specify pre ho
|
||||
Please see the documentation on the [Backup API Type][1] for how to specify hooks in the Backup
|
||||
spec.
|
||||
|
||||
## Hook Example with fsfreeze
|
||||
|
||||
We are going to walk through using both pre and post hooks for freezing a file system. Freezing the
|
||||
file system is useful to ensure that all pending disk I/O operations have completed prior to taking a snapshot.
|
||||
|
||||
We will be using [example/nginx-app/with-pv.yaml][2] for this example. Follow the [steps for your provider][3] to
|
||||
setup this example.
|
||||
|
||||
### Annotations
|
||||
|
||||
The Ark [example/nginx-app/with-pv.yaml][2] serves as an example of adding the pre and post hook annotations directly
|
||||
to your declarative deployment. Below is an example of what updating an object in place might look like.
|
||||
|
||||
```shell
|
||||
kubectl annotate pod -n nginx-example -l app=nginx \
|
||||
pre.hook.backup.ark.heptio.com/command='["/sbin/fsfreeze", "--freeze", "/var/log/nginx"]' \
|
||||
pre.hook.backup.ark.heptio.com/container=fsfreeze \
|
||||
post.hook.backup.ark.heptio.com/command='["/sbin/fsfreeze", "--unfreeze", "/var/log/nginx"]' \
|
||||
post.hook.backup.ark.heptio.com/container=fsfreeze
|
||||
```
|
||||
|
||||
Now test the pre and post hooks by creating a backup. You can use the Ark logs to verify that the pre and post
|
||||
hooks are running and exiting without error.
|
||||
|
||||
```shell
|
||||
ark backup create nginx-hook-test
|
||||
|
||||
ark backup get nginx-hook-test
|
||||
ark backup logs nginx-hook-test | grep hookCommand
|
||||
```
|
||||
|
||||
|
||||
[1]: api-types/backup.md
|
||||
[2]: examples/nginx-app/with-pv.yaml
|
||||
[3]: cloud-common.md
|
||||
|
||||
Reference in New Issue
Block a user