Skip to content

Commit

Permalink
docs: added documentation to enable Slack notification post deploymen…
Browse files Browse the repository at this point in the history
…t task (#787) (#788)

Fixes #787
  • Loading branch information
sudiptob2 committed Feb 13, 2023
1 parent 68f188e commit 28a7319
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
39 changes: 39 additions & 0 deletions docs/content/en/docs/tasks/implement-slack-notification/_index.md
Original file line number Diff line number Diff line change
@@ -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":<YOUR_HOOK_SECRET>,"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
```
33 changes: 28 additions & 5 deletions examples/sample-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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":<YOUR_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":<YOUR_HOOK_SECRET>,"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
Expand Down

0 comments on commit 28a7319

Please sign in to comment.