GitOps treats Git as the single source of truth: make changes by updating Git and let automation (CI/CD or a GitOps controller) reconcile those changes against your environments.
At a glance
IaC and CaC are complementary:- IaC provisions and maintains infrastructure resources (cloud services, clusters, networks).
- CaC configures operating systems, runtime services, and application settings on that infrastructure.
- In GitOps you typically use IaC to create the platform (clusters, VPCs, storage) and CaC to deploy and configure applications inside that platform (Kubernetes manifests, Helm charts, or configuration management scripts).
Key differences (quick reference)
Common tools and examples
Useful references:
- Terraform Basics Training Course
- Helm for Beginners
- GitOps with ArgoCD
- GitOps with FluxCD
- Learn Ansible Basics - Beginners Course
How IaC and CaC fit together in a GitOps workflow
A typical GitOps deployment separates concerns while keeping everything declarative in Git:- Author IaC to provision and update foundational resources:
- Create/modify Terraform or Pulumi modules to provision clusters, VPCs, and storage.
- Apply via CI/CD pipelines or an IaC operator.
- Store application configuration (CaC) in a Git repo watched by a GitOps controller:
- Kubernetes manifests,
ConfigMap/SecretYAMLs, or Helm charts live in a Git repository. - A GitOps controller (Argo CD, Flux) continuously reconciles cluster state with repo state.
- Kubernetes manifests,
- Reconcile and observe:
- CI/CD and GitOps controllers ensure the environment matches the desired state in Git.
- Rollbacks are performed by reverting commits in Git; automated reconciliation enforces the change.
Practical example (end-to-end)
- Provision infrastructure with IaC:
- Use Terraform to create an AWS EKS cluster, VPC, subnets, and IAM roles.
- Deploy and configure applications with CaC:
- Commit Helm charts or Kubernetes manifests to a
gitops-appsrepo. - The GitOps controller (Argo CD / Flux) watches
gitops-appsand applies manifests to the EKS cluster.
- Commit Helm charts or Kubernetes manifests to a
- Manage non-Kubernetes hosts:
- Use Ansible to provision OS settings, install monitoring agents, and configure bastion hosts; store playbooks in Git and run via CI/CD.
Workflow checklist
- Use Git as the source of truth for both infrastructure and configuration.
- Separate IaC and CaC repositories or directories to isolate responsibilities.
- Automate applying IaC changes (CI/CD, Terraform Cloud) and CaC reconciliation (Argo CD, Flux).
- Add CI checks (linting, tests) to prevent bad manifests from being applied.
- Tag or version releases so rollbacks are simple and auditable.
Analogy
- IaC is building the house: foundation, framing, wiring.
- CaC is furnishing and operating the house: appliances, thermostat settings, installed software.