Argo CD + pushplus:同步结果推到微信
效果:Application 同步成功、失败或健康度变化后,微信收到应用名和 sync 状态。
Argo CD 没有内置 pushplus。用 Notifications 的 Webhook,或在 Resource Hook 里 curl。若界面只能填一个 URL,用 GET 固定文案。
前置条件
- 一个 pushplus token(官网扫码获取)
- 能改
argocd-notifications-cm,或能加 PostSync Hook
配置步骤
方式一:Notifications Webhook
- 编辑 ConfigMap argocd-notifications-cm(一般在
argocd命名空间)。 - 只能填 URL 时用 GET 固定文案(Argo 默认 POST 的通知 JSON 不会变成
content):
https://www.pushplus.plus/send?token=你的token&title=ArgoCD同步事件&content=请打开ArgoCD查看应用状态
- 若该 Webhook 支持自定义
method/body,改为 POST JSON:
service.webhook.pushplus: |
url: https://www.pushplus.plus/send
headers:
- name: Content-Type
value: application/json
template.app-sync:
webhook:
pushplus:
method: POST
body: |
{"token":"你的token","title":"Argo CD {{.app.metadata.name}}","content":"sync={{.app.status.sync.status}} health={{.app.status.health.status}}","template":"markdown"}
Trigger、subscribe 按 Argo CD Notifications 文档绑定,例如 Application 注解 notifications.argoproj.io/subscribe.on-sync-succeeded.pushplus。
方式二:Hook 里 curl
在 Application 的 PostSync / SyncFail Hook Job 末尾:
curl -s -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d "{\"token\":\"$PUSH_PLUS_TOKEN\",\"title\":\"Argo CD $ARGOCD_APP_NAME\",\"content\":\"phase=$ARGOCD_APP_SYNC_STATUS\",\"template\":\"markdown\"}"
token 用 K8s Secret 注入,不要写进清单仓库。完整字段见 消息接口。
验证
curl -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d '{"token":"你的token","title":"Argo CD 配置测试","content":"token 可用","template":"markdown"}'
常见问题
订阅了但没消息? 看 argocd-notifications-controller 日志;集群出网要能访问 www.pushplus.plus。排查见 收不到消息、接口限制。
正文总是固定那句? GET 直连就是固定文案。动态字段必须自定义 body 或在 Hook 里自己拼 JSON。