Skip to content

Commit

Permalink
Merge pull request #239 from MagnusRef/add-teams-docs-and-more
Browse files Browse the repository at this point in the history
Add MS Teams notification docs
  • Loading branch information
gianlucam76 authored Mar 4, 2024
2 parents b70700c + 4de8e31 commit 69e2b0d
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 30 deletions.
22 changes: 22 additions & 0 deletions docs/assets/teams_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 99 additions & 24 deletions docs/observability/example_addon_notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ tags:
- multi-tenancy
- Sveltos
- Slack
- Teams
authors:
- Gianluca Mardente
- Magnus R. Christoffersen
---

## Example: Kubernetes Addons and Notifications
In these examples, we will configure Sveltos to send a notification whenever all the add-ons and applications listed in the `ClusterProfile` are deployed to the clusters matching the cluster label selector set to **env=fv**.

In this example, we will configure Sveltos to perform the below actions whenever all the add-ons and applications listed in the `ClusterProfile` are deployed to the clusters matching the cluster label selector set to **env=fv:**.
Once the defined conditions are met, a notification will be generated and send out.

1. Send a Slack message
2. Send a Webex message
3. Send a Slack message
4. Generate a Kubernetes event
## Slack

```yaml
apiVersion: lib.projectsveltos.io/v1alpha1
Expand All @@ -33,53 +32,132 @@ spec:
- name: addons
type: Addons
notifications:
- name: event
type: KubernetesEvent
- name: slack
type: Slack
notificationRef:
apiVersion: v1
kind: Secret
name: slack
namespace: default
```
The above `slack` secret contains the Slack channel and the token.

```bash
$ kubectl create secret generic slack \
--from-literal=SLACK_CHANNEL_ID=<your channel id> \
--from-literal=SLACK_TOKEN=<your token> \
--type=addons.projectsveltos.io/cluster-profile
```

## Webex

```yaml
apiVersion: lib.projectsveltos.io/v1alpha1
kind: ClusterHealthCheck
metadata:
name: production
spec:
clusterSelector: env=fv
livenessChecks:
- name: addons
type: Addons
notifications:
- name: webex
type: Webex
notificationRef:
apiVersion: v1
kind: Secret
name: webex
namespace: default
- name: discord
type: Discord
```

The above `Webex` secret contains the Webex room id and the token.

```bash
$ kubectl create secret generic webex \
--from-literal=WEBEX_ROOM_ID=<your channel id> \
--from-literal=WEBEX_TOKEN=<your token> \
--type=addons.projectsveltos.io/cluster-profile
```

## Teams

```yaml
apiVersion: lib.projectsveltos.io/v1alpha1
kind: ClusterHealthCheck
metadata:
name: production
spec:
clusterSelector: env=fv
livenessChecks:
- name: addons
type: Addons
notifications:
- name: teams
type: Teams
notificationRef:
apiVersion: v1
kind: Secret
name: discord
namespace: default
name: teams
namespace: default
```

- The `slack` secret contains the Slack channel and the token.
The above `Teams` secret contains the Teams webhook URL.

```bash
$ kubectl create secret generic slack --from-literal=SLACK_TOKEN=<your token> --from-literal=SLACK_CHANNEL_ID=<your channel id> --type=addons.projectsveltos.io/cluster-profile
$ kubectl create secret generic teams \
--from-literal=TEAMS_WEBHOOK_URL="<your URL>" \
--type=addons.projectsveltos.io/cluster-profile
```

- The `Webex` secret contains the Webex room id and the token.
## Discord

```yaml
apiVersion: lib.projectsveltos.io/v1alpha1
kind: ClusterHealthCheck
metadata:
name: production
spec:
clusterSelector: env=fv
livenessChecks:
- name: addons
type: Addons
notifications:
- name: discord
type: Discord
notificationRef:
apiVersion: v1
kind: Secret
name: discord
namespace: default
```

The above `discord` secret contains the Discord channel id and the token.
```bash
$ kubectl create secret generic slack --from-literal=WEBEX_TOKEN=<your token> --from-literal=WEBEX_ROOM_ID=<your channel id> --type=addons.projectsveltos.io/cluster-profile
$ kubectl create secret generic discord \
--from-literal=DISCORD_CHANNEL_ID=<your channel id> \
--from-literal=DISCORD_TOKEN=<your token> \
--type=addons.projectsveltos.io/cluster-profile
```

- The `discord` secret contains the Discord channel id and the token.
## Kubernetes event

```bash
$ kubectl create secret generic slack --from-literal=DISCORD_TOKEN=<your token> --from-literal=DISCORD_CHANNEL_ID=<your channel id> --type=addons.projectsveltos.io/cluster-profile
```
```yaml
apiVersion: lib.projectsveltos.io/v1alpha1
kind: ClusterHealthCheck
metadata:
name: production
spec:
clusterSelector: env=fv
livenessChecks:
- name: addons
type: Addons
```

To list the events generated by Sveltos, use the below command.

```bash
$ kubectl get events -n default --field-selector reason=ClusterHealthCheck
$ kubectl get events -n default --field-selector reason=ClusterHealthCheck
LAST SEEN TYPE REASON OBJECT MESSAGE
31s Normal ClusterHealthCheck clusterhealthcheck/hc cluster Capi:default/sveltos-management-workload...
16s Warning ClusterHealthCheck clusterhealthcheck/hc cluster Capi:default/sveltos-management-workload...
Expand All @@ -92,6 +170,3 @@ The Event message contains the below information on the cluster:
2. Cluster `namespace`
3. Cluster `name`

Once the defined conditions are met, a notification will be generated and visible in the space mentioned above. The below notification is a Webex notification.

![Sveltos Slack notification](../assets/slack_notitifcation.png)
11 changes: 6 additions & 5 deletions docs/observability/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ The notifications fields is a list of all __notifications__ to be sent when the

The supported types are:

1. <img src="../../assets/kubernetes_logo.png" alt="Kubernetes" width="25" /> Kubernetes events (__reason=ClusterHealthCheck__);
2. <img src="../../assets/slack_logo.png" alt="Slack" width="25" /> Slack message;
3. <img src="../../assets/webex_logo.png" alt="Webex" width="25" /> Webex message;
4. <img src="../../assets/discord_logo.png" alt="Discord" width="25" /> Discord message
1. <img src="../../assets/slack_logo.png" alt="Slack" width="25" /> [Slack](./example_addon_notification.md#slack)
2. <img src="../../assets/webex_logo.png" alt="Webex" width="25" /> [Webex](./example_addon_notification.md#webex)
4. <img src="../../assets/teams_logo.svg" alt="Teams" width="25" /> [Teams](./example_addon_notification.md#teams)
3. <img src="../../assets/discord_logo.png" alt="Discord" width="25" /> [Discord](./example_addon_notification.md#discord)
5. <img src="../../assets/kubernetes_logo.png" alt="Kubernetes" width="25" /> [Kubernetes events](./example_addon_notification.md#kubernetes-event) (__reason=ClusterHealthCheck__)


### HealthCheck CRD
Expand Down Expand Up @@ -212,4 +213,4 @@ spec:
+(projectsveltos.io/serviceaccount-namespace): '{{serviceAccountNamespace}}'
name: add-labels
validationFailureAction: enforce
```
```
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ nav:
- Example Cross-cluster Configuration: 'events/example_cross_cluster_configuration.md'
- Cluster Observability:
- Notifications: 'observability/notifications.md'
- Example Slack, Webex, Discord Notification and Addons: 'observability/example_addon_notification.md'
- Examples for Slack, Teams, Webex, Discord Notifications and k8s events: 'observability/example_addon_notification.md'
- Example Slack Notification for Pods in crashloopbackoff: 'observability/example_crashloopbackoff_notification.md'
- Example Deployment Health Notification: 'observability/example_deployment_health_notification.md'
- Example Detect Degrade Certificates Notification: 'observability/example_degrade_certificate_notification.md'
Expand Down

0 comments on commit 69e2b0d

Please sign in to comment.