首页 > 其他分享 >Argo Rollouts notifications

Argo Rollouts notifications

时间:2023-12-26 18:06:18浏览次数:41  
标签:end name Rollouts title notifications Argo rollout spec metadata

Argo Rollouts notifications cm 模板

argo-rollouts-notification-configmap的configmap需要部署在argo-rollouts名称空间下。
apiVersion: v1
kind: ConfigMap
metadata:
  name: argo-rollouts-notification-configmap
data:
  template.analysis-run-error: |
    message: Rollout {{.rollout.metadata.name}}'s analysis run is in error state.
    email:
      subject: Rollout {{.rollout.metadata.name}}'s analysis run is in error state.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#ECB22E",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.analysis-run-failed: |
    message: Rollout {{.rollout.metadata.name}}'s analysis run failed.
    email:
      subject: Rollout {{.rollout.metadata.name}}'s analysis run failed.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#E01E5A",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.analysis-run-running: |
    message: Rollout {{.rollout.metadata.name}}'s analysis run is running.
    email:
      subject: Rollout {{.rollout.metadata.name}}'s analysis run is running.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#18be52",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.rollout-aborted: |
    message: Rollout {{.rollout.metadata.name}} has been aborted.
    email:
      subject: Rollout {{.rollout.metadata.name}} has been aborted.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#E01E5A",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.rollout-completed: |
    message: Rollout {{.rollout.metadata.name}} has been completed.
    email:
      subject: Rollout {{.rollout.metadata.name}} has been completed.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#18be52",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.rollout-paused: |
    message: Rollout {{.rollout.metadata.name}} has been paused.
    email:
      subject: Rollout {{.rollout.metadata.name}} has been paused.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#18be52",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.rollout-step-completed: |
    message: Rollout {{.rollout.metadata.name}} step number {{ add .rollout.status.currentStepIndex 1}}/{{len .rollout.spec.strategy.canary.steps}} has been completed.
    email:
      subject: Rollout {{.rollout.metadata.name}} step number {{ add .rollout.status.currentStepIndex 1}}/{{len .rollout.spec.strategy.canary.steps}} has been completed.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#18be52",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            },
            {
              "title": "Step completed",
              "value": "{{add .rollout.status.currentStepIndex 1}}/{{len .rollout.spec.strategy.canary.steps}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.rollout-updated: |
    message: Rollout {{.rollout.metadata.name}} has been updated.
    email:
      subject: Rollout {{.rollout.metadata.name}} has been updated.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#18be52",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  template.scaling-replicaset: |
    message: Scaling Rollout {{.rollout.metadata.name}}'s replicaset to {{.rollout.spec.replicas}}.
    email:
      subject: Scaling Rollout {{.rollout.metadata.name}}'s replicaset to {{.rollout.spec.replicas}}.
    slack:
      attachments: |
          [{
            "title": "{{ .rollout.metadata.name}}",
            "color": "#18be52",
            "fields": [
            {
              "title": "Strategy",
              "value": "{{if .rollout.spec.strategy.blueGreen}}BlueGreen{{end}}{{if .rollout.spec.strategy.canary}}Canary{{end}}",
              "short": true
            },
            {
              "title": "Desired replica",
              "value": "{{.rollout.spec.replicas}}",
              "short": true
            },
            {
              "title": "Updated replicas",
              "value": "{{.rollout.status.updatedReplicas}}",
              "short": true
            }
            {{range $index, $c := .rollout.spec.template.spec.containers}}
              {{if not $index}},{{end}}
              {{if $index}},{{end}}
              {
                "title": "{{$c.name}}",
                "value": "{{$c.image}}",
                "short": true
              }
            {{end}}
            ]
          }]
  trigger.on-analysis-run-error: |
    - send: [analysis-run-error]
  trigger.on-analysis-run-failed: |
    - send: [analysis-run-failed]
  trigger.on-analysis-run-running: |
    - send: [analysis-run-running]
  trigger.on-rollout-aborted: |
    - send: [rollout-aborted]
  trigger.on-rollout-completed: |
    - send: [rollout-completed]
  trigger.on-rollout-paused: |
    - send: [rollout-paused]
  trigger.on-rollout-step-completed: |
    - send: [rollout-step-completed]
  trigger.on-rollout-updated: |
    - send: [rollout-updated]
  trigger.on-scaling-replica-set: |
    - send: [scaling-replicaset]

触发器列表

1. on-rollout-completed:当部署完成并且所有步骤都完成时
2. on-rollout-step-completed:当rollout定义中的单个步骤完成时
3. on-rollout-updated:当rollout定义更改时
4. on-scaling-replica-set:当rollout中的副本数量发生更改时
5. on-analysis-run-error
6. on-analysis-run-failed
7. on-analysis-run-running
8. on-rollout-aborted
9. on-rollout-paused

自定义 template

apiVersion: v1
kind: ConfigMap
metadata:
  name: argo-rollouts-notification-configmap
  namespace: argo-rollouts
data:
  template.my-purple-template: |
    message: |
      Rollout {{.rollout.metadata.name}} has purple image

自定义 trigger

条件语言语法参考: https://github.com/expr-lang/expr/blob/master/docs/Language-Definition.md
apiVersion: v1
kind: ConfigMap
metadata:
  name: argo-rollouts-notification-configmap
  namespace: argo-rollouts
data:
  trigger.on-purple: |
    - send: [my-purple-template]
      when: rollout.spec.template.spec.containers[0].image == 'argoproj/rollouts-demo:purple'

Email 配置

配置所需参数

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

Secret 配置

apiVersion: v1
kind: Secret
metadata:
  name: argo-rollouts-notification-secret
  namespace: argo-rollouts
stringData:
  email-username: email-username
  email-password: email-password
type: Opaque

ConfigMap 配置

apiVersion: v1
kind: ConfigMap
metadata:
  name: argo-rollouts-notification-configmap  
  namespace: argo-rollouts
data:
  service.email: |
    username: $email-username
    password: $email-password
    host: smtp.exmail.com         # 按需修改
    port: 465                     # 按需修改
    from: $email-username
  emplate.rollout-completed: |
    message: Rollout {{.rollout.metadata.name}} has been completed.
    email:
      subject: Rollout {{.rollout.metadata.name}} has been completed.
  trigger.on-rollout-completed: |
    - send: [rollout-completed]

订阅配置

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollout-canary
  annotations:
    notifications.argoproj.io/subscribe.on-rollout-completed.email: wgs@hard-chain.cn;1304995320@qq.com
...

Email 内容信息

Rollout rollout-canary has been completed.

参考文档

https://argoproj.github.io/argo-rollouts/features/notifications/



标签:end,name,Rollouts,title,notifications,Argo,rollout,spec,metadata
From: https://blog.51cto.com/wangguishe/8985890

相关文章

  • Argo Rollouts Canary结合Istio进行流量迁移实例
    环境说明用argorollouts金丝雀发布策略更新nginx服务。发布过程结合Isito和analysis。创建nsargo-demo#kubectlcreatensargo-demonamespace/argo-democreated启用Istio自动注入功能#kubectllabelnamespaceargo-demoistio-injection=enablednamespace/argo-demolabe......
  • Argo Rollouts AnalysisTemplate CRD
    AnalysisTemplateCRDapiVersion:argoproj.io/v1alpha1kind:AnalysisTemplatemetadata:name:success-ratespec:args:#模板参数,模板内部引用的格式为“{{args.NAME}}”;可在调用该模板时对其赋值;-name:<string>value:<string>valueF......
  • ArgoCD和Argo Rollouts自动化部署应用
    环境说明使用ArgoRollouts部署nginx应用:1.使用Rollout部署nginx2.采用canary部署策略3.结合Analysis进行渐进式交付4.结合IstioVirtualService进行自动化流量分割和流量迁移5.部署清单放在gitrepo中使用ArgoCD进行自动化部署:1.使用Application监视GitRepository2......
  • 阿里云 ACK One Serverless Argo 助力深势科技构建高效任务平台
    作者:田双坤、于雪前言深势科技是“AIforScience”科学研究范式的引领者和践行者,致力于运用人工智能和多尺度模拟仿真算法,结合先进计算手段求解重要科学问题,为人类文明最基础的生物医药、能源、材料和信息科学与工程研究打造新一代微尺度工业设计和仿真平台。对于深势的科学家和用......
  • 阿里云 ACK One Serverless Argo 助力深势科技构建高效任务平台
    作者:田双坤、于雪前言深势科技是“AIforScience”科学研究范式的引领者和践行者,致力于运用人工智能和多尺度模拟仿真算法,结合先进计算手段求解重要科学问题,为人类文明最基础的生物医药、能源、材料和信息科学与工程研究打造新一代微尺度工业设计和仿真平台。对于深势的科学......
  • cargo-make rust 任务执行以及构建工具
    再学习nakago框架的时候发现其使用了cargo-make这个工具,但是很方便,类似make的构建模式包含的特性依赖管理,别名支持,支持workspace简单使用安装cargoinstall--forcecargo-make参考使用创建一个cargo项目 cargonewappdemoMakefile.toml文件cargonewappdemoMakefile.to......
  • [转][译] 密码哈希的方法:PBKDF2,Scrypt,Bcrypt 和 ARGON2
    原文地址:PasswordHashing:PBKDF2,Scrypt,BcryptandARGON2原文作者:MichelePreziuso译文出自:掘金翻译计划本文永久链接:https://github.com/xitu/gold-miner/blob/master/TODO1/password-hashing-pbkdf2-scrypt-bcrypt-and-argon2.md译者:司徒公子校对者:xionglong58、GJX......
  • config-cloudflare-argo-guide
    title:CloudflareArgo配置指北date:2021-11-2113:43:59author:TokisakiGalaxyexcerpt:tags:-Linux-cloudflare-Argocategories:踩坑记录设置别名sudonano/etc/bashrcaliascf=cloudflaredLinux安装为服务sudonano/etc/cloudflared/config.ymltun......
  • ArgoCD和Argo Rollouts自动化部署应用
    环境说明使用ArgoRollouts部署nginx应用:1.使用Rollout部署nginx2.采用canary部署策略3.结合Analysis进行渐进式交付4.结合IstioVirtualService进行自动化流量分割和流量迁移5.部署清单放在gitrepo中使用ArgoCD进行自动化部署:1.使用Application监视GitRepositor......
  • ArgoCD 添加私有仓库
    HTTPS方式访问私有仓库ArgoCDCLI添加私有仓库#argocdrepoaddhttps://github.com/argoproj/argocd-example-apps--username<username>--password<password>dashboard添加私有仓库SSHPrivateKeyCredentialArgoCDCLI添加known_hosts#ssh-keyscan-p3......