Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions argocd-slack-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Argo CD Slack Notifications Plugin

## Overview

This plugin enables Slack notifications for Argo CD application events. It configures Argo CD to send notifications to Slack channels when applications are synced, deployed, or experience health issues.

## Features

- Real-time Slack notifications for Argo CD events
- Customizable notification templates with rich formatting
- Support for multiple event types:
- Application created/deleted
- Sync started/succeeded/failed
- Application health degraded
- Deployment completed

## Required Vault Configuration

The gitops catalog implementation will add these 2 secrets to your Vault,
and bind them to your app using external secrets. For local development you
can add these secrets manually.

```bash
vault kv put secret/argocd-slack-plugin \
SLACK_TOKEN="xoxb-your-slack-token-here" \
SLACK_CHANNEL="#deployments"
```

Note: While the channel name isn't sensitive, it's stored in Vault as a user input value.

## Slack Setup

1. Create an Incoming Webhook in Slack
2. Use the webhook URL as the SLACK_TOKEN value

## Configuration

### Default Channel

The default Slack channel is configured via the `SLACK_CHANNEL` value in Vault. All notifications will be sent to this channel by default.

### Custom Subscriptions

You can configure per-application notifications by adding annotations:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: "#deployments"
notifications.argoproj.io/subscribe.on-sync-failed.slack: "#alerts"
```

## Notification Events

The following events trigger notifications:

- `on-created`: Application created
- `on-deleted`: Application deleted
- `on-deployed`: Application successfully deployed
- `on-health-degraded`: Application health degraded
- `on-sync-failed`: Sync operation failed
- `on-sync-running`: Sync operation started
- `on-sync-succeeded`: Sync operation succeeded

## Customization

### Modifying Templates

Edit the `argocd-notifications-cm` ConfigMap to customize notification templates and add new ones.

### Adding New Triggers

Add new triggers in the ConfigMap following the pattern:

```yaml
trigger.on-your-event: |
- when: your.condition
send: [your-template]
```

## Troubleshooting

Check the notification controller logs:

```bash
kubectl logs -n argocd deployment/argocd-notifications-controller
```

Verify the secret is created:

```bash
kubectl get secret -n argocd argocd-notifications-secret
```

Test notifications:

```bash
kubectl exec -n argocd deployment/argocd-notifications-controller -- \
/app/argocd-notifications template notify app-sync-succeeded <app-name> --recipient slack:<channel>
```
25 changes: 25 additions & 0 deletions argocd-slack-plugin/argocd-slack-plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: <CLUSTER_NAME>-argocd-slack-plugin-components
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: '100'
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: <GITOPS_REPO_URL>
path: <REGISTRY_PATH>/components/argocd-slack-plugin
targetRevision: HEAD
destination:
name: in-cluster
namespace: argocd
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false # argocd namespace should already exist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: <CLUSTER_NAME>-argocd-slack-plugin
namespace: argocd
annotations:
kubefirst.konstruct.io/application-name: argocd-slack-plugin
kubefirst.konstruct.io/source: catalog-templates
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: argocd
name: <CLUSTER_DESTINATION>
project: <PROJECT>
source:
repoURL: <GITOPS_REPO_URL>
path: <REGISTRY_PATH>/components/argocd-slack-plugin
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false # argocd namespace should already exist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: <CLUSTER_NAME>-argocd-slack-plugin-secret
namespace: argocd
spec:
target:
name: argocd-notifications-secret
secretStoreRef:
kind: ClusterSecretStore
name: vault-kv-secret
refreshInterval: 10s
data:
- secretKey: slack-token
remoteRef:
key: /argocd-slack-plugin
property: SLACK_TOKEN
- secretKey: slack-channel
remoteRef:
key: /argocd-slack-plugin
property: SLACK_CHANNEL
Loading