Deploy işaretleri: ArgoCD ve Jenkins
ArgoCD ve Jenkins deploy'larını Spitfire'a gönderin; her deploy APM servis grafiklerinde dikey bir işaret olur ve "deploy'dan sonra bozuldu" bir bakışta görünür. Deploy aynı zamanda:
- APM servis sayfasındaki Neden kırıldı? sıralamasına girer: deploy'dan önceki 30 dakika sonrasıyla karşılaştırılır, hata oranı ya da p95 yükseldiyse deploy üst sıradadır.
- Olaylar listesine düşer ve event policy'lerinden geçer: başarısız deploy
majorbir problem açar, aynı servis ve ortamın sonraki başarılı deploy'u onu kapatır.
Deploy girişleri webhook girişleridir: her birinin yalnız bir kez gösterilen kendi sfhook_ token'ı vardır. İzleme olayları modülü gerekmez.
Servis adı nereden gelir
ArgoCD'de uygulama adı, Jenkins'te gövdedeki service (yoksa job adı) APM servis adı olur.
Adlar farklıysa girişin Servis eşlemesi alanına her satıra bir uygulama=servis yazın:
# ArgoCD uygulaması = APM servisi
orders-prod=orders
billing-api=billingBüyük/küçük harf fark etmez; satırı olmayan uygulama kendi adını kullanır. Eşlemeyi değiştirirseniz sonraki deploy'lardan geçerli olur.
Girişi oluşturma
Tower'lar ve metrikler
Spitfire'da: /towers→ Webhook girişleri → Yeni giriş.Bir ad (ör.
argocd-prod) ve biçim: ArgoCD ya da Jenkins. Gerekiyorsa servis eşlemesini yazın → Yeni giriş.Pencere token'ı, Kontrolcüdeki URL'yi ve gönderici ayarını gösterir. Token yalnız burada görünür; adımlar bitene kadar pencereyi açık tutun.
Deneme deploy'u (curl) komutunu kopyalayıp bir terminalde çalıştırın.
Başarı kontrolü: yanıt
{"data":{"received":1,"services":["orders"]}}olur ve Son teslim sütunu dolar.401token ya da URL'nin yanlış kopyalandığını gösterir. Denemeordersservisinetestrevizyonlu bir işaret bırakır.
ArgoCD
argocd-notifications (ArgoCD 2.6 ve sonrasıyla gelir) üç trigger'la webhook gönderir: on-deployed (sync bitti, uygulama Healthy), on-sync-failed ve on-health-degraded. Komutlar ArgoCD'nin argocd namespace'inde olduğunu varsayar.
Token'ı argocd-notifications Secret'ına koyun. Komut token'ı sorar (ekranda ve shell history'de görünmez);
sfhook_…token'ını yapıştırıp Enter'a basın:read -rsp 'sfhook_ token: ' T; echo kubectl -n argocd get secret argocd-notifications-secret >/dev/null 2>&1 \ || kubectl -n argocd create secret generic argocd-notifications-secret kubectl -n argocd patch secret argocd-notifications-secret --type merge \ -p "{\"stringData\":{\"spitfire-token\":\"$T\"}}" && unset TBaşarı kontrolü:
secret/argocd-notifications-secret patchedyazar.Aşağıdaki YAML'ı
~/spitfire-argocd-cm.yamlolarak kaydedin.https://SPITFIRE_ADDRESS/api/v1/events/in/INPUT_IDyerine penceredeki Kontrolcüdeki URL'yi yazın (penceredeki argocd-notifications Secret + ConfigMap metninde zaten doludur).apiVersion: v1 kind: ConfigMap metadata: name: argocd-notifications-cm namespace: argocd data: service.webhook.spitfire: | url: https://SPITFIRE_ADDRESS/api/v1/events/in/INPUT_ID headers: - name: Authorization value: Bearer $spitfire-token - name: Content-Type value: application/json template.spitfire-deploy-succeeded: | webhook: spitfire: method: POST body: | {"app":"{{.app.metadata.name}}","status":"succeeded","revision":"{{.app.status.sync.revision}}","environment":"{{.app.spec.destination.namespace}}","url":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}","who":"{{with .app.status.operationState}}{{with .operation.initiatedBy}}{{.username}}{{end}}{{end}}","at":"{{with .app.status.operationState}}{{.finishedAt}}{{end}}"} template.spitfire-deploy-failed: | webhook: spitfire: method: POST body: | {"app":"{{.app.metadata.name}}","status":"failed","revision":"{{.app.status.sync.revision}}","environment":"{{.app.spec.destination.namespace}}","url":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}","who":"{{with .app.status.operationState}}{{with .operation.initiatedBy}}{{.username}}{{end}}{{end}}","at":"{{with .app.status.operationState}}{{.finishedAt}}{{end}}"} template.spitfire-deploy-degraded: | webhook: spitfire: method: POST body: | {"app":"{{.app.metadata.name}}","status":"failed","revision":"{{.app.status.sync.revision}}","environment":"{{.app.spec.destination.namespace}}","url":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}","who":"{{with .app.status.operationState}}{{with .operation.initiatedBy}}{{.username}}{{end}}{{end}}"} trigger.on-deployed: | - description: Synced and healthy oncePer: app.status.sync.revision send: [spitfire-deploy-succeeded] when: app.status.operationState != nil and app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy' trigger.on-sync-failed: | - description: Sync failed send: [spitfire-deploy-failed] when: app.status.operationState != nil and app.status.operationState.phase in ['Error', 'Failed'] trigger.on-health-degraded: | - description: Health degraded send: [spitfire-deploy-degraded] when: app.status.health.status == 'Degraded' subscriptions: | - recipients: [spitfire] triggers: [on-deployed, on-sync-failed, on-health-degraded]Uygulayın.
--server-sideConfigMap'teki diğer anahtarlarınıza dokunmaz, yalnız bunları ekler:kubectl apply --server-side --field-manager=spitfire -f ~/spitfire-argocd-cm.yamlBaşarı kontrolü:
configmap/argocd-notifications-cm serverside-appliedyazar ve bu komut URL'yi gösterir:kubectl -n argocd get cm argocd-notifications-cm -o jsonpath='{.data.service\.webhook\.spitfire}'conflicthatası aynı anahtarları başka bir aracın yönettiğini gösterir; anahtarları o araçtaki ConfigMap'e ekleyin.Bir uygulamayı sync edin (ArgoCD arayüzünde Sync ya da yeni bir commit).
Başarı kontrolü: Son teslim güncellenir; APM'de servisin grafiklerinde işaret, altında Deploy'lar listesi çıkar. Gelmediyse:
kubectl -n argocd logs deploy/argocd-notifications-controller --since=15m | grep -i spitfire
subscriptions tüm uygulamalara abone olur. Yalnız bazı uygulamalar için o bloğu silin ve her uygulamaya annotation ekleyin:
kubectl -n argocd annotate application orders --overwrite \
notifications.argoproj.io/subscribe.on-deployed.spitfire="" \
notifications.argoproj.io/subscribe.on-sync-failed.spitfire="" \
notifications.argoproj.io/subscribe.on-health-degraded.spitfire=""Jenkins
Jenkinsfile'ın post{} bloğundaki bir curl deploy'un sonucunu bildirir. Build'i hiç bozmaz: en çok 10 saniye bekler, hata verse de (|| true) build sürer.
Token'ı Jenkins'e ekleyin: Manage Jenkins → Credentials → System → Global credentials → Add Credentials → Kind: Secret text, Secret: pencereden
sfhook_…token'ı, ID:spitfire-deploy-token→ Create.Başarı kontrolü: credentials listesinde
spitfire-deploy-tokengörünür.Jenkinsfile'a
spitfireDeployfonksiyonunu vepostbloğunu ekleyin (penceredeki Jenkinsfile metninde URL doludur).ordersveprodyerine servisinizi ve ortamınızı,echosatırının yerine deploy adımlarınızı yazın.// Spitfire deploy notice: never fails the build (|| true, 10 s at most) def spitfireDeploy(String status) { def who = currentBuild.getBuildCauses()[0]?.userId ?: 'jenkins' withCredentials([string(credentialsId: 'spitfire-deploy-token', variable: 'SPITFIRE_TOKEN')]) { sh """curl -sS --max-time 10 -X POST 'https://SPITFIRE_ADDRESS/api/v1/events/in/INPUT_ID' \\ -H "Authorization: Bearer \$SPITFIRE_TOKEN" -H 'Content-Type: application/json' \\ -d '{"service":"orders","environment":"prod","status":"${status}","revision":"${env.GIT_COMMIT ?: ''}","url":"${env.BUILD_URL}","job":"${env.JOB_NAME}","build":"${env.BUILD_NUMBER}","who":"${who}"}' || true""" } } pipeline { agent any stages { stage('Deploy') { steps { script { spitfireDeploy('started') } echo 'your deploy steps here' } } } post { success { script { spitfireDeploy('succeeded') } } failure { script { spitfireDeploy('failed') } } } }Job'ı çalıştırın (Build Now).
Başarı kontrolü: build log'unda iki kez
{"data":{"received":1,"services":["orders"]}}görünür (başladı, bitti) veordersgrafiklerinde işaret çıkar. Başarısız build kırmızı işaret ve bir problem açar.
Notification plugin
Notification plugin'i header ekleyemediği için token URL'nin kullanıcı bilgisinde gider (Spitfire Basic auth parolasını token sayar).
Job → Configure → Job Notifications → Add Endpoint: Format JSON, Protocol HTTP, Event All Events, URL:
https://spitfire:sfhook_…@SPITFIRE_ADDRESS/api/v1/events/in/INPUT_IDToken görünmesin diye URL'yi Secret text credential olarak girin (URL Source: Secret).
Job'ı çalıştırın.
STARTEDbaşlayan,COMPLETEDbiten deploy olur (SUCCESSbaşarılı;FAILURE,UNSTABLE,ABORTEDbaşarısız). Servis adı job adıdır (eşleme ya daSERVICEbuild parametresi değiştirir), ortamENVIRONMENTbuild parametresidir.Başarı kontrolü: girişin son olaylarında
Deploy succeeded: <job>görünür.
Gövde biçimi
Kendi script'inizden de gönderebilirsiniz; tek nesne ya da en çok 100 elemanlı liste:
| Alan | Anlamı |
|---|---|
service / app / job |
Servis adı (eşleme uygulanır) |
status |
started, succeeded, failed (success, failure, synced, degraded… da olur) |
revision / commit |
Sürüm ya da commit |
environment / env |
Ortam; APM'deki ortam seçimiyle eşleşir, boşsa her ortamda görünür |
url |
CI/CD bağlantısı (yalnızca http/https) |
who |
Deploy'u yapan |
at |
Zaman (RFC 3339 ya da Unix saniye); yoksa geliş zamanı |
message |
Not |