Skip to content

feat(argocd): GitHub push webhook on a locked-down public host - #307

Open
arunanshub wants to merge 2 commits into
masterfrom
feat/argocd-github-webhook
Open

arunanshub wants to merge 2 commits into
masterfrom
feat/argocd-github-webhook

Conversation

@arunanshub

@arunanshub arunanshub commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Argo CD refreshes on push instead of waiting up to ~3 minutes for its poll. GitHub delivers to argocd-hook.arunanshu.dev/api/webhook; argocd.arunanshu.dev stays behind the Access OTP.

Layers

Layer File Admits
Cloudflare WAF custom rule infra/cloudflare_waf.tf GitHub hooks CIDRs only (from api.github.com/meta, re-read every plan), POST /api/webhook only
Access bypass infra/cloudflare_access.tf /api/webhook path only; other paths on the host still hit OTP
Traefik kubernetes/components/argocd-webhook Route matches only POST /api/webhook; RateLimit 30/min, burst 30
Argo CD both argocd values files HMAC via webhook.github.secret ($argocd-webhook-github:secret ref); body ≤ 5MB

Secret: random_password in tofu state → just seal-argocd-webhook → SealedSecret; and → just github-argocd-webhook → GitHub API. Never printed.

Before merging

  • Check Security → WAF → Custom rules in the dashboard. cloudflare_ruleset.zone_custom_firewall owns the zone's custom-rules entry point; import any existing rules first.
  • just infra-apply
  • just seal-argocd-webhook, commit github-secret.sealedsecret.yaml here. The Render diff CI job fails until this lands (kustomize build of the component resources can't find the file) (deliberate: no placeholder secret).
  • Re-sign the commits with your key if you want it signed by you (it's signed by the agent session's key).

After merging

  • Manually sync the argocd Application (no auto-sync), then check the live argocd-secret / argocd-cm.
  • just github-argocd-webhook, push something, watch Recent Deliveries.

Known risk: Bot Fight Mode

It's on in cloudflare_hardening.tf, runs outside the Ruleset Engine, and cannot be skipped by any custom rule. If it challenges GitHub's deliveries, the fix is an IP Access allow rule for the hook CIDRs or turning it off. Both are zone-wide, so neither is included here. Triage table in docs/runbooks/argocd-webhook.md.

Validation run locally

  • tofu fmt -check, tofu validate (lock file updated for hashicorp/http 3.6.3)
  • prod overlay through kustomize + kubeconform with a throwaway sealed secret: 55/55 valid
  • opsctl verify-adoption: invariant holds
  • yamlfmt -lint, just --fmt --check, gitleaks: clean
  • kubeseal 0.36.0 against the committed cert: the part-of label lands in spec.template.metadata.labels

Not run: render-diff / conftest (CI does it), infra-plan (needs your state).

https://claude.ai/code/session_01ApgDFwSZDFKWW75JMu3hXu


Generated by Claude Code

Argo CD now refreshes on push instead of waiting up to ~3 minutes for its
poll. GitHub delivers to argocd-hook.arunanshu.dev/api/webhook; the UI host
stays behind the wildcard Access OTP.

Four independent layers keep the public host narrow:
- Cloudflare WAF custom rule: only GitHub's `hooks` CIDRs (read from
  api.github.com/meta each plan), only POST /api/webhook.
- Cloudflare Access: path-scoped bypass for /api/webhook only.
- Traefik: HTTPRoute matches only POST /api/webhook, behind a RateLimit
  middleware (per-host bucket; remote addr is cloudflared's).
- Argo CD: HMAC check via webhook.github.secret, resolved from the sealed
  argocd-webhook-github Secret through a $ref; body capped at 5MB.

The secret is generated in tofu state and flows to kubeseal
(`just seal-argocd-webhook`) and the GitHub API
(`just github-argocd-webhook`) without being printed. Polling stays at the
chart default as the fallback. Rollout, triage and rotation are in
docs/runbooks/argocd-webhook.md.

The sealed secret is not in this commit: it must be generated from tofu
state after `just infra-apply`, so check-manifests fails until it lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ApgDFwSZDFKWW75JMu3hXu
The prod overlay only holds the Application, so check-manifests never
builds the component's resources/; the render job does, and that is the
one that fails until the SealedSecret is committed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ApgDFwSZDFKWW75JMu3hXu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants