Kubernetes and Argo CD
Run Smoketest after Kubernetes or Argo CD deployments become healthy.
Use Smoketest after your Kubernetes workload is rolled out and reachable. For GitOps, trigger Smoketest from Argo CD Notifications after an app sync succeeds and health is good. For imperative deploys, call Smoketest after kubectl rollout status.
Kubectl deploy script
kubectl apply -f k8s/
kubectl rollout status deployment/acme-web --namespace production --timeout=5m
curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
-H "Idempotency-Key: ${DEPLOYMENT_ID:-$(git rev-parse HEAD)}" \
--data-urlencode "targetUrl=https://app.example.com" \
--data-urlencode "commitSha=$(git rev-parse HEAD)" \
--data-urlencode "branch=$(git rev-parse --abbrev-ref HEAD)" \
--data-urlencode "externalId=${DEPLOYMENT_ID:-$(git rev-parse HEAD)}"Argo CD Notifications
Argo CD Notifications can send generic webhook requests. Configure the notification to call the Smoketest trigger URL only when the application is synced and healthy.
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.webhook.smoketest: |
url: $smoketest-webhook-url
method: POST
template.smoketest: |
webhook:
smoketest:
method: POST
path: ?targetUrl=https%3A%2F%2Fapp.example.com&commitSha={{.app.status.sync.revision}}&externalId={{.app.metadata.uid}}-{{.app.status.sync.revision}}
trigger.on-deployed: |
- when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
send: [smoketest]Store the secret URL in argocd-notifications-secret as smoketest-webhook-url.
Notes
For GitHub checks, bind the Smoketest webhook to a mapped GitHub repository and send a commit SHA that belongs to that repository. Argo CD's sync.revision is a Git SHA for Git-backed apps.