Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

Related Practices (16%)

Notes on related practices.

GitOps doesn’t replace these practices. It builds on them. The exam tests whether you know how they relate and where the boundaries are.

Topics

  • Configuration as Code (CaC)
  • Infrastructure as Code (IaC)
  • DevOps and DevSecOps
  • CI and CD

Configuration as Code (CaC)

  • Managing application and system configuration (settings, feature flags, env vars, k8s manifests, policies) as version-controlled files rather than manual changes in a UI or on a server
  • Examples: Kubernetes YAML, Helm values files, Ansible playbooks, Chef/Puppet, ConfigMaps
  • Benefits: repeatable, reviewable (PRs), auditable, consistent across environments
  • Relation to GitOps: CaC is a prerequisite. GitOps adds the pull-based agent and continuous reconciliation on top. CaC alone (e.g. running Ansible by hand from a repo) is not GitOps.

Infrastructure as Code (IaC)

  • Provisioning and managing infrastructure (networks, VMs, clusters, DNS, databases) through code instead of manual processes
  • Two styles
    • Declarative: describe the end state. Terraform/OpenTofu, CloudFormation, Bicep/ARM, Crossplane, Pulumi (declarative model in a general-purpose language).
    • Imperative: describe the steps. Shell scripts, CLI calls, some Ansible usage.
  • Mutable vs. immutable infrastructure
    • Mutable: patch servers in place → configuration drift over time
    • Immutable: replace rather than modify (new image, new VM, new pod). Fits GitOps well.
  • CaC vs. IaC: IaC provisions the platform; CaC configures what runs on it. The line is blurry and the exam may use them together.
  • Relation to GitOps
    • Traditional IaC (terraform apply from a pipeline) is push-based and runs once, so it’s not continuously reconciled
    • GitOps for infra: Crossplane (k8s CRDs that represent cloud resources, reconciled by controllers), Flux Terraform controller (tofu-controller), Cluster API
    • Terraform state file ≠ GitOps state store. The tfstate records actual state. The desired state is the .tf code in Git.

DevOps and DevSecOps

  • DevOps: a culture and set of practices that bring development and operations together to deliver software faster and more reliably
    • CALMS: Culture, Automation, Lean, Measurement, Sharing
    • DORA metrics: deployment frequency, lead time for changes, change failure rate, time to restore service (MTTR)
    • GitOps is one way to implement DevOps for deployments and operations. Git becomes the shared interface between dev and ops.
  • DevSecOps: build security into every stage of the lifecycle (“shift left”) instead of bolting it on at the end
    • SAST/DAST, dependency and image scanning (Trivy, Grype, Snyk)
    • Supply chain: SBOMs, signed images and commits (Sigstore/cosign), SLSA provenance
    • Policy as Code: OPA Gatekeeper, Kyverno. Enforce rules at admission time or in CI against the manifests in Git.
    • Secrets: never plaintext in Git. Use Sealed Secrets, SOPS, or External Secrets Operator.
  • How GitOps helps security
    • Pull model: no cluster credentials in CI
    • Every change goes through PR review → least privilege for humans (fewer people need kubectl write access)
    • Full audit trail in Git history
    • Drift correction reverts unauthorized manual changes

CI and CD

  • Continuous Integration (CI): merge code frequently, and automatically build and test every change
    • Output: a tested, versioned artifact (container image, chart)
    • Tools: GitHub Actions, GitLab CI, Jenkins, Tekton, Argo Workflows
  • Continuous Delivery: every change is deployable, but release to production needs a manual approval
  • Continuous Deployment: every change that passes the pipeline goes to production automatically, with no manual gate
  • Where GitOps fits: GitOps is a way to do the CD half
    • CI builds and pushes the image, then updates the image tag in the config repo (commit or PR)
    • The GitOps agent sees the new commit and pulls it into the cluster
    • Separation of concerns: CI writes to Git and the registry, CD reads from Git. CI never touches the cluster.
  • Image update automation can replace the “CI commits the tag” step: Argo CD Image Updater, Flux ImageRepository/ImagePolicy/ImageUpdateAutomation
dev → push code → CI (build, test, scan, push image)
                      └─ commit new tag → config repo (Git)
                                              ↑ pull
                                   GitOps agent (in cluster) → reconcile

Self-check

1. A team stores Terraform code in Git and runs terraform apply from a nightly Jenkins job. Is this GitOps?

Answer

No, not fully. It is declarative and versioned (IaC), but it is push-based and not continuously reconciled. Drift between runs isn’t corrected by an agent.

2. What is the difference between Continuous Delivery and Continuous Deployment?

Answer

Delivery: always releasable, with a manual approval to go to production. Deployment: automatically released to production with no manual gate.

3. Name two ways GitOps improves security posture.

Answer

Any two of: no cluster credentials in CI (pull model), all changes are reviewed through PRs, full audit trail, fewer humans need direct cluster write access, unauthorized drift is reverted automatically.