Skip to main content

GitOps and CI/CD Patterns

Delivery patterns trunk-based CI, GitOps reconciliation, progressive rollout, and security gates in the pipeline.


GitOps and CI/CD Patterns

CI builds and verifies artifacts. CD promotes trusted artifacts to environments. GitOps makes git the desired-state source for what runs in cluster.


Pattern comparison

PatternHow it worksBest for
Push-based CDPipeline calls kubectl apply or cloud APISimple apps, few clusters
GitOps (pull)Controller syncs cluster to gitKubernetes, audit trail
Feature flagsDecouple deploy from releaseSaaS, gradual exposure
Blue/greenTwo identical envs; switch trafficZero-downtime migrations
CanarySmall % traffic to new versionRisk reduction

Reference pipeline (secure)

Research Core: CI/CD · DevSecOps


GitOps repository layout

infra-repo/ apps/ payments/ base/ overlays/ staging/ production/ clusters/ prod-eks/ argocd-apps.yaml

Rules:

  • Immutable tags in production no :latest
  • Separate repos or paths for app source vs deployment manifests
  • PR reviews on every prod change

Environment promotion

GateStagingProduction
Automated testsRequiredRequired
Security scan severityBlock criticalBlock critical + high
Manual approvalOptionalRequired for tier-1
Smoke tests post-deployRequiredRequired + synthetic monitors

Common failures (and fixes)

SymptomLikely causeFix
Drift between git and clusterManual kubectl editDisable direct edits; reconcile
Slow pipelinesNo cachingCache deps; parallelize independent jobs
Flaky tests block everyoneQuarantine + fixSeparate quarantine job; SLA to fix
Secrets in workflow logsEcho or env dumpMask secrets; use OIDC to cloud

Learning exercise

  1. Fork a sample app.
  2. Add GitHub Actions: test → build → push to registry with digest tag.
  3. Add Argo CD Application pointing at kustomize overlay.
  4. Change replica count in git; watch sync never kubectl scale by hand.

Further reading on this site