Search…
GitOps
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
    1
    application_template: .release/application_template.yaml
    2
    environment_variables: .release/environment_variables.yaml
    Copied!
  • 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

1
##check if the Release GitOps files are modified
2
if release_files_modifies
3
4
#get the template from the repo
5
template_from_repo = app.template_from_repo
6
7
#loop through every app for this repo that matches the branch
8
repository.apps.with_branch(branch).each do |app|
9
previous_template = app.previous_template
10
11
##diff the template, if true, generate and save new templates
12
if diff(template_from_repo, previous_template)
13
generate_new_templates(app).save
14
end
15
end
16
17
#for every active environment for the repo that matches the branch
18
repository.active_environments.with_branch(branch).each do |env|
19
20
#transform app template to environment configuration
21
env_config = transform_app_template_to_env_config(env)
22
23
env_config.save
24
25
#if you want to deploy any matching envs, this setting must be true
26
if should_deploy_active_envs_that_track_branch_with_config_change?
27
deploy_env(env)
28
end
29
end
30
end
Copied!
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.
Last modified 3mo ago