Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added documentation to enable Slack notification post deployment task (#787) #788

Merged
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