Argo Rollouts notifications
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/