GitOps Promoter enables you to effectively manage the promotion of your GitOps manifests between environments. Organizations often relied on continuous integration (CI) tools to manage promotions imperatively, GitOps Promoter simplifies the promotion process by enabling a declarative process.
Red Hat OpenShift GitOps 1.22 introduces GitOps Promoter and Source Hydrator as Technology Preview features.
GitOps Promoter overview
The GitOps Promoter, in cooperation with the Source Hydrator, manages the promotion of environments from a don't-repeat-yourself (DRY) branch to preview branches, <env>-next, to finally the deployed branches <env>.
The DRY branch contains the manifests you want to deploy and typically uses a YAML management tool like Kustomize or Helm to avoid duplication (hence the DRY moniker). Anytime a commit is made in the DRY branch the Argo CD Source Hydrator automatically hydrates the change simultaneously to the preview branches <env>-next.
At this point, GitOps Promoter takes over to promote the change from the <env>-next branches to the <env> branches by creating and managing pull requests in the Git repository. Any proposed gating defined in the promotion strategy is applied to each environment and must pass before it moves on to the next environment.
Figure 1, a diagram from upstream architecture documentation, shows the complete end-to-end process.
Getting started with the GitOps Promoter
To start using GitOps Promoter, access to the desired source control management (SCM) must be configured, which varies depending on the desired SCM. For example, in GitHub this is done by creating a GitHub App (see upstream documentation on configuring various SCM providers).
To enable GitOps Promoter in Red Hat OpenShift GitOps, configure the Promoter in the Argo CD Custom Resource (CR). In the Technology Preview of GitOps Promoter, the operator does not create the required certificates automatically. You can use the command below to have Red Hat OpenShift generate a certificate, and this example uses such a certificate:
apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
name: openshift-gitops
namespace: openshift-gitops
spec:
...
promoter:
apiserver:
enabled: true
tls:
caSecretKey: tls.key
caSecretName: argocd-promoter-apiserver-tls
certSecretName: argocd-promoter-apiserver-tls
argoCDUIExtensionEnabled: true
enabled: true
webhook:
enabled: trueAdd an annotation with oc:
oc annotate service argocd-promoter-apiserver service.beta.openshift.io/serving-cert-secret-name=argocd-promoter-apiserver-tls
This example enables the GitOps Promoter extension using argoCDUIExtensionEnabled, which provides a UI in Argo CD. Figure 2 shows the UI during an active promotion:
The UI also includes a history of promotions showing the last 5 promotions that have occurred, as shown in figure 3:
Promotion strategy
GitOps Promoter uses a PromotionStrategy CR to declaratively define the environments in order of promotion.
apiVersion: promoter.argoproj.io/v1alpha1
kind: PromotionStrategy
metadata:
name: petclinic
namespace: petclinic-argocd
spec:
activeCommitStatuses:
- key: argocd-health-petclinic
environments:
- autoMerge: true
branch: environment/dev
- autoMerge: true
branch: environment/stage
- autoMerge: true
branch: environment/prod
gitRepositoryRef:
name: petclinicIn this example, there are 3 environments defined (dev, stage and prod) with automatic merging enabled. When automatic merging is enabled the GitOps Promoter automatically merges the pull request once all gating has passed. When a human-in-the-loop is required for change control purposes, disable automatic merging on the required environments.
Gating
Gating is an important feature for any promotion system as it ensures that a new release passes all required checks before a promotion occurs. GitOps Promoter supports gating through 2 types of CommitStatus CRs:
- Proposed: Commit statuses that must be passed before the release is promoted in an environment. Examples of these include linting and validating manifests, image vulnerabilities, and so on.
- Active: Commit statuses that can only be executed after the release has been deployed in an environment (for example, passing integration testing and health checks in an Argo CD application pass).
Only a proposed gate directly blocks promotion. An active gate blocks indirectly, because each environment after the first has an automatic proposed promoter-previous-environment gate.
GitOps Promoter includes a number of commit statuses by default.
Conclusion
GitOps Promoter is an important new feature that enables organizations to manage promotions declaratively in an efficient and effective manner. Feedback on this feature during the Tech Preview period would be greatly appreciated, and can help us deliver a robust promotion capability in Red Hat OpenShift GitOps.