diff --git a/docs/content/en/docs/tasks/implement-slack-notification/_index.md b/docs/content/en/docs/tasks/implement-slack-notification/_index.md new file mode 100644 index 0000000000..cb0f07d892 --- /dev/null +++ b/docs/content/en/docs/tasks/implement-slack-notification/_index.md @@ -0,0 +1,39 @@ +--- +title: Implement Slack Notification +description: Learn how to implement Slack notification as a post deployment task. +icon: concepts +layout: quickstart +weight: 24 +hidechildren: true # this flag hides all sub-pages in the sidebar-multicard.html +--- + +# Overview +This section describes how to **prepare and enable** post-deployment tasks to send notifications to slack using webhooks. + +## Create Slack Webhook + +At first, create an incoming slack webhook. Necessary information is available in the [slack api page](https://api.slack.com/messaging/webhooks). +Once you create the webhook, you will get a URL similar to below example. + +`https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX` + +`T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX` is the secret part of the webhook which we would need in the next step. + +## Create slack-secret + +Create a `slack-secret.yaml` definition using the following command. +This will create a kubernetes secret named `slack-secret.yaml` in the `examples/sample-app/base` directory. Before running +this command change your current directory into `examples/sample-app`. + +```bash +kubectl create secret generic slack-secret --from-literal=SECURE_DATA='{"slack_hook":,"text":"Deployed PodTatoHead Application"}' -n podtato-kubectl -oyaml --dry-run=client > base/slack-secret.yaml +``` +## Enable post deployment task + +To enable Slack notification add `post-deployment-notification` in as a postDeploymentTasks in the +[examples/sample-app/base/app.yaml](https://github.com/keptn/lifecycle-toolkit/blob/main/examples/sample-app/base/app.yaml) file as shown below. + +```yaml + postDeploymentTasks: + - post-deployment-notification +``` \ No newline at end of file diff --git a/examples/sample-app/README.md b/examples/sample-app/README.md index 67f6d83233..eccd9c0ab6 100644 --- a/examples/sample-app/README.md +++ b/examples/sample-app/README.md @@ -4,12 +4,35 @@ This example should demonstrate the capabilities of the lifecycle toolkit as ill ![img.png](assets/big-picture.png) -## Prepare Secret for Slack Notification -As a first step, create an incoming webhook according to the instructions -https://api.slack.com/messaging/webhooks +## PostDeployment Slack Notification +This section describes how to **prepare and enable** post-deployment tasks to send notifications to slack using webhooks. -Afterwards create a secret with the created webhook -> kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":,"text":"Deployed PodTatoHead Application"}' -n podtato-kubectl -oyaml --dry-run=client > base/slack-secret.yaml +**Create Slack Webhook** + +In the first step, create an incoming slack webhook. Necessary information is available in the [slack api page](https://api.slack.com/messaging/webhooks). +Once you create the webhook, you will get a URL similar to below example. + +`https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX` + +`T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX` is the secret part of the webhook which we would need in the next step. + +**Create slack-secret** + +Create a `slack-secret.yaml` definition using the following command. +This will create a kubernetes secret named `slack-secret.yaml` in the [base](./base) directory. + +```bash +kubectl create secret generic slack-secret --from-literal=SECURE_DATA='{"slack_hook":,"text":"Deployed PodTatoHead Application"}' -n podtato-kubectl -oyaml --dry-run=client > base/slack-secret.yaml +``` +**Enable post deployment task** + +To enable Slack notification add `post-deployment-notification` in as a postDeploymentTasks in the +[app.yaml](base/app.yaml) file as shown below. + +```yaml + postDeploymentTasks: + - post-deployment-notification +``` ## Deploy the Observability Part and Keptn-lifecycle-toolkit > make install