Skip to content

Commit

Permalink
Update webhook docs (#220)
Browse files Browse the repository at this point in the history
* Update webhook docs

Signed-off-by: Emruz Hossain <[email protected]>

* Add hook templating guide in overview page

Signed-off-by: Emruz Hossain <[email protected]>

* Add Slack notification guide

Signed-off-by: Emruz Hossain <[email protected]>

* Re-structure hook guides

Signed-off-by: Emruz Hossain <[email protected]>

* Fix hook guide links

Signed-off-by: Emruz Hossain <[email protected]>
  • Loading branch information
Emruz Hossain authored Apr 18, 2022
1 parent 1bb4d0d commit 3c1434d
Show file tree
Hide file tree
Showing 46 changed files with 668 additions and 72 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Shows different uses cases of Stash like instant backup, pause backup, cross-nam
- [Customize Backup and Restore](/docs/guides/use-cases/customize-backup-restore/index.md): Shows how to customize backup and restore processes in Stash according to your needs.
- [Platforms](/docs/guides/platforms/eks-irsa/index.md): Shows how to use Stash to backup and restore volumes of a Kubernetes workload running in different platforms.
- [Monitoring](/docs/guides/monitoring/overview/index.md): Shows how Prometheus monitoring works with Stash, what metrics Stash exports, and how to enable monitoring.
- [Hooks](/docs/guides/hooks/overview.md): Shows how to execute different actions before/after the backup/restore process.
- [Hooks](/docs/guides/hooks/overview/index.md): Shows how to execute different actions before/after the backup/restore process.
- [CLI](/docs/guides/cli/cli.md): Shows how to manage Stash objects quickly and easily using Stash `kubectl` plugin.
- [Troubleshooting](/docs/guides/troubleshooting/how-to-troubleshoot/index.md): Gives an overview of how you can gather the necessary information to identify the issue that causes the backup/restore failure.
- [Security](/docs/guides/security/rbac.md): Describes different built-in cluster security support by Stash.
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/crds/backupbatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ A `BackupBatch` object has the following fields in the `spec` section.
- **spec.hooks.preBackup:** `spec.hooks.preBackup` hooks are executed on each backup session before taking backup of any of the members.
- **spec.hooks.postBackup:** `spec.hooks.postBackup` hooks are executed on each backup session after taking backup of all the members.

For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview.md).
For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview/index.md).

#### spec.runtimeSettings

Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/crds/backupconfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ A `BackupConfiguration` object has the following fields in the `spec` section.
- **spec.hooks.preBackup:** `spec.hooks.preBackup` hooks are executed before the backup process.
- **spec.hooks.postBackup:** `spec.hooks.postBackup` hooks are executed after the backup process.

For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview.md).
For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview/index.md).

#### spec.runtimeSettings

Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/crds/restorebatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ A `RestoreBatch` object has the following fields in the `spec` section.
- **spec.hooks.preRestore:** `spec.hooks.preRestore` hooks are executed before restoring any of the members.
- **spec.hooks.postRestore:** `spec.hooks.postRestore` hooks are executed after restoring all the members.

For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview.md).
For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview/index.md).

### RestoreBatch `Status`

Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/crds/restoresession.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ A `RestoreSession` object has the following fields in the `spec` section.
- **spec.hooks.preRestore:** `spec.hooks.preRestore` hooks are executed before the restore process.
- **spec.hooks.postRestore:** `spec.hooks.postRestore` hooks are executed after the restore process.

For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview.md).
For more details on how hooks work in Stash and how to configure different types of hook, please visit [here](/docs/guides/hooks/overview/index.md).

#### spec.runtimeSettings

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Shows different uses cases of Stash like instant backup, pause backup, cross-nam
- [Customize Backup and Restore](/docs/guides/use-cases/customize-backup-restore/index.md): Shows how to customize backup and restore processes in Stash according to your needs.
- [Platforms](/docs/guides/platforms/eks-irsa/index.md): Shows how to use Stash to backup and restore volumes of a Kubernetes workload running in different platforms.
- [Monitoring](/docs/guides/monitoring/overview/index.md): Shows how Prometheus monitoring works with Stash, what metrics Stash exports, and how to enable monitoring.
- [Hooks](/docs/guides/hooks/overview.md): Shows how to execute different actions before/after the backup/restore process.
- [Hooks](/docs/guides/hooks/overview/index.md): Shows how to execute different actions before/after the backup/restore process.
- [CLI](/docs/guides/cli/cli.md): Shows how to manage Stash objects quickly and easily using Stash `kubectl` plugin.
- [Troubleshooting](/docs/guides/troubleshooting/how-to-troubleshoot/index.md): Gives an overview of how you can gather the necessary information to identify the issue that causes the backup/restore failure.
- [Security](/docs/guides/security/rbac.md): Describes different built-in cluster security support by Stash.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Here, we are going to demonstrate how you can perform different actions before a
- Install Stash Enterprise in your cluster following the steps [here](/docs/setup/install/enterprise.md).
- Install [KubeDB](https://kubedb.com) in your cluster following the steps [here](https://kubedb.com/docs/latest/setup/). This step is optional. You can deploy your database using any method you want. We are using KubeDB because KubeDB simplifies many of the difficult or tedious management tasks of running production-grade databases on private and public clouds.
- If you are not familiar with how Stash backup and restore MySQL databases, please check the following guide [here](/docs/addons/mysql/overview/index.md).
- Also, if you haven't read about how hooks work in Stash, please check it from [here](/docs/guides/hooks/overview.md).
- Also, if you haven't read about how hooks work in Stash, please check it from [here](/docs/guides/hooks/overview/index.md).

You should be familiar with the following `Stash` concepts:

Expand Down Expand Up @@ -73,7 +73,7 @@ spec:
Let's create the above `MySQL` CR,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/sample-mysql.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/backup-and-restore-hooks/examples/sample-mysql.yaml
mysql.kubedb.com/sample-mysql created
```

Expand Down Expand Up @@ -270,7 +270,7 @@ spec:
Let's create the `Repository` we have shown above,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/repository.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/backup-and-restore-hooks/examples/repository.yaml
repository.stash.appscode.com/gcs-repo created
```

Expand Down Expand Up @@ -322,7 +322,7 @@ spec:
Let's create the above `BackupConfiguration`,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/pre_backup_hook_demo.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/backup-and-restore-hooks/examples/pre_backup_hook_demo.yaml
backupconfiguration.stash.appscode.com/backup-hook-demo created
```

Expand Down Expand Up @@ -441,7 +441,7 @@ spec:
Let's apply the update,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/post_backup_hook_demo.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/backup-and-restore-hooks/examples/post_backup_hook_demo.yaml
backupconfiguration.stash.appscode.com/backup-hook-demo configured
```

Expand Down Expand Up @@ -575,7 +575,7 @@ spec:
Let's create the above `RestoreSession`,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/pre_restore_hook_demo.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/backup-and-restore-hooks/examples/pre_restore_hook_demo.yaml
restoresession.stash.appscode.com/pre-restore-hook-demo created
```

Expand Down Expand Up @@ -673,7 +673,7 @@ spec:
Let's create the above `RestoreSession`,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/post_restore_hook_demo.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/backup-and-restore-hooks/examples/post_restore_hook_demo.yaml
restoresession.stash.appscode.com/post-restore-hook-demo created
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Here, we are going to demonstrate how to send a notification to a Slack channel
- Install Stash Enterprise in your cluster following the steps [here](/docs/setup/install/enterprise.md).
- Install [KubeDB](https://kubedb.com) in your cluster following the steps [here](https://kubedb.com/docs/latest/setup/). This step is optional. You can deploy your database using any method you want. We are using KubeDB because KubeDB simplifies many of the difficult or tedious management tasks of running production-grade databases on private and public clouds.
- If you are not familiar with how Stash backup and restore MySQL databases, please check the following guide [here](/docs/addons/mysql/overview/index.md).
- Also, if you haven't read about how hooks work in Stash, please check it from [here](/docs/guides/hooks/overview.md).
- Also, if you haven't read about how hooks work in Stash, please check it from [here](/docs/guides/hooks/overview/index.md).

You should be familiar with the following `Stash` concepts:

Expand Down Expand Up @@ -85,7 +85,7 @@ spec:
Let's create the above database,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/batch-backup/wordpress-mysql.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/batch-backup/examples/wordpress-mysql.yaml
mysql.kubedb.com/wordpress-mysql created
```

Expand Down Expand Up @@ -206,7 +206,7 @@ wordpress-deployment-586f94487c-nm8p5 1/1 Running 0 2m26s

## Prepare for Backup

Now, let's prepare for the backup. Here, we are going to prepare the backend where we will store our backed up data and we are going to setup a [Slack Incoming Webhook](https://api.slack.com/messaging/webhooks) where we will send the notifications for backup.
Now, let's prepare for the backup. Here, we are going to prepare the backend where we will store our backed up data and we are going to setup a [Slack Incoming Webhook](https://api.slack.com/messaging/webhooks) where we will send the notifications for backup. Configure a Slack incoming webhook following the guides from [here](/docs/guides/hooks/slack-notification/index.md).

### Prepare Backend

Expand Down Expand Up @@ -248,60 +248,10 @@ spec:
Let's create the `Repository` we have shown above,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/batch-backup/repository.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/batch-backup/examples/repository.yaml
repository.stash.appscode.com/gcs-repo created
```

### Configure a Slack Incoming Webhook

Now, we are going to setup a Slack incoming webhook for a channel. You can skip this part if you already have a webhook configured.

Follow the following steps to configure an incoming webhook for a slack channel.

- At first, go to the https://api.slack.com and click on the `Start Building` button.

<figure align="center">
  <img alt="Step 1 " src="/docs/images/guides/hooks/batch-backup/step-1.png">
</figure>

- Give a name to your app and select your workspace. Then, click on the `Create App` button.

<figure align="center">
  <img alt="Step 2 " src="/docs/images/guides/hooks/batch-backup/step-2.png">
</figure>

- Then, click on the `Incoming Webhooks` card.

<figure align="center">
  <img alt="Step 3 " src="/docs/images/guides/hooks/batch-backup/step-3.png">
</figure>

- Now, activate the webhook by turning on the toggle as shown in the image below.

<figure align="center">
  <img alt="Step 4 " src="/docs/images/guides/hooks/batch-backup/step-4.png">
</figure>

- Scroll down a little bit and click on the `Add New Webhook to Workspace` button.

<figure align="center">
  <img alt="Step 5 " src="/docs/images/guides/hooks/batch-backup/step-5.png">
</figure>

- Then, select your desired channel where you want to send notification and click on the `Allow` button.

<figure align="center">
  <img alt="Step 6 " src="/docs/images/guides/hooks/batch-backup/step-6.png">
</figure>

- Finally, copy the webhook URL which will be used by Stash to send the notifications.

<figure align="center">
  <img alt="Step 7 " src="/docs/images/guides/hooks/batch-backup/step-7.png">
</figure>

Now, we are ready to send the backup notifications to our slack channel.

## Backup

Let's schedule a backup for our WordPress application stack. Here, we are going to configure a `preBackup` hook of a `BatchBackup` CR to send a notification when the backup starts and a `postBackup` hook to send another notification when the backup ends.
Expand Down Expand Up @@ -397,7 +347,7 @@ You can customize the `body` section of `httpPost` hook to change the visual rep
Let's create the above `BackupBatch` object,

```bash
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/examples/guides/hooks/batch-backup/wordpress-backup.yaml
$ kubectl apply -f https://github.com/stashed/docs/raw/{{< param "info.version" >}}/docs/guides/hooks/batch-backup/examples/wordpress-backup.yaml
backupbatch.stash.appscode.com/wordpress-backup created
```

Expand Down Expand Up @@ -445,7 +395,7 @@ Here, `SNAPSHOT-COUNT` 2 indicates that one snapshot for each target has been ta
Now, go to your slack channel. You should see that Stash has sent notification before and after the backup of WordPress application.

<figure align="center">
  <img alt="Backup Notification " src="/docs/images/guides/hooks/batch-backup/notification.png">
  <img alt="Backup Notification " src="images/notification.png">
</figure>

## Cleanup
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 3c1434d

Please sign in to comment.