《OpenShift 4.x HOL教程汇总》
说明:本文已经 在OpenShift 4.15 + OpenShift GitOps 1.11.2 环境中验证
说明:先根据《OpenShift 4 之 GitOps(1)通过OpenShift GitOps Operator 安装 ArgoCD》完成安装,然后在 ArgoCD 中创建 spring-petclinic 应用。
ArgoCD 在更新完应用后可以根据更新的状态触发相关事件,例如:on-sync-succeeded,on-sync-running,on-sync-failed 等。针对这些事件,可以通过不同的渠道(例如:Email、Slack、Grafna、Webhook)发送给指定通知方。
$ oc patch argocd openshift-gitops -n openshift-gitops --type merge --patch '{"spec": {"notifications": {"enabled": true}}}'
$ oc get notificationsconfiguration -n openshift-gitops
NAME AGE
default-notifications-configuration 21m
$ oc get cm argocd-notifications-cm -n openshift-gitops
NAME DATA AGE
argocd-notifications-cm 16 35m
$ oc get secret argocd-notifications-secret -n openshift-gitops
NAME TYPE DATA AGE
argocd-notifications-secret Opaque 0 37m
$ oc apply -n argocd -f - << EOF
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
email-username: xxx@gmail.com
email-password: xxxxxxxxxxxxx
type: Opaque
EOF
apiVersion: argoproj.io/v1alpha1
kind: NotificationsConfiguration
name: default-notifications-configuration
namespace: openshift-gitops
spec:
services:
service.email.gmail: |
host: smtp.gmail.com
port: 465
username: $email-username
password: $email-password
from: $email-username
。。。
$ oc annotate application spring-petclinic -n openshift-gitops notifications.argoproj.io/subscribe.on-sync-succeeded.gmail='user@sina.com;user@sohu.com'
https://blog.argoproj.io/notifications-for-argo-bb7338231604
https://github.com/redhat-developer/gitops-operator/blob/master/docs/OpenShift%20GitOps%20Usage%20Guide.md
https://developers.redhat.com/articles/2023/01/17/how-openshift-gitops-notifications-can-trigger-pipelines
https://argo-cd.readthedocs.io/en/stable/operator-manual/notifications/
https://argo-cd.readthedocs.io/en/latest/operator-manual/notifications/subscriptions/
https://github.com/argoproj/argo-cd/discussions/9655
https://wearenotch.com/email-notifications-and-github-webhooks-with-argo-cd/
更多【git-GitOps - 为 OpenShift GitOps 配置邮件通知】相关视频教程:www.yxfzedu.com