forked from argoproj/argo-rollouts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support notifications on rollout events using notifications-eng…
…ine (argoproj#1175) feat: support notifications on rollout events using notifications-engine (argoproj#1175) Signed-off-by: Alexander Matyushentsev <[email protected]> Signed-off-by: Andrii Perenesenko <[email protected]>
- Loading branch information
1 parent
a130aa0
commit 39ab764
Showing
22 changed files
with
924 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Notifications | ||
|
||
!!! important | ||
Available since v1.1 | ||
|
||
Argo Rollouts provides notifications powered by the [Notifications Engine](https://github.com/argoproj/notifications-engine). | ||
Controller administrators can leverage flexible systems of triggers and templates to configure notifications requested | ||
by the end users. The end-users can subscribe to the configured triggers by adding an annotation to the Rollout objects. | ||
|
||
## Configuration | ||
|
||
The trigger defines the condition when the notification should be sent as well as the notification content template. | ||
Default Argo Rollouts comes with a list of built-in triggers that cover the most important events of Argo Rollout live-cycle. | ||
Both triggers and templates are configured in the `argo-rollouts-notification-configmap` ConfigMap. In order to get | ||
started quickly, you can use pre-configured notification templates defined in [notifications-install.yaml](../../manifests/notifications-install.yaml). | ||
|
||
If you are leveraging Kustomize it is recommended to include [notifications-install.yaml](../../manifests/notifications-install.yaml) as a remote | ||
resource into your `kustomization.yaml` file: | ||
|
||
```yaml | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml | ||
- https://github.com/argoproj/argo-rollouts/releases/latest/download/notifications-install.yaml | ||
``` | ||
After including the `argo-rollouts-notification-configmap` ConfigMap the administrator needs to configure integration | ||
with the required notifications service such as Slack or MS Teams. An example below demonstrates Slack integration: | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: argo-rollouts-notification-configmap | ||
data: | ||
service.slack: | | ||
token: $slack-token | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: argo-rollouts-notification-secret | ||
stringData: | ||
slack-token: <my-slack-token> | ||
``` | ||
|
||
Learn more about supported services and configuration settings in services [documentation](../generated/notification-services/overview.md). | ||
|
||
## Subscriptions | ||
|
||
The end-users can start leveraging notifications using `notifications.argoproj.io/subscribe.<trigger>.<service>: <recipient>` annotation. | ||
For example, the following annotation subscribes two Slack channels to notifications about canary rollout step completion: | ||
|
||
```yaml | ||
--- | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Rollout | ||
metadata: | ||
name: rollout-canary | ||
annotations: | ||
notifications.argoproj.io/subscribe.on-rollout-step-completed.slack: my-channel1;my-channel2 | ||
``` | ||
|
||
Annotation key consists of following parts: | ||
|
||
* `on-rollout-step-completed` - trigger name | ||
* `slack` - notification service name | ||
* `my-channel1;my-channel2` - a semicolon separated list of recipients | ||
|
||
## Customization | ||
|
||
The Rollout administrator can customize the notifications by configuring notification templates and custom triggers | ||
in `argo-rollouts-notification-configmap` ConfigMap. | ||
|
||
### Templates | ||
|
||
The notification template is a stateless function that generates the notification content. The template is leveraging | ||
[html/template](https://golang.org/pkg/html/template/) golang package. It is meant to be reusable and can be referenced by multiple triggers. | ||
|
||
An example below demonstrates a sample template: | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: argo-rollouts-notification-configmap | ||
data: | ||
template.my-purple-template: | | ||
message: | | ||
Rollout {{.rollout.metadata.name}} has purple image | ||
slack: | ||
attachments: | | ||
[{ | ||
"title": "{{ .rollout.metadata.name}}", | ||
"color": "#800080" | ||
}] | ||
``` | ||
|
||
Each template has access to the following fields: | ||
|
||
- `rollout` holds the rollout object. | ||
- `recipient` holds the recipient name. | ||
|
||
The `message` field of the template definition allows creating a basic notification for any notification service. You can | ||
leverage notification service-specific fields to create complex notifications. For example using service-specific you can | ||
add blocks and attachments for Slack, subject for Email or URL path, and body for Webhook. See corresponding service | ||
[documentation](../generated/notification-services/overview.md) for more information. | ||
|
||
### Custom Triggers | ||
|
||
In addition to custom notification template administrator and configure custom triggers. Custom trigger defines the | ||
condition when the notification should be sent. The definition includes name, condition and notification templates reference. | ||
The condition is a predicate expression that returns true if the notification 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 `argo-rollouts-notification-configmap` ConfigMap. For example the following trigger sends a notification | ||
when rollout pod spec uses `argoproj/rollouts-demo:purple` image: | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: argocd-notifications-cm | ||
data: | ||
trigger.on-purple: | | ||
- send: [my-purple-template] | ||
when: rollout.spec.template.spec.containers[0].image == 'argoproj/rollouts-demo:purple' | ||
``` | ||
|
||
Each condition might use several templates. Typically each template is responsible for generating a service-specific notification part. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: argo-rollouts-notification-configmap | ||
data: | ||
service.slack: | | ||
token: $slack-token | ||
## Custom Trigger | ||
trigger.on-purple: | | ||
- send: [my-purple-template] | ||
when: rollout.spec.template.spec.containers[0].image == 'argoproj/rollouts-demo:purple' | ||
template.my-purple-template: | | ||
message: | | ||
Rollout {{.rollout.metadata.name}} has purple image | ||
slack: | ||
attachments: | | ||
[{ | ||
"title": "{{ .rollout.metadata.name}}", | ||
"color": "#800080" | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- ../../manifests/notifications | ||
|
||
patchesStrategicMerge: | ||
- configmap.yaml |
Oops, something went wrong.