Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
  • Loading branch information
crenshaw-dev committed Oct 5, 2023
1 parent 4be2a27 commit 8149751
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 303 deletions.
48 changes: 24 additions & 24 deletions docs/operator-manual/notifications/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 8149751

Please sign in to comment.