on
GitOps with GitHub Actions and Kubernetes: a practical pattern for safe, automated deployments
Continuous deployment to Kubernetes is easier and safer when you combine GitHub Actions for CI with a GitOps CD engine (Argo CD or Flux) and progressive-delivery tools like Argo Rollouts. This article explains a recent, practical pattern that many teams are adopting: use Actions to build, test, and update your Git “source of truth,” and let a GitOps controller reconcile that repo into the cluster — with progressive delivery for controlled rollouts.
Why this pattern now
- GitOps is the dominant delivery model for Kubernetes teams because it makes deployments auditable, repeatable, and reversible: your Git repo is the single source of truth and the cluster continuously converges to it. Many recent industry surveys and write‑ups show rising adoption of GitOps tools like Argo CD and Flux. (cncf.io)
- GitHub Actions is widely used for CI and can either directly call a deployment API or (preferably in GitOps setups) update manifests in Git so the CD engine handles the actual cluster changes. GitHub’s docs describe both deploying from Actions and using environment protections and approvals to control releases. (docs.github.com)
- Argo Rollouts adds safe deployment strategies (canary, blue/green, automated analysis) on top of Kubernetes and integrates cleanly with Argo CD and Actions for end-to-end automation. (github.com)
High-level architecture
- CI (GitHub Actions)
- Build image, run tests, push image to a registry (e.g., GitHub Container Registry).
- Update the image tag in a GitOps config repository (or create a PR against it).
- CD (Argo CD / Flux)
- The GitOps operator (pull-based) detects the change in the config repo and reconciles the cluster.
- Progressive delivery (Argo Rollouts)
- Rollouts or automated canaries manage traffic shifting, health checks, and automated rollbacks.
This separation keeps CI focused on producing artifacts and CD focused on delivery and cluster state management — a pattern shown in multiple end‑to‑end guides and tutorials. (teerakarna.github.io)
Concrete workflow (step-by-step)
- Build and push image
- Use a GitHub Actions workflow to build a container image tagged with the commit SHA and push it to your registry (GHCR, ECR, GCR, etc.). This gives you immutable images for traceability. (dev.to)
- Update manifests in the config repo
- After pushing the image, update the Kubernetes manifests or Helm values in the GitOps repo. You can:
- Commit directly from the Actions job using a bot account PAT, or
- Open a PR so reviewers can validate and approve the change, or
- Use Argo CD Image Updater / Flux image automation to automatically write back new image tags. (argo-cd.readthedocs.io)
- After pushing the image, update the Kubernetes manifests or Helm values in the GitOps repo. You can:
- Let GitOps reconcile
- Argo CD or Flux observes the repo and applies the new manifests to the cluster. This pull model reduces the need for cluster credentials in CI runners and centralizes authorization in the operator. (argo-cd.readthedocs.io)
- Run progressive delivery
- If you need safe, gradual rollouts, configure Argo Rollouts resources instead of plain Deployments. Rollouts support canaries, traffic-weighted steps, and automated analysis/rollback — all of which can be triggered by the manifest change. (github.com)
Minimal GitHub Actions example Below is a compact example showing the CI piece: build, push, and update a Kubernetes YAML in a separate config repo. (You’ll need a PAT stored as secrets.REPO_PAT or use an image‑updater integration instead.)
- name: build-and-promote.yml (excerpt) ```yaml on: push: branches: [ “main” ]
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build image run: docker build -t ghcr.io/myorg/myapp:$ . - name: Login to GHCR uses: docker/login-action@v2 with: registry: ghcr.io username: $ password: $ - name: Push image run: docker push ghcr.io/myorg/myapp:$ - name: Update config repo (bot commit) env: REPO: myorg/config-repo PAT: $ run: | git clone https://x-access-token:${PAT}@github.com/${REPO}.git cd config yq e -i “.image.tag = "$"” k8s/myapp/values.yaml git commit -am “promote image $” git push origin main ``` This action pushes a new manifest to the config repo; Argo CD will detect and apply it. Alternatively, use an Image Updater to automate tag writes without a PAT. (dev.to)
Safety and operational tips
- Use immutable tags (SHA) rather than “latest” to make rollbacks unambiguous.
- Protect the config repo: require PR reviews, branch protection, and CODEOWNERS for cross-team security.
- Prefer pull-based deployment (Argo CD / Flux) to limit credentials on CI runners and to give platform teams an audit trail. (argo-cd.readthedocs.io)
- Add health checks and automated analysis (Prometheus, SLOs) to rollouts so Argo Rollouts can decide when to proceed or rollback automatically. (github.com)
Why choose Argo CD + Argo Rollouts (short rationale)
- App-centric UI and broad ecosystem: Argo CD provides clear visibility into application state and a rich set of integrations (ApplicationSet, Image Updater, rollouts). Many teams choose Argo CD for platform-style deployments and operational visibility. (argo-cd.readthedocs.io)
- Flux is also a strong option (tighter Git-based primitives, different UX); pick the engine that aligns with your team’s operational model and toolchain. Surveys and guides from cloud providers document both tools as mainstream choices. (cncf.io)
Wrap-up: Why this pattern works
- Clear separation: CI produces artifacts; CD reconciles cluster state. That reduces blast radius, increases auditability, and makes rollbacks straightforward.
- Safety: Progressive delivery with Argo Rollouts or equivalent reduces risk for production releases.
- Scale: When your team count grows, GitOps’ repo-driven workflows and platform operators give consistent, auditable behavior across environments. Recent industry writing and tutorials show this is how many teams now run Kubernetes delivery pipelines. (teerakarna.github.io)
References (selected)
- GitHub Actions — Deploying with GitHub Actions (how‑tos, environments, protections). (docs.github.com)
- Argo CD: CI automation and GitOps model documentation. (argo-cd.readthedocs.io)
- Argo Rollouts: project repo and docs for progressive delivery. (github.com)
- Tutorials and end‑to‑end examples combining GitHub Actions and Argo CD. (teerakarna.github.io)
- CNCF and industry surveys on GitOps/CI adoption trends. (cncf.io)
This pattern — Actions produce artifacts and update Git, Argo CD/Flux pull and reconcile, and Argo Rollouts handle safe traffic shifts — gives you reproducible, observable, and controlled deployments for Kubernetes.