Description of ReleaseHub GitOps Workflow

Introduction to ReleaseHub GitOps

With Release you can use our UI to manage your Application Template and Environment Configurations along with corresponding environment variable files. But, Release also supports managing these configuration files in your Git repository. The requirements to use GitOps with Release are:

  • GitOps must be enabled for your application, please contact [email protected] to enable it

  • You need to add two lines to your .release.yaml file

    application_template: .release/application_template.yaml
    environment_variables: .release/environment_variables.yaml
  • You have two files (application_template.yaml and environment_variables.yaml) checked-in to your .release directory.

Figure 1. Both configuration files in the .release directory

Once these two requirements are met you will be able to manage your Release configurations via Git.

In the same way you work on features and bugs in branches, you can try new configuration in branches and when you merge back to you main branch, your changes will be included in your main branch.

Release Configuration Relationships

Figure 2. Simplified Release configuration relationships without environment variable configurations

When you create an application in Release we automatically create the first template for you. Every time an environment is created in Release for your application, this template will be used to generate the first configuration for that particular environment. There is also a Default Environment Variable file for the Application Template. These are both templates and used when the first Environment Configuration is created.

Whenever you save the Application Template or the Default Environment Variable file/s the major number of the configuration version is incremented.

Figure 3. Example of environments with different application templates as their parents

Whenever an environment is created the Application Template is used to generate the first Environment Configuration. The major number is based on the version of the Application Template and the minor number is the version of the Environment Configuration. The major number of the Environment Configuration never changes. Release does not merge changes from the Application Template into your Environment Configurations.

Whenever you save an Environment Configuration or Environment Variable file it increments the minor number.

GitOps Workflow

When using GitOps with Release the creation of the specific Environment Configurations is done automatically via a webhook processor that follows the workflow below in Figure 4. Any time you push to your repository, Release runs this workflow to decide if it should create new templates and/or configs, and ultimately should it deploy to any environments.

Figure 4. GitOps Flow Chart

Pseudocode for the GitOps Flow Chart

##check if the Release GitOps files are modified
if release_files_modifies
#get the template from the repo
template_from_repo = app.template_from_repo
#loop through every app for this repo that matches the branch
repository.apps.with_branch(branch).each do |app|
previous_template = app.previous_template
##diff the template, if true, generate and save new templates
if diff(template_from_repo, previous_template)
#for every active environment for the repo that matches the branch
repository.active_environments.with_branch(branch).each do |env|
#transform app template to environment configuration
env_config = transform_app_template_to_env_config(env)
#if you want to deploy any matching envs, this setting must be true
if should_deploy_active_envs_that_track_branch_with_config_change?

Release will create new configurations for your environments, but will not overwrite these attributes : 'context', 'domain', 'hostnames'

On every push to your repository, Release checks to see if there are any changes to the Release gitops files and reacts accordingly. This allows you to make changes to your templates on branches and merge the changes back to your main branch. In the same way you can work on your code in branches, you can do the same with your templates and environment variables.