首页 > 其他分享 >ArgoCD notifications 配置

ArgoCD notifications 配置

时间:2023-12-26 18:07:14浏览次数:63  
标签:status name Application app 配置 ArgoCD notifications email

ArgoCD notifications Triggers

Triggers 定义应发送通知的条件。定义包括名称、条件 和通知模板参考。条件是一个谓词表达式,如果通知则返回 true 应该发送。

Triggers 列表

1. on-created                        # Application 创建
2. on-deleted                        # Application 删除
3. on-deployed                       # Application 已经同步完成且正常运行。每次提交触发一次。
4. on-health-degraded                # Application 降级
5. on-sync-failed                    # Application 同步失败
6. on-sync-running                   # Application 正在同步
7. on-sync-status-unknown            # Application 状态为 'Unknown'
8. on-sync-succeeded                 # Application 同步成功

Triggers 示例

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
data:
  # Optional 'oncePer' property ensure that notification is sent only once per specified field value
  # E.g. following is triggered once per sync revision
  trigger.on-deployed: |
    when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
    oncePer: app.status.sync.revision
    send: [app-sync-succeeded]

ArgoCD notifications Templates

通知模板用于生成通知内容,并在argocd-notifications-cm ConfigMap中进行配置。

Templates 定义规范

1. app:保存应用程序对象。
2. context:是用户定义的字符串映射,可能包含任何字符串键和值。
3. serviceType:保存通知服务类型名称。该字段可用于有条件地呈现服务特定字段。
4. recipient:保存收件人姓名。

定义 context

定义共享 context 可在Templates引用。
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
data:
  context: |
    region: east
    environmentName: staging

  template.a-slack-template-with-context: |
    message: "Something happened in {{ .context.environmentName }} in the {{ .context.region }} data center!"

Email 配置

配置所需参数

电子邮件通知服务使用 SMTP 协议发送电子邮件通知,并需要指定以下设置:
host: SMTP 服务器主机名
port: SMTP 服务器端口
username: 用户名
password: 密码
from: 发送电子邮件地址
html: 可选布尔值,true 或 false
insecure_skip_verify: 可选布尔值,true 或 false

Secret 配置

apiVersion: v1
kind: Secret
metadata:
  name: argocd-notifications-secret
  namespace: argocd
stringData:
  email-username: email-username
  email-password: email-password
type: Opaque

ConfigMap 配置

# kubectl edit cm argocd-notifications-cm  -n argocd
添加 data 部分内容。
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
  ...
data:
  service.email: |
    username: $email-username
    password: $email-password
    host: smtp.exmail.qq.com
    port: 465
    from: $email-username

  template.app-deployed: |
    email:
      subject: New version of an application {{.app.metadata.name}} is up and running.
    message: |
      Application {{.app.metadata.name}} is now running new version of deployments manifests.
  template.app-sync-succeeded: |
    email:
      subject: Application {{.app.metadata.name}} has been successfully synced.
    message: |
      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 .

  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-sync-succeeded: |
    - description: Application syncing has succeeded
      send:
      - app-sync-succeeded
      when: app.status.operationState != nil and app.status.operationState.phase in ['Succeeded']

订阅通知 

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: nginx
  namespace: argocd
  annotations:
    notifications.argoproj.io/subscribe.on-deployed.email: wgs@hard-chain.cn;1304995320@qq.com
...

邮件信息

Application nginx is now running new version of deployments manifests.

notifications 配置示例

apiVersion: v1
data:
  service.email: |
    username: $email-username
    password: $email-password
    host: smtp.exmail.qq.com
    port: 465
    from: $email-username
  template.app-deployed: |
    email:
      subject: New version of an application {{.app.metadata.name}} is up and running.
    message: |
      Application {{.app.metadata.name}} is now running new version of deployments manifests.
  template.app-sync-succeeded: |
    email:
      subject: Application {{.app.metadata.name}} has been successfully synced.
    message: |
      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 .
  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-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:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"ConfigMap","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"notifications-controller","app.kubernetes.io/name":"argocd-notifications-controller","app.kubernetes.io/part-of":"argocd"},"name":"argocd-notifications-cm","namespace":"argocd"}}
  creationTimestamp: "2023-12-08T09:41:38Z"
  labels:
    app.kubernetes.io/component: notifications-controller
    app.kubernetes.io/name: argocd-notifications-controller
    app.kubernetes.io/part-of: argocd
  name: argocd-notifications-cm
  namespace: argocd
  resourceVersion: "9897682"
  uid: 6953cdca-7551-49e2-8e5c-daf16c3fdd9f

参考文档

https://argo-cd.readthedocs.io/en/stable/operator-manual/notifications/



标签:status,name,Application,app,配置,ArgoCD,notifications,email
From: https://blog.51cto.com/wangguishe/8985881

相关文章

  • ArgoCD和Argo Rollouts自动化部署应用
    环境说明使用ArgoRollouts部署nginx应用:1.使用Rollout部署nginx2.采用canary部署策略3.结合Analysis进行渐进式交付4.结合IstioVirtualService进行自动化流量分割和流量迁移5.部署清单放在gitrepo中使用ArgoCD进行自动化部署:1.使用Application监视GitRepository2......
  • ArgoCD 添加私有仓库
    HTTPS方式访问私有仓库ArgoCDCLI添加私有仓库#argocdrepoaddhttps://github.com/argoproj/argocd-example-apps--username<username>--password<password>dashboard添加私有仓库SSHPrivateKeyCredentialArgoCDCLI添加known_hosts#ssh-keyscan-p35022192.168......
  • Argo Rollouts notifications
    ArgoRolloutsnotificationscm模板argo-rollouts-notification-configmap的configmap需要部署在argo-rollouts名称空间下。apiVersion:v1kind:ConfigMapmetadata:name:argo-rollouts-notification-configmapdata:template.analysis-run-error:|message:Rollo......
  • ArgoCD和Argo Rollouts自动化部署应用
    环境说明使用ArgoRollouts部署nginx应用:1.使用Rollout部署nginx2.采用canary部署策略3.结合Analysis进行渐进式交付4.结合IstioVirtualService进行自动化流量分割和流量迁移5.部署清单放在gitrepo中使用ArgoCD进行自动化部署:1.使用Application监视GitRepository2......
  • 验证码技术指南:在线对“验证魔方”进行个性化配置
    验证码作为人机交互界面经常出现的关键要素,是身份核验、防范风险、数据反爬的重要组成部分,广泛应用网站、App上,在注册、登录、交易、交互等各类场景中发挥着巨大作用,具有真人识别、身份核验的功能,在保障账户安全方面也具有重要作用。顶象无感验证对操作者进行智能判定,将操作者区......
  • QT 中配置 64位kafka ,c++
    在MSYS2下,执行$pacman-Smingw32/mingw-w64-i686-librdkafkamingw64/mingw-w64-x86_64-librdkafka即可获得二进制库、头文件和动态链接库。文件路径实例,D:\msys64\mingw64下找文件即可:D:\msys64\mingw64\lib\librdkafka++.dll.a 在工程文件中创建文件夹thirdparty/librdkaf......
  • Taurus .Net Core 微服务开源框架:Admin 插件【4-6】 - 配置管理-Mvc【Plugin-Doc 接口
    前言:继上篇:Taurus.NetCore微服务开源框架:Admin插件【4-5】-配置管理-Mvc【Plugin-Admin后台】本篇继续介绍下一个内容:系统配置节点:Mvc- Plugin- Doc 接口测试及文档:配置界面如下:  配置说明如下:1、Doc.IsEnable:配置当前接口测试文档插件是否可用这是一个......
  • 如何配置双网关/双网卡
    #1.前期准备1)两个网卡都需要正确设置,包括各自默认网关(注意,两个网卡都需要设定网关)  网卡配置文件在/etc/sysconfig/network-scripts/目录下,需要正确设置两个网卡的配置文件,然后重新启用新配置。2)两个网卡都已正确接入到两路线路,并且两路网络的服务供应商都已正常提供服务#2.......
  • grep -Ev '#|^$' zabbix_server.conf 显示配置文件 命令
    grep-Ev'#|^$'zabbix_server.confroot@k8s-node01:/etc/zabbix#grep-Ev'#|^$'zabbix_server.confLogFile=/var/log/zabbix/zabbix_server.logLogFileSize=0PidFile=/run/zabbix/zabbix_server.pidSocketDir=/run/zabbixDBName=zabbixDBUser=......
  • Keepalived 安装 配置 Nginx 高可用
    Keepalived安装配置Nginx高可用Keepalived安装yuminstall-ykeepalived配置文件位置/etc/keepalived/keepalived.conf配置nginx高可用vi/etc/keepalived/keepalived.confvrrp_scriptchk_gluster{script"/usr/bin/systemctlis-activeglusterd"int......