Skip to main content

What are environment branches?

Understanding the environment branches pattern at the heart of Kargo Render begins with understanding some common difficulties encountered by GitOps practitioners.

Configuration management

To keep Kubernetes manifests concise and manageable, most GitOps practitioners incorporate some manner of configuration management tooling into their deployments. Kustomize, and Helm are two popular examples of such tools. Although they may employ widely varied approaches, tools in this class all enable the same fundamental capability -- maintaining a common set of "base" configuration that can be amended or patched in some way to suit each of the environments to which you might deploy your application.

Continuous delivery platforms, like Argo CD or Flux, commonly integrate with tools such as these. Argo CD, for instance, can easily detect the use of Kustomize or Helm and utilize embedded versions of those tools to render such configuration into plain manifests that are appropriate for a given environment. While, at a glance, this may seem convenient, relying on these integrations to perform just-in-time rendering of your manifests also poses some significant drawbacks. Notably:

  • The source of truth for your application's manifests (e.g. the main branch of your GitOps repository) can be obfuscated by your tooling. Since you don't see the plain manifests that will be applied to a given environment before they're applied, any notion of what you are actually deploying to that environment is dependent upon your ability to mentally render those manifests precisely as your tools will.

  • Upgrades to your CD platform may include upgrades to embedded configuration management tools. Changes in those tools may alter the interpretation of what you consider your source of truth. i.e. Plain manifests rendered from the contents of your main branch tomorrow could differ from what was rendered from the same input today. If your source of truth is subject to interpretation, that truth is not objective.

Environment branches

The environment branches pattern can alleviate the problems highlighted in the previous section. Implementing this pattern simply means the main branch of your application's GitOps repository ceases to be the source of truth and becomes, instead, an input to tools that will render the truth as plain manifests and persist them to environment-specific branches.

For any application, this pattern:

  • Creates a comprehensive, one-to-one mapping between branches of your GitOps repository and corresponding environments.

  • Deobfuscates what's deployed to each environment.

  • Puts you in control by making the most of GitOps. Apply features of your Git provider, such as pull requests, GitHub branch protection rules and GitHub Actions, to implement suitable policies and workflows on a per-environment basis.

Despite its many advantages, the environment branches pattern can be onerous to implement because it requires new automation to continuously render changes to your main branch into your environment branches. Kargo Render's singular goal is to answer those difficulties with an intuitive tool that puts the benefits of the environment branches pattern easily within reach for all GitOps practitioners.