# Notification Slack

{% embed url="<https://argocd-notifications.readthedocs.io/en/stable/>" %}

## Slack Configuration

<https://argocd-notifications.readthedocs.io/en/stable/services/slack/>

In Slack: Add apps ==> App Directory ==> Build ==> Create Custom App

![](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-acf2e4968fbac4fe27db5b43cb484afa84598ca9%2Fargocd-notifications-01.png?alt=media)

![app directory](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-efd57e7d6d894cda757a3473f05700a2c996254d%2Fargocd-notifications-02.png?alt=media)

![build](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-ea1a2a4248d36240e2dc4085ff70ef5f76f3319b%2Fargocd-notifications-03.png?alt=media)

![create custom app](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-7a50d3098c8509674046288b61749f312b7a92cf%2Fargocd-notifications-04.png?alt=media)

create an app from scratch

![create an app from scratch](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-2ad3acd3570f9c9612fe8802136d65a04a5d959e%2Fargocd-notifications-05.png?alt=media)

![create app](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-1ff879636ffb62d172b64d77bb3cb7f614d7e5c2%2Fargocd-notifications-06.png?alt=media)

oauth & permission

![](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-29a9ab64feb81729021e30cde950020c3d130d5c%2Fargocd-notifications-07%20\(1\)%20\(1\).png?alt=media)

bot token scope ==> add an oauth scope ==>

![add an oauth scope](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-573742269d3772d3d2c1ea9bad0a157c2b1cb416%2Fargocd-notifications-08.png?alt=media)

Add chat:write

Add chat:write:customize if you want to customize messages.

Install App to Workspace

![](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-a99ece6d02022c58ee97275523e4f2f022aaa66a%2Fargocd-notifications-10.png?alt=media)

allow

Once the token is generated, copy it.

![](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-2f08e2173e01be43306dec23565ecf18e6913862%2Fargocd-notifications-11.png?alt=media)

Add application to the argocd channel

In the channel: Add apps >> channel detail >> integration >> argocd-notifications

![Add apps](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-083720bbff64d802444d09ed82b75d612f1753c5%2Fargocd-notifications-12.png?alt=media)

![Add apps](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-c1a2e6d6df7e1ffdb42162d9a60101e9d2aa8ff7%2Fargocd-notifications-13.png?alt=media)

## Install in ArgoCD

```bash
mkdir -p core/argocd-notifications
cd core/argocd-notifications
```

{% tabs %}
{% tab title="kustomization.yaml" %}

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1

kind: Kustomization

resources:
  - https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/v1.1.1/manifests/install.yaml

patches:
  - path: https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/v1.1.1/catalog/install.yaml
    target:
      kind: ConfigMap
      name: argocd-notifications-cm
  - path: slack-secret.yml
    target:
      kind: Secret
      name: argocd-notifications-secret

patchesStrategicMerge:
  - slack-configmap.yml
```

{% endtab %}

{% tab title="slack-configmap.yml" %}

```yaml
apiVersion: v1
data:
  service.slack: |
    token: $slack-token
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
```

{% endtab %}

{% tab title="slack-secret.yml" %}

```yaml
apiVersion: v1
kind: Secret
metadata:
  name: argocd-notifications-secret
stringData:
  slack-token: YOUR-TOKEN
type: Opaque
```

{% endtab %}
{% endtabs %}

Add the app in ArgoCD.

{% code title="add-apps/argocd-notifications.yml" %}

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: argocd-notifications
spec:
  destination:
    name: ''
    namespace: argocd
    server: 'https://kubernetes.default.svc'
  source:
    path: apps/core/argocd-notifications
    repoURL: 'git@github.com:xxxxx/xxxx.git'
    targetRevision: HEAD
  project: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
```

{% endcode %}

```bash
kubectl apply -f add-apps/argocd-notifications.yml
```

## Subscribe Trigger

### Application

Add annotations to the Application.

```bash
kubectl edit application AAA -n argocd
```

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  # Add only this section
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my_channel
```

This will enable receiving notifications.

### Project

To send notifications for an entire Project, add annotations to the project configuration.

```bash
kubectl get AppProjects -n argocd
```

![](https://4167976146-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbehXUTixKOk2w9STxcsF%2Fuploads%2Fgit-blob-279f2943fbf5bce1b5f657b86e098dbba5528ea8%2F2021-06-03-06-03-20.png?alt=media)

```bash
kubectl edit appProject default -n argocd
```

```yaml
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  # Add only this section
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my-channel1;my-channel2
```

### Via Command Line

{% code title="trigger.yaml" %}

```yaml
metadata:
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: argocd
```

{% endcode %}

```bash
kubectl patch AppProjects default -n argocd --patch "$(cat trigger.yaml)" --type=merge
```
