Skip to content

Commit

Permalink
docs: improve notifications docs (argoproj#15816)
Browse files Browse the repository at this point in the history
* docs: improve notifications docs

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* use a version compatible with Python 3.7, which is what RTD runs

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* more fixes

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
  • Loading branch information
crenshaw-dev authored and lukaszgyg committed Jan 12, 2024
1 parent 5da6eb3 commit 560cdd1
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 86 deletions.
50 changes: 25 additions & 25 deletions docs/operator-manual/notifications/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Overview
# Notifications Overview

Argo CD Notifications continuously monitors Argo CD applications and provides a flexible way to notify
users about important changes in the application state. Using a flexible mechanism of
Expand All @@ -10,38 +10,38 @@ So you can just use them instead of reinventing new ones.

* Install Triggers and Templates from the catalog

```
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/notifications_catalog/install.yaml
```
```bash
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/notifications_catalog/install.yaml
```

* Add Email username and password token to `argocd-notifications-secret` secret

```bash
EMAIL_USER=<your-username>
PASSWORD=<your-password>

kubectl apply -n argocd -f - << EOF
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
email-username: $EMAIL_USER
email-password: $PASSWORD
type: Opaque
EOF
```
```bash
EMAIL_USER=<your-username>
PASSWORD=<your-password>
kubectl apply -n argocd -f - << EOF
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
email-username: $EMAIL_USER
email-password: $PASSWORD
type: Opaque
EOF
```
* Register Email notification service
```bash
kubectl patch cm argocd-notifications-cm -n argocd --type merge -p '{"data": {"service.email.gmail": "{ username: $email-username, password: $email-password, host: smtp.gmail.com, port: 465, from: $email-username }" }}'
```
```bash
kubectl patch cm argocd-notifications-cm -n argocd --type merge -p '{"data": {"service.email.gmail": "{ username: $email-username, password: $email-password, host: smtp.gmail.com, port: 465, from: $email-username }" }}'
```
* Subscribe to notifications by adding the `notifications.argoproj.io/subscribe.on-sync-succeeded.slack` annotation to the Argo CD application or project:
```bash
kubectl patch app <my-app> -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-succeeded.slack":"<my-channel>"}}}' --type merge
```
```bash
kubectl patch app <my-app> -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-succeeded.slack":"<my-channel>"}}}' --type merge
```
Try syncing an application to get notified when the sync is completed.
10 changes: 5 additions & 5 deletions docs/operator-manual/notifications/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The Argo CD Notification controller serves Prometheus metrics on port 9001.

!!! note
Metrics port might be changed using the `--metrics-port` flag in `argocd-notifications-controller` deployment.
The metrics port can be changed using the `--metrics-port` flag in `argocd-notifications-controller` deployment.

## Metrics
The following metrics are available:
Expand All @@ -15,16 +15,16 @@ The following metrics are available:

* `template` - notification template name
* `notifier` - notification service name
* `succeeded` - flag that indicates if notification was successfully sent or failed.
* `succeeded` - flag that indicates if notification was successfully sent or failed

### `argocd_notifications_trigger_eval_total`

Number of trigger evaluations.
Labels:

* `name` - trigger name
* `triggered` - flag that indicates if trigger condition returned true of false.
* `triggered` - flag that indicates if trigger condition returned true of false

# Examples:
## Examples

* Grafana Dashboard: [grafana-dashboard.json](grafana-dashboard.json)
* Grafana Dashboard: [grafana-dashboard.json](grafana-dashboard.json)
8 changes: 4 additions & 4 deletions docs/operator-manual/notifications/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ metadata:
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my-channel1;my-channel2
```
Annotation key consists of following parts:
The annotation key consists of following parts:
* `on-sync-succeeded` - trigger name
* `slack` - notification service name
* `my-channel1;my-channel2` - a semicolon separated list of recipients

You can create subscriptions for all applications of the Argo CD project by adding the same annotation to AppProject CRD:
You can create subscriptions for all applications of an Argo CD project by adding the same annotation to the AppProject resource:

```yaml
apiVersion: argoproj.io/v1alpha1
Expand All @@ -27,7 +27,7 @@ metadata:

## Default Subscriptions

The subscriptions might be configured globally in the `argocd-notifications-cm` ConfigMap using `subscriptions` field. The default subscriptions
The subscriptions might be configured globally in the `argocd-notifications-cm` ConfigMap using the `subscriptions` field. The default subscriptions
are applied to all applications. The trigger and applications might be configured using the
`triggers` and `selector` fields:

Expand All @@ -53,7 +53,7 @@ data:
- on-sync-status-unknown
```

If you want to use webhook in subscriptions, you need to store the custom name to recipients.
If you want to use webhook in subscriptions, you need to store the custom webhook name in the subscription's `recipients` field.

```yaml
apiVersion: v1
Expand Down
46 changes: 23 additions & 23 deletions docs/operator-manual/notifications/templates.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The notification template is used to generate the notification content and configured in `argocd-notifications-cm` ConfigMap. The template is leveraging
[html/template](https://golang.org/pkg/html/template/) golang package and allow to customize notification message.
The notification template is used to generate the notification content and is configured in the `argocd-notifications-cm` ConfigMap. The template is leveraging
the [html/template](https://golang.org/pkg/html/template/) golang package and allows customization of the notification message.
Templates are meant to be reusable and can be referenced by multiple triggers.

The following template is used to notify the user about application sync status.
Expand All @@ -19,9 +19,9 @@ data:
Each template has access to the following fields:
- `app` holds the application object.
- `context` is user defined string map and might include any string keys and values.
- `serviceType` holds the notification service type name. The field can be used to conditionally
render service specific fields.
- `context` is a user-defined string map and might include any string keys and values.
- `serviceType` holds the notification service type name (such as "slack" or "email). The field can be used to conditionally
render service-specific fields.
- `recipient` holds the recipient name.

## Defining user-defined `context`
Expand Down Expand Up @@ -51,30 +51,30 @@ See corresponding service [documentation](services/overview.md) for more informa

## Change the timezone

You can change the timezone to show it as follows.
You can change the timezone to show in notifications as follows.

1. Call time functions.

```
{{ (call .time.Parse .app.status.operationState.startedAt).Local.Format "2006-01-02T15:04:05Z07:00" }}
```
```
{{ (call .time.Parse .app.status.operationState.startedAt).Local.Format "2006-01-02T15:04:05Z07:00" }}
```

2. Set environment to container.
2. Set the `TZ` environment variable on the argocd-notifications-controller container.

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: argocd-notifications-controller
spec:
(snip)
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: argocd-notifications-controller
spec:
containers:
- name: argocd-notifications-controller
env:
- name: TZ
value: Asia/Tokyo
```
template:
spec:
containers:
- name: argocd-notifications-controller
env:
- name: TZ
value: Asia/Tokyo
```

## Functions

Expand Down
8 changes: 4 additions & 4 deletions docs/operator-manual/notifications/triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ and notification templates reference. The condition is a predicate expression th
should be sent. The trigger condition evaluation is powered by [antonmedv/expr](https://github.com/antonmedv/expr).
The condition language syntax is described at [Language-Definition.md](https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md).

The trigger is configured in `argocd-notifications-cm` ConfigMap. For example the following trigger sends a notification
The trigger is configured in the `argocd-notifications-cm` ConfigMap. For example the following trigger sends a notification
when application sync status changes to `Unknown` using the `app-sync-status` template:

```yaml
Expand All @@ -17,9 +17,9 @@ data:
send: [app-sync-status, github-commit-status] # template names
```
Each condition might use several templates. Typically each template is responsible for generating a service-specific notification part.
In the example above `app-sync-status` template "knows" how to create email and slack notification and `github-commit-status` knows how to
generate payload for Github webhook.
Each condition might use several templates. Typically, each template is responsible for generating a service-specific notification part.
In the example above, the `app-sync-status` template "knows" how to create email and Slack notification, and `github-commit-status` knows how to
generate the payload for GitHub webhook.

## Conditions Bundles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ You need to check your argocd-notifications controller version. For instance, th

## Failed to notify recipient

### notification service 'xxxx' is not supported"
### notification service 'xxxx' is not supported

You have not defined `xxxx` in `argocd-notifications-cm` or to fail to parse settings.
45 changes: 24 additions & 21 deletions docs/operator-manual/notifications/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
## Troubleshooting

The `argocd admin notifications` is a CLI command group that helps to configure the controller
settings and troubleshoot issues.
`argocd admin notifications` is a CLI command group that helps to configure the controller
settings and troubleshoot issues. Full command details are available in the [command reference](../../user-guide/commands/argocd_admin_notifications.md).

## Global flags
Following global flags are available for all sub-commands:
The following global flags are available for all sub-commands:

* `config-map` - path to the file containing `argocd-notifications-cm` ConfigMap. If not specified
* `--config-map` - path to the file containing `argocd-notifications-cm` ConfigMap. If not specified
then the command loads `argocd-notification-cm` ConfigMap using the local Kubernetes config file.
* `secret` - path to the file containing `argocd-notifications-secret` ConfigMap. If not
* `--secret` - path to the file containing `argocd-notifications-secret` ConfigMap. If not
specified then the command loads `argocd-notification-secret` Secret using the local Kubernetes config file.
Additionally, you can specify `:empty` value to use empty secret with no notification service settings.
Additionally, you can specify `:empty` to use empty secret with no notification service settings.

**Examples:**

* Get list of triggers configured in the local config map:
* Get a list of triggers configured in the local config map:

```bash
argocd admin notifications trigger get \
--config-map ./argocd admin notifications-cm.yaml --secret :empty
```
```bash
argocd admin notifications trigger get \
--config-map ./argocd admin notifications-cm.yaml --secret :empty
```

* Trigger notification using in-cluster config map and secret:

```bash
argocd admin notifications template notify \
app-sync-succeeded guestbook --recipient slack:argocd admin notifications
```
```bash
argocd admin notifications template notify \
app-sync-succeeded guestbook --recipient slack:argocd admin notifications
```

## Kustomize

Expand All @@ -44,17 +42,17 @@ kustomize build ./argocd-notifications | \

### On your laptop

You can download the `argocd` CLI from the github [release](https://github.com/argoproj/argo-cd/releases)
You can download the `argocd` CLI from the GitHub [release](https://github.com/argoproj/argo-cd/releases)
attachments.

The binary is available in `argoproj/argo-cd` image. Use the `docker run` and volume mount
The binary is available in the `quay.io/argoproj/argocd` image. Use the `docker run` and volume mount
to execute binary on any platform.

**Example:**

```bash
docker run --rm -it -w /src -v $(pwd):/src \
argoproj/argo-cd:<version> \
quay.io/argoproj/argocd:<version> \
/app/argocd admin notifications trigger get \
--config-map ./argocd-notifications-cm.yaml --secret :empty
```
Expand All @@ -72,7 +70,12 @@ kubectl exec -it argocd-notifications-controller-<pod-hash> \

## Commands

{!docs/operator-manual/notifications/troubleshooting-commands.md!}
The following commands may help debug issues with notifications:

* [`argocd admin notifications template get`](../../user-guide/commands/argocd_admin_notifications_template_get.md)
* [`argocd admin notifications template notify`](../../user-guide/commands/argocd_admin_notifications_template_notify.md)
* [`argocd admin notifications trigger get`](../../user-guide/commands/argocd_admin_notifications_trigger_get.md)
* [`argocd admin notifications trigger run`](../../user-guide/commands/argocd_admin_notifications_trigger_run.md)

## Errors

Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ mkdocs-material==7.1.8
markdown_include==0.6.0
pygments==2.15.0
jinja2==3.0.3
markdown==3.3.7
markdown==3.3.7
pymdown-extensions==10.2.1
5 changes: 4 additions & 1 deletion hack/gen-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func generateNotificationsDocs() {
log.Fatal(err)
}
if files != nil {
if e := updateMkDocsNav("Operator Manual", "Notification", "Notification Services", files); e != nil {
if e := updateMkDocsNav("Operator Manual", "Notifications", "Notification Services", files); e != nil {
log.Fatal(e)
}
}
Expand All @@ -49,6 +49,9 @@ func updateMkDocsNav(parent string, child string, subchild string, files []strin
}
rootnavitemmap := rootitem.(map[interface{}]interface{})
childnav, _ := findNavItem(rootnavitemmap[parent].([]interface{}), child)
if childnav == nil {
return fmt.Errorf("Can't find '%s' chile item under '%s' parent item in mkdoc.yml", child, parent)
}

childnavmap := childnav.(map[interface{}]interface{})
childnavitems := childnavmap[child].([]interface{})
Expand Down
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ markdown_extensions:
- admonition
- toc:
permalink: true
- pymdownx.superfences
nav:
- Overview: index.md
- understand_the_basics.md
Expand Down Expand Up @@ -59,7 +60,7 @@ nav:
- operator-manual/web_based_terminal.md
- operator-manual/config-management-plugins.md
- operator-manual/deep_links.md
- Notification:
- Notifications:
- Overview: operator-manual/notifications/index.md
- operator-manual/notifications/triggers.md
- operator-manual/notifications/templates.md
Expand Down

0 comments on commit 560cdd1

Please sign in to comment.