Skip to content
DevOps AI ToolKit
All guides
AI for Automation By James Joyner IV · · 13 min read

A Practical GitOps Workflow Guide for Kubernetes Teams

Discover a practical GitOps workflow guide for Kubernetes teams to streamline deployments and ensure consistent infrastructure management.

A Practical GitOps Workflow Guide for Kubernetes Teams

GitOps means Git is the single source of truth for your infrastructure and application state, and an automated reconciler keeps your cluster matching whatever’s committed. For production Kubernetes, the recommended pattern is pull-based: an in-cluster operator like Argo CD watches your repo and pulls changes, rather than your CI system pushing credentials into the cluster. Push-based deployment is still fine for smaller non-Kubernetes targets or early prototypes where standing up an operator feels like overkill.

Two moves get you moving today:

  • Spin up a pilot repo with one real service, not a toy app.
  • Install an operator in a test cluster and point it at that repo before you touch production.

Key Takeaways

GitOps works because it makes Git the single enforceable source of truth, and a reconciling operator automatically closes the gap between declared and live cluster state.

PointDetails
DefinitionGitOps pairs a declarative Git repo with automated reconciliation to keep clusters matching committed state.
Production patternPull-based operators like Argo CD are recommended for Kubernetes; push suits simpler non-Kubernetes targets.
Repo structureSeparate config repos from app code and use folders, not branches, for environment variants.
SecurityRun policy-as-code checks in PRs and scope operator RBAC tightly before scaling.
Rollout planDevopsaitoolkit’s playbooks and templates help teams move from a one-service pilot to fleet-wide GitOps faster.

Table of Contents

What Is a GitOps Workflow, Really?

A working gitops workflow guide has to start with the four principles that actually define the pattern, because half the “GitOps” implementations I see skip one and wonder why reconciliation feels flaky.

  1. Declarative state. Your desired infrastructure and app config exists as data (YAML, Helm values, Kustomize overlays), not as a sequence of imperative commands.
  2. Versioned and immutable. Every state change lives in Git history, giving you a complete audit trail and a rollback target for free.
  3. Pulled automatically. An agent in the cluster retrieves the desired state rather than waiting for an external system to push it in.
  4. Continuously reconciled. Software constantly compares live state to declared state and corrects drift without a human triggering it.

The minimal toolchain behind this: a Git repo (or repos) for config, a CI system for building and testing, an operator or reconciler running in-cluster, an artifact registry for container images, and a monitoring stack that can see what the operator is doing. Miss the monitoring piece and you’ll find out about drift from a user complaint instead of a dashboard.

Immutability matters more than it sounds. If a manifest points at a floating tag like latest or an upstream Helm chart’s HEAD, your “declared state” isn’t actually declared. It’s a moving target that can silently change what gets deployed between one sync and the next. Argo CD’s documentation treats this reconciliation model as core to the pattern: the controller continuously monitors manifests in Git and drives the cluster toward that declared state, which only works if the declared state itself is pinned and stable.

How Does a GitOps Workflow Move From PR to Production?

The mechanics are the same whether you’re shipping a microservice or rotating a config map, and the steps rarely change once you’ve set them up correctly.

  1. A developer opens a pull request against the application source repo, changing code or a config value.
  2. CI builds the artifact, runs tests, and pushes an immutable image (tagged by commit SHA or digest) to your registry.
  3. A separate step (often a bot commit or a CI job) updates the image reference in the GitOps config repo, not the app repo.
  4. That change goes through its own PR against the config repo, ideally with policy checks running automatically.
  5. Once merged, the operator detects the diff between Git and cluster state and reconciles, pulling the new manifest in on its own schedule or via webhook trigger.
  6. The operator reports sync status and health back to your dashboards, closing the loop.

For Kubernetes, pull-based reconciliation is the pattern worth defaulting to across dev, stage, and prod. Push-based CI deployment (a pipeline running kubectl apply or helm upgrade directly) still shows up for non-Kubernetes targets like serverless functions or bare VMs, where running a persistent operator doesn’t make sense.

Pro Tip: Never let CI write directly to your image tag inside the same repo it just built from. That circular write pattern is a common cause of infinite CI loops, and it also muddies your audit trail because a single commit ends up representing both a code change and a deployment change.

Hands with DevOps checklist near server rack

How Should You Organize GitOps Repositories?

Separate your configuration repo from your application source code. Argo CD’s own best practices call this out specifically: mixing them causes CI loops, muddies audit history, and makes it hard to give reviewers access to deployment config without also handing them commit rights on app code.

Beyond that split, a few structural calls matter:

  • Mono-repo for config works well for small to mid-size teams. One repo, folders per environment, easy to reason about.
  • Multi-repo per team or service scales better once you have dozens of teams who need independent access control and don’t want to review each other’s diffs.
  • Folder-based environment variants (a prod/, staging/, dev/ structure inside one app’s config) tend to beat branch-based environments. Google Cloud’s GitOps guidance favors folders because promotions become explicit diffs between directories instead of branch merges that can drag in unrelated changes.
  • Pin every upstream dependency. Helm chart versions, Kustomize bases, container digests. Reference them by SHA or tag, never by HEAD or latest.

Get this layout wrong early and you’ll be doing a painful repo migration later, usually right when you can least afford the disruption.

What Does a GitOps Operator Actually Need to Do?

An operator’s job sounds simple: watch Git, reconcile cluster state. In practice, the responsibilities that separate a solid production setup from a shaky one are more specific.

  • Continuous reconciliation, not just a one-time apply on webhook trigger. It needs to keep polling or listening so drift gets caught even when nobody touched Git.
  • Drift detection with visible diffs. You want to see exactly what changed between live and declared state, not just a binary “out of sync” flag.
  • Multi-cluster awareness if you’re running more than one cluster, so one control plane (or a consistent pattern across several) manages fleet-wide state.
  • Health analysis beyond pod status. A deployment can be “synced” and still be functionally broken if health checks only look at replica counts.

When evaluating operator options, weigh templating support (Helm, Kustomize, plain YAML), SSO and RBAC integration so access maps to your existing identity provider, observability hooks that expose Prometheus metrics or emit events your alerting can consume, and how it behaves at scale across dozens of applications and clusters. Red Hat’s framing of GitOps describes this pairing well: a declarative Git repo plus an operator like Argo CD achieving continuous reconciliation and auditability together, neither one sufficient alone.

Where Does CI End and GitOps Begin?

The cleanest mental model: CI builds artifacts, GitOps manages deployment state. Once your pipeline produces a tested, immutable image, its job is done. Everything downstream, from environment promotion to cluster reconciliation, belongs to the GitOps flow.

Promotion typically works one of a few ways:

  • A bot updates the image tag in a lower environment’s manifest automatically after a successful build.
  • Promoting to the next environment means copying that same pinned reference into the next folder, not rebuilding anything.
  • Policy gates (manual approval, automated test suite, or a canary analysis) sit between environments to block a bad promotion.

For progressive delivery, wire canary or blue/green templates into your pipeline so a percentage of traffic shifts gradually, with automated verification checks deciding whether to continue the rollout or roll back. Our post on deploying to Kubernetes from GitLab CI walks through wiring this handoff without the pipeline and the operator stepping on each other.

How Do You Secure a GitOps Pipeline?

Security in a GitOps flow isn’t a separate layer bolted on afterward. It has to live in the same PR workflow that ships every other change.

  • Run policy-as-code in PR checks. Tools like OPA or Kyverno can catch a missing resource limit or an over-permissioned service account before it merges, not after it’s live. HashiCorp’s guidance on GitOps treats this shift-left validation as standard practice, and teams that enforce it early see meaningfully fewer drift and misconfiguration incidents.
  • Manage secrets outside plain manifests. Vault, Sealed Secrets, or OIDC-based short-lived credentials all keep sensitive values out of Git history. Our guide on secrets management with OIDC in GitLab CI covers the credential rotation piece specifically.
  • Enforce branch protections and scoped RBAC for the operator’s own service account, so the thing reconciling your cluster can’t touch resources outside its lane.
  • Keep an audit trail that ties every cluster change back to a commit and an approver.

Pro Tip: Give your operator’s service account the narrowest RBAC scope that still lets it do its job. A reconciler with cluster-admin is a single misconfigured manifest away from a very bad day.

How Do You Catch Drift Before It Becomes an Incident?

Detecting drift is only useful if it’s connected to something that tells a human, or automatically corrects the problem.

  1. Wire operator events into your observability stack. Sync status, health checks, and drift events should show up as metrics and logs, not just in a dashboard nobody watches. Datadog’s guidance on GitOps makes the case for connecting deployments to metrics and logs rather than trusting Kubernetes health checks alone.
  2. Define verification around SLIs and SLOs, not just “did the pod come up.” A pod can be running and still serving errors.
  3. Trigger automated rollback when verification fails, rather than paging someone to eyeball a dashboard at 2 a.m.
  4. Keep a break-glass runbook for manual intervention, with scoped tokens that expire automatically and a mandatory post-incident review so emergency access doesn’t quietly become permanent policy.

If you’ve hit a stuck sync loop before, our writeup on an OutOfSync drift loop walks through a real failure pattern and how to break it.

What Does a Phased GitOps Rollout Actually Look Like?

Skipping straight to fleet-wide GitOps is how most rollouts stall. A phased plan with measurable gates keeps the blast radius small while you learn what breaks.

  1. Phase 0, pilot. One service, one cluster, one operator instance. Confirm reconciliation works end to end before adding scope.
  2. Phase 1, add environments. Extend the pilot’s pattern to staging and production folders for that same service, testing your promotion flow.
  3. Phase 2, add policy and secrets management. Layer in PR policy checks and a real secrets pattern once the basic loop is stable.
  4. Phase 3, scale to the fleet. Onboard additional services and teams, standardizing repo layout and RBAC as you go.

Harness’s GitOps guidance backs this staged approach specifically because it gives you standardization gates instead of forcing every team to reinvent conventions independently.

Before scaling past the pilot, confirm your checklist: repo layout finalized, CI updated to write pinned references, operator installed with scoped RBAC, policy checks running on every PR, monitoring wired to operator events, and a tested rollback path. Actually trigger a rollback in the pilot before you trust it in production. A rollback procedure that’s never been exercised is a hypothesis, not a runbook.

PointDetails
Start with one servicePilot a single service and cluster before expanding scope, per phased rollout guidance.
Separate config from codeUse distinct repos to avoid CI loops and keep a clean audit trail.
Pin everythingReference images and charts by SHA or tag, never HEAD or latest.
Shift security leftRun OPA or Kyverno checks in PRs before merge, not after deployment.
Test rollback before scalingExercise your rollback path in the pilot phase, not for the first time in an incident.

What Should You Watch for When Running GitOps Day to Day?

Two mistakes account for most of the GitOps incidents worth writing up: unpinned upstream references that silently change what “declared state” means, and a config repo pointed at a floating branch HEAD that drifts underneath you.

  • Pin Helm chart versions and Kustomize bases explicitly, every time, no exceptions for “just testing.”
  • Never reference an upstream repo by HEAD in a base; a maintainer’s unrelated commit shouldn’t be able to change your production manifest.
  • Keep a short internal runbook for common drift scenarios so on-call doesn’t have to reconstruct the fix from scratch each time.

If you’re standing up this pattern for the first time, our deeper walkthroughs on GitOps for infrastructure and Terraform drift detection cover the pieces this guide only has room to summarize.

What I’d Tell a Team Starting Their First GitOps Rollout

Most teams overreach by trying to build fleet-scale tooling before they’ve proven the basic loop works on one service. Start simple, accept a plainer pattern for speed early, and invest in scaling infrastructure only once the pilot has actually broken something and you’ve fixed it.

— James

Speed Up Your GitOps Rollout With Ready-Made Playbooks

Building the pieces in this guide from scratch, repo layout, policy checks, rollback runbooks, takes real engineering time most platform teams don’t have to spare. Devopsaitoolkit gives you downloadable GitOps playbooks and automation templates built around the patterns covered here, so your team skips the trial-and-error phase and gets a working pilot running in days instead of weeks.

Devopsaitoolkit

If your team needs more than templates, whether that’s a second set of eyes on your operator setup, a security review of your policy gates, or a full pilot-to-fleet rollout plan, Devopsaitoolkit also offers direct consulting for GitOps and OpenStack automation. For a look at the AI-assisted tooling built specifically for engineers running Kubernetes and GitLab pipelines, check the AI DevOps toolkit or see current plans on the pricing page. Start by browsing the Devopsaitoolkit homepage and download a playbook to get your pilot repo moving this week.

Where to Learn More About GitOps Operators

Sources

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,778 DevOps AI prompts
  • One practical workflow email per week
Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.