You think your configs are under control until someone merges a change and production quietly disagrees. Kustomize helps wrangle Kubernetes manifests, but versioning them across environments gets tricky fast. That’s where Mercurial can step in—quietly versioning, branching, and tracking your YAML reality without turning CI into a spaghetti factory. Together, Kustomize and Mercurial offer an elegant answer to the common “who changed what and why did pods vanish” problem.
Kustomize focuses on declarative configuration layering. It builds predictable Kubernetes manifests from a base plus overlays—dev, staging, prod—all without templating. Mercurial, on the other hand, is a distributed version control system known for simplicity, peer workflows, and atomic commits. Pairing them locks in the repeatability that makes infrastructure trustworthy. When you store and branch overlays with Mercurial, every manifest change becomes traceable, reproducible, and easy to roll back.
In a healthy Kustomize Mercurial workflow, each environment lives in its own branch or directory. Developers adjust patches or bases, commit with context, and trigger a build pipeline that regenerates and validates manifests. No guessing which overlay went live. The commit history becomes a literal change log for your cluster. CI tools run kustomize build on the exact state pulled from Mercurial, then push or validate against the target Kubernetes namespace.
Best practices hinge on consistency and context:
- Match Mercurial branches to environment overlays for clarity and rollback control.
- Use pre-commit hooks to run
kustomize buildchecks so broken manifests stay out of main. - Tag every release matching a Kustomize base to ensure auditability.
- Enforce RBAC rules so developers can view manifests without full cluster write access.
- Rotate any embedded secrets using external vaults to avoid version history leaks.
Those habits yield concrete benefits: