Configuration de la notification ArgoCD Slack
Recevez des notifications pour tous vos mouvements Argo :)
1- Créez une application Slack en utilisant l'URL ci-dessous.
https://api.slack.com/apps?new_app=1
Ensuite, choisissez "À partir de zéro"
Remplissez le nom de l'application, tel que "argocd", et sélectionnez votre espace de travail Slack comme ci-dessous.
Une fois l'application créée, accédez àEnter OAuth & Permissions & Choose Permissions
Maintenant, ajoutez une étendue pour ce Bot (application argocd), donc sélectionnez Deux étendues pour le moment.
Une fois Scope configuré, faites défiler vers le haut, cliquez sur le bouton "Installer l'application sur l'espace de travail" et confirmez l'installation.
Une fois l'installation terminée, copiez le jeton OAuth.
2- Créez maintenant un canal Slack - par exemple argocd
Important- Parcourez votre canal argocd et ajoutez le bot que vous avez créé à l'étape précédente, dans ce cas, le nom du bot est "argocd"
### Si vous oubliez d'ajouter ceci, vous ne recevrez PAS de notifications. ###
Après avoir ajouté le Bot au canal Slack. Nous devons apporter quelques modifications à nos fichiers de configuration ArgoCD .
3- Changements de configuration ArgoCD.
En supposant que votre jeton de mou est — xoxp-12345678912345–5467834251-jGQASEDJGNCDHTIv9ZcY
Dans votre configuration argocd, recherchez le Secret argocd-notifications-secret.
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
slack-token: "xoxp-12345678912345–5467834251-jGQASEDJGNCDHTIv9ZcY"
Maintenant, postulez—
kubectl apply -f argocd-notifications-secret.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.slack: |
token: $slack-token # use as it is
defaultTriggers: |
- on-deployed
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.phase in ['Succeeded'] and app.status.health.status == 'Healthy' and app.status.sync.status == 'Synced'
template.app-deployed: |
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
}
{{range $index, $c := .app.status.conditions}}
{{if not $index}},{{end}}
{{if $index}},{{end}}
{
"title": "{{$c.type}}",
"value": "{{$c.message}}",
"short": true
}
{{end}}
]
}]
Postulez maintenant —
kubectl apply -f argocd-notifications-cm.yaml
Ouvrez votre fichier d'application de service, tel que celui ci-dessous, et ajoutez l'annotation slack.
annotations:
notifications.argoproj.io/subscribe.on-deployed.slack: argocd #Slack Channel name
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ms-echoserver-application
namespace: argocd
annotations:
notifications.argoproj.io/subscribe.on-deployed.slack: argocd #Slack Channel name
argocd-image-updater.argoproj.io/image-list: myalias=gcr.io/project01/ms-echoserver:dev #Write repository name
argocd-image-updater.argoproj.io/myalias.pull-secret: pullsecret:argocd/argocd-gcr-secret # You can remove this annotation if you have already configured the gcr secret and are using the same secret to retrieve all GCR images in your deployments.
argocd-image-updater.argoproj.io/myalias.update-strategy: digest #There are several ways to update the image, but I'm using digest.
argocd-image-updater.argoproj.io/write-back-method: git # We don't need the secret as mentioned in argocd doc because we already set it up via argocd console if you're using the same git repo.
argocd-image-updater.argoproj.io/git-branch: main
argocd-image-updater.argoproj.io/myalias.force-update: "true"
Test -
Déployez maintenant votre service et testez la notification. Je déploie ms-echoserver-application.
Cliquez sur moi-
Guide d'installation ArgoCD tout-en-un.
ArgoCD Haute Disponibilité (HA) [Production Ready].
Crochets de ressources ArgoCD.
J'espère que ce post est informatif et utile pour vous :)
Par moi un café ← — — — Si vous aimez le blog, s'il vous plaît donnez-moi un Clap : ) et suivez-moi pour plus de contenu.
Vos applaudissements me motivent à continuer à écrire de tels blogs.
![Qu'est-ce qu'une liste liée, de toute façon? [Partie 1]](https://post.nghiatu.com/assets/images/m/max/724/1*Xokk6XOjWyIGCBujkJsCzQ.jpeg)



































