Last active
May 13, 2024 21:16
-
-
Save lemin-ou/1ebf2a1ebcad9a438041f931f1d63e76 to your computer and use it in GitHub Desktop.
Configure notification for ArgoCD
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
apiVersion: v1 | |
data: | |
context: | | |
# this can be changed anytime, developers must portforward argocd server service | |
# using the following command | |
# kubectl port-forward -n argocd svc/argocd-server 2323:80 | |
argocdUrl: http://localhost:2323 | |
environment: Developement | |
environmentShortName: dev | |
service.slack: | | |
token: $slack-token | |
channels: ["devsecops"] | |
subscriptions: | | |
# subscription to all notifications | |
- recipients: | |
- slack:devsecops | |
triggers: | |
- on-created | |
- on-deleted | |
- on-deployed | |
- on-health-degraded | |
- on-sync-failed | |
- on-sync-running | |
- on-sync-succeeded | |
- on-sync-status-unknown | |
defaultTriggers: | | |
- on-deployed | |
- on-health-degraded | |
- on-sync-failed | |
- on-sync-succeeded | |
- on-sync-status-unknown | |
template.app-created: | | |
email: | |
subject: Application {{.app.metadata.name}} has been created. | |
message: Application {{.app.metadata.name}} has been created. | |
teams: | |
title: Application {{.app.metadata.name}} has been created. | |
template.app-deleted: | | |
email: | |
subject: Application {{.app.metadata.name}} has been deleted. | |
message: Application {{.app.metadata.name}} has been deleted. | |
teams: | |
title: Application {{.app.metadata.name}} has been deleted. | |
template.app-deployed: | | |
email: | |
subject: New version of an application {{.app.metadata.name}} is up and running. | |
message: | | |
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} is now running new version of deployments manifests. | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#18be52", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Revision", | |
"value": "{{.app.status.sync.revision}}", | |
"short": true | |
}, | |
{ | |
"title": "Developer", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Author}}", | |
"short": true | |
}, | |
{ | |
"title": "Revision Message", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Message}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
}, | |
{ | |
"name": "Revision", | |
"value": "{{.app.status.sync.revision}}" | |
}, | |
{ | |
"title": "Developer", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Author}}", | |
"short": true | |
}, | |
{ | |
"title": "Revision Message", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Message}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Operation Application", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#000080' | |
title: New version of an application {{.app.metadata.name}} is up and running. | |
template.app-health-degraded: | | |
email: | |
subject: Application {{.app.metadata.name}} has degraded. | |
message: | | |
{{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} has degraded. | |
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#f4c030", | |
"fields": [ | |
{ | |
"title": "Health Status", | |
"value": "{{.app.status.health.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
}, | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Health Status", | |
"value": "{{.app.status.health.status}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: | | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Application", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#FF0000' | |
title: Application {{.app.metadata.name}} has degraded. | |
template.app-sync-failed: | | |
email: | |
subject: Failed to sync application {{.app.metadata.name}}. | |
message: | | |
{{if eq .serviceType "slack"}}:exclamation:{{end}} The sync operation of application {{.app.metadata.name}} has failed at {{.app.status.operationState.finishedAt}} with the following error: {{.app.status.operationState.message}} | |
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#E96D76", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Failed at", | |
"value": "{{.app.status.operationState.finishedAt}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Operation", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#FF0000' | |
title: Failed to sync application {{.app.metadata.name}}. | |
template.app-sync-running: | | |
email: | |
subject: Start syncing application {{.app.metadata.name}}. | |
message: | | |
The sync operation of application {{.app.metadata.name}} has started at {{.app.status.operationState.startedAt}}. | |
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#0DADEA", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Started at", | |
"value": "{{.app.status.operationState.startedAt}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Operation", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
title: Start syncing application {{.app.metadata.name}}. | |
template.app-sync-status-unknown: | | |
email: | |
subject: Application {{.app.metadata.name}} sync status is 'Unknown' | |
message: | | |
{{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} sync is 'Unknown'. | |
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. | |
{{if ne .serviceType "slack"}} | |
{{range $c := .app.status.conditions}} | |
* {{$c.message}} | |
{{end}} | |
{{end}} | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#E96D76", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Application", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
title: Application {{.app.metadata.name}} sync status is 'Unknown' | |
template.app-sync-succeeded: | | |
email: | |
subject: Application {{.app.metadata.name}} has been successfully synced. | |
message: | | |
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} has been successfully synced at {{.app.status.operationState.finishedAt}}. | |
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#18be52", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Synced at", | |
"value": "{{.app.status.operationState.finishedAt}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Operation Details", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#000080' | |
title: Application {{.app.metadata.name}} has been successfully synced | |
trigger.on-created: | | |
- description: Application is created. | |
oncePer: app.metadata.name | |
send: | |
- app-created | |
when: "true" | |
trigger.on-deleted: | | |
- description: Application is deleted. | |
oncePer: app.metadata.name | |
send: | |
- app-deleted | |
when: app.metadata.deletionTimestamp != nil | |
trigger.on-deployed: | | |
- description: Application is synced and healthy. Triggered once per commit. | |
oncePer: app.status.operationState?.syncResult?.revision | |
send: | |
- app-deployed | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Succeeded'] | |
and app.status.health.status == 'Healthy' | |
trigger.on-health-degraded: | | |
- description: Application has degraded | |
send: | |
- app-health-degraded | |
when: app.status.health.status == 'Degraded' | |
trigger.on-sync-failed: | | |
- description: Application syncing has failed | |
send: | |
- app-sync-failed | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Error', | |
'Failed'] | |
trigger.on-sync-running: | | |
- description: Application is being synced | |
send: | |
- app-sync-running | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Running'] | |
trigger.on-sync-status-unknown: | | |
- description: Application status is 'Unknown' | |
send: | |
- app-sync-status-unknown | |
when: app.status.sync.status == 'Unknown' | |
trigger.on-sync-succeeded: | | |
- description: Application syncing has succeeded | |
send: | |
- app-sync-succeeded | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Succeeded'] | |
kind: ConfigMap | |
metadata: | |
creationTimestamp: null | |
leminou@Mohameds-MacBook-Pro-2 configurations % ls | |
argocd-slack-notifications eks-cluster-configuration-file.sh install-docker-on-ubuntu.sh | |
leminou@Mohameds-MacBook-Pro-2 configurations % cat eks-cluster-configuration-file.sh | |
#!/bin/bash | |
# resource that will help you setup mutli-cluster configuration : https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html | |
read -r -d '' KUBECONFIG <<EOF | |
apiVersion: v1 | |
clusters: | |
- cluster: | |
certificate-authority-data: $certificate_data | |
server: $cluster_endpoint | |
name: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name | |
contexts: | |
- context: | |
cluster: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name | |
user: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name | |
name: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name | |
current-context: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name | |
kind: Config | |
preferences: {} | |
users: | |
- name: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name | |
user: | |
exec: | |
apiVersion: client.authentication.k8s.io/v1beta1 | |
command: aws | |
args: | |
- --region | |
- $region_code | |
- eks | |
- get-token | |
- --cluster-name | |
- $cluster_name | |
# - --role | |
# - "arn:aws:iam::$account_id:role/my-role" | |
env: | |
- name: "AWS_PROFILE" | |
value: "default" | |
EOF | |
# echo "${KUBECONFIG}" > ~/.kube/config | |
leminou@Mohameds-MacBook-Pro-2 configurations % ls | |
argocd-slack-notifications eks-cluster-configuration-file.sh install-docker-on-ubuntu.sh | |
leminou@Mohameds-MacBook-Pro-2 configurations % cat argocd-slack-notifications | |
cat: argocd-slack-notifications: Is a directory | |
leminou@Mohameds-MacBook-Pro-2 configurations % cat argocd-slack-notifications/configmap.yaml | |
apiVersion: v1 | |
data: | |
context: | | |
# this can be changed anytime, developers must portforward argocd server service | |
# using the following command | |
# kubectl port-forward -n argocd svc/argocd-server 2323:80 | |
argocdUrl: http://localhost:2323 | |
environment: Developement | |
environmentShortName: dev | |
service.slack: | | |
token: $slack-token | |
channels: ["devsecops"] | |
subscriptions: | | |
# subscription to all notifications | |
- recipients: | |
- slack:devsecops | |
triggers: | |
- on-created | |
- on-deleted | |
- on-deployed | |
- on-health-degraded | |
- on-sync-failed | |
- on-sync-running | |
- on-sync-succeeded | |
- on-sync-status-unknown | |
defaultTriggers: | | |
- on-deployed | |
- on-health-degraded | |
- on-sync-failed | |
- on-sync-succeeded | |
- on-sync-status-unknown | |
template.app-created: | | |
email: | |
subject: Application {{.app.metadata.name}} has been created. | |
message: Application {{.app.metadata.name}} has been created. | |
teams: | |
title: Application {{.app.metadata.name}} has been created. | |
template.app-deleted: | | |
email: | |
subject: Application {{.app.metadata.name}} has been deleted. | |
message: Application {{.app.metadata.name}} has been deleted. | |
teams: | |
title: Application {{.app.metadata.name}} has been deleted. | |
template.app-deployed: | | |
email: | |
subject: New version of an application {{.app.metadata.name}} is up and running. | |
message: | | |
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} is now running new version of deployments manifests. | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#18be52", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Revision", | |
"value": "{{.app.status.sync.revision}}", | |
"short": true | |
}, | |
{ | |
"title": "Developer", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Author}}", | |
"short": true | |
}, | |
{ | |
"title": "Revision Message", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Message}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
}, | |
{ | |
"name": "Revision", | |
"value": "{{.app.status.sync.revision}}" | |
}, | |
{ | |
"title": "Developer", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Author}}", | |
"short": true | |
}, | |
{ | |
"title": "Revision Message", | |
"value": "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Message}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Operation Application", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#000080' | |
title: New version of an application {{.app.metadata.name}} is up and running. | |
template.app-health-degraded: | | |
email: | |
subject: Application {{.app.metadata.name}} has degraded. | |
message: | | |
{{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} has degraded. | |
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#f4c030", | |
"fields": [ | |
{ | |
"title": "Health Status", | |
"value": "{{.app.status.health.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
}, | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Health Status", | |
"value": "{{.app.status.health.status}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: | | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Application", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#FF0000' | |
title: Application {{.app.metadata.name}} has degraded. | |
template.app-sync-failed: | | |
email: | |
subject: Failed to sync application {{.app.metadata.name}}. | |
message: | | |
{{if eq .serviceType "slack"}}:exclamation:{{end}} The sync operation of application {{.app.metadata.name}} has failed at {{.app.status.operationState.finishedAt}} with the following error: {{.app.status.operationState.message}} | |
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#E96D76", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Failed at", | |
"value": "{{.app.status.operationState.finishedAt}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Operation", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#FF0000' | |
title: Failed to sync application {{.app.metadata.name}}. | |
template.app-sync-running: | | |
email: | |
subject: Start syncing application {{.app.metadata.name}}. | |
message: | | |
The sync operation of application {{.app.metadata.name}} has started at {{.app.status.operationState.startedAt}}. | |
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#0DADEA", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Started at", | |
"value": "{{.app.status.operationState.startedAt}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Operation", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
title: Start syncing application {{.app.metadata.name}}. | |
template.app-sync-status-unknown: | | |
email: | |
subject: Application {{.app.metadata.name}} sync status is 'Unknown' | |
message: | | |
{{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} sync is 'Unknown'. | |
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. | |
{{if ne .serviceType "slack"}} | |
{{range $c := .app.status.conditions}} | |
* {{$c.message}} | |
{{end}} | |
{{end}} | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#E96D76", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Open Application", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
title: Application {{.app.metadata.name}} sync status is 'Unknown' | |
template.app-sync-succeeded: | | |
email: | |
subject: Application {{.app.metadata.name}} has been successfully synced. | |
message: | | |
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} has been successfully synced at {{.app.status.operationState.finishedAt}}. | |
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . | |
slack: | |
attachments: | | |
[{ | |
"title": "{{ .app.metadata.name}}", | |
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", | |
"color": "#18be52", | |
"fields": [ | |
{ | |
"title": "Sync Status", | |
"value": "{{.app.status.sync.status}}", | |
"short": true | |
}, | |
{ | |
"title": "Repository", | |
"value": "{{.app.spec.source.repoURL}}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "{{.context.environment}}", | |
"short": true | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"title": "{{$c.type}}", | |
"value": "{{$c.message}}", | |
"short": true | |
} | |
{{end}} | |
] | |
}] | |
deliveryPolicy: PostAndUpdate | |
groupingKey: "{{.app.metadata.name}}" | |
notifyBroadcast: true | |
teams: | |
facts: | | |
[{ | |
"name": "Sync Status", | |
"value": "{{.app.status.sync.status}}" | |
}, | |
{ | |
"name": "Synced at", | |
"value": "{{.app.status.operationState.finishedAt}}" | |
}, | |
{ | |
"name": "Repository", | |
"value": "{{.app.spec.source.repoURL}}" | |
} | |
{{range $index, $c := .app.status.conditions}} | |
{{if not $index}},{{end}} | |
{{if $index}},{{end}} | |
{ | |
"name": "{{$c.type}}", | |
"value": "{{$c.message}}" | |
} | |
{{end}} | |
] | |
potentialAction: |- | |
[{ | |
"@type":"OpenUri", | |
"name":"Operation Details", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true" | |
}] | |
}, | |
{ | |
"@type":"OpenUri", | |
"name":"Open Repository", | |
"targets":[{ | |
"os":"default", | |
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}" | |
}] | |
}] | |
themeColor: '#000080' | |
title: Application {{.app.metadata.name}} has been successfully synced | |
trigger.on-created: | | |
- description: Application is created. | |
oncePer: app.metadata.name | |
send: | |
- app-created | |
when: "true" | |
trigger.on-deleted: | | |
- description: Application is deleted. | |
oncePer: app.metadata.name | |
send: | |
- app-deleted | |
when: app.metadata.deletionTimestamp != nil | |
trigger.on-deployed: | | |
- description: Application is synced and healthy. Triggered once per commit. | |
oncePer: app.status.operationState?.syncResult?.revision | |
send: | |
- app-deployed | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Succeeded'] | |
and app.status.health.status == 'Healthy' | |
trigger.on-health-degraded: | | |
- description: Application has degraded | |
send: | |
- app-health-degraded | |
when: app.status.health.status == 'Degraded' | |
trigger.on-sync-failed: | | |
- description: Application syncing has failed | |
send: | |
- app-sync-failed | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Error', | |
'Failed'] | |
trigger.on-sync-running: | | |
- description: Application is being synced | |
send: | |
- app-sync-running | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Running'] | |
trigger.on-sync-status-unknown: | | |
- description: Application status is 'Unknown' | |
send: | |
- app-sync-status-unknown | |
when: app.status.sync.status == 'Unknown' | |
trigger.on-sync-succeeded: | | |
- description: Application syncing has succeeded | |
send: | |
- app-sync-succeeded | |
when: app.status.operationState != nil and app.status.operationState.phase in ['Succeeded'] | |
kind: ConfigMap | |
metadata: | |
creationTimestamp: null | |
name: argocd-notifications-cm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment