This tutorial will show you how you can use a Building Block multiple times
in the same environment with the example of the Redis-HA Building Block.
Each Building Block instance should have its own dedicated directory in the control repository so that you their values can be changed independently.
The directory structure of the example's control repository is the following:
/ └── syseleven-redis-ha/ ├── .gitlab-ci.yml └── syseleven-redis-ha-2/ ├── .gitlab-ci.yml └── values-redis-ha.yaml .gitlab-ci.yml
.gitlab-ci.yml should look like this:
include: - /syseleven-redis-ha/.gitlab-ci.yml - /syseleven-redis-ha-2/.gitlab-ci.yml
The next step is to include a JobEnvironment template to each Building Block instance.
Since the instances are to be deployed in the same environment and Gitlab does not allow to include the same template in multiple Gitlab CI definitions, you have to include it once in one of your Building Block instances
.gitlab-ci.yml. The other instances will have to extend the job of the first one and do any necessary modifications.
The modifications that need to be made are the following:
include: - project: syseleven/building-blocks/helmfiles/redis-ha file: JobDevelopment.yaml ref: 1.33.0
And the second deployment
.syseleven-redis-ha-2-development: extends: .syseleven-redis-ha-development variables: NAMESPACE_REDIS_HA: syseleven-redis-ha-2 BASEDIR: $CI_PROJECT_DIR/syseleven-redis-ha-2 RELEASE_NAME_REDIS_HA: redis-ha-2 syseleven-redis-ha-diff-2-development: extends: - syseleven-redis-ha-diff-development - .syseleven-redis-ha-2-development syseleven-redis-ha-deploy-2-development: extends: - syseleven-redis-ha-deploy-development - .syseleven-redis-ha-2-development
After committing, you should get two Redis-HA deployments in different namespaces. If you want to deploy the same Building Block multiple times in the same namespace, you have to change default variables.