前言
安装
1 2
| kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
|
自定义的配置
自定义域名和instanceLabelKey
如果使用helm的话,一般会用app.kubernetes.io/instance来当做标签, 而argocd默认也是用这个标签来追踪资源的,所以就会导致被重写导致部署的资源出错。
使用: application.instanceLabelKey 配置来自定义key
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| apiVersion: v1 data: application.instanceLabelKey: www.baidu.com/instance url: https://argocd.baidu.com kind: ConfigMap metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"v1","kind":"ConfigMap","metadata":{"annotations":{},"labels":{"app.kubernetes.io/name":"argocd-cm","app.kubernetes.io/part-of":"argocd"},"name":"argocd-cm","namespace":"argocd"}} labels: app.kubernetes.io/name: argocd-cm app.kubernetes.io/part-of: argocd name: argocd-cm namespace: argocd
|
登录
GitLab WebHook
添加Token
1 2 3 4 5 6
| kubectl edit secret argocd-secret -n argocd
stringData: webhook.gitlab.secret: LS0tLS1CRUdJTiBSU0EgUFJJVk
|
添加集群
通过kube config添加
1 2 3 4 5 6
| kubectl config get-contexts -o name --kubeconfig ~/.kube/.config/test # 通过 content name 添加集群, 并重命名s argocd cluster add {content-name} --kubeconfig ~/.kube/.config/test --name { cluster name}
argocd cluster list
|
通知
修改 argocd-notifications-cm 配置通知
通知分为3部分, 触发器(Triggers), 模板(Templates), 还有订阅(subscriptions)
订阅下配置触发器和recipient
触发器下配置模板
模板
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| template.app-health-degraded: | email: subject: Application {{.app.metadata.name}} has degraded. message: | {{if eq .serviceType "slack"}}:exclamation:{{end}} App {{.app.metadata.name}} 服务降级. *可能原因*: `服务可能一直在崩溃, pending, 以及其他情况导致服务无法正常运行.` slack: attachments: |- [{ "title": "{{ .app.metadata.name}}", "title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", "color": "#f4c030", "fields": [ { "title": "Sync Status", "value": "{{.app.status.sync.status}}", "short": true }, { "title": "Repository", "value": "{{.app.spec.source.repoURL}}", "short": true } ] }]
|
触发器
1 2 3 4 5
| trigger.on-health-degraded: | - description: Application has degraded send: - app-health-degraded when: app.status.health.status == 'Degraded'
|
订阅
配置了 slack 通知
1 2 3 4 5 6 7
| subscriptions: | - recipients: - slack:dawdawdwad triggers: - on-sync-succeeded - on-sync-failed - on-health-degraded
|
服务
slack 配置
1 2
| service.slack: | token: 11111111111111111111111
|
完整参考