L
L
Lagoon
Search…
Active/Standby
Lagoon supports active/standby (also known as blue/green) deployments.
How to Run Blue-Green Deployments with Active/Standby on Lagoon

Configuration

To change an existing project to support active/standby you'll need to configure some project settings with the Lagoon API.
    productionEnviromment should be set to the branch name of the current active environment.
    standbyProductionEnvironment should be set to the branch name of the current environment that is in standby.
1
mutation updateProject {
2
updateProject(input:{
3
id:1234
4
patch:{
5
productionEnvironment:"production-brancha"
6
standbyProductionEnvironment:"production-branchb"
7
}
8
}){
9
standbyProductionEnvironment
10
name
11
productionEnvironment
12
}
13
}
Copied!

.lagoon.yml - production_routes

To configure a project for active/standby in the .lagoon.yml file, you'll need to configure the production_routes section with any routes you want to attach to the active environment, and any routes to the standby environment. During an active/standby switch, these routes will migrate between the two environments.
If you have two production environments, production-brancha and production-branchb, with the current active production environment as production-brancha then:
    Routes under production_routes.active will direct you to production-brancha.
    Routes under production_routes.standby will direct you to production-branchb.
During an active/standby switch, the routes will swap:
    Routes under production_routes.active will direct you to production-branchb.
    Routes under production_routes.standby will direct you to production-brancha.
.lagoon.yml
1
production_routes:
2
active:
3
routes:
4
- nginx:
5
- example.com:
6
tls-acme: 'false'
7
- active.example.com:
8
tls-acme: 'false'
9
standby:
10
routes:
11
- nginx:
12
- standby.example.com:
13
tls-acme: 'false'
Copied!
Any routes that are under the section environments..routes will not be moved as part of active/standby. These routes will always be attached to the environment as defined. Ensure that if you do need a specific route to be migrated during an active/standby switch, that you remove them from the environments section and place them under the production_routes section specific to if it should be an active or standby route. See more about routes in .lagoon.yml.

Triggering a switch event

via the UI

To trigger the switching of environment routes, you can visit the standby environment in the Lagoon UI and click on the button labeled Switch Active/Standby environments. You will be prompted to confirm your action.
Once confirmed, it will take you to the tasks page where you can view the progress of the switch.

via the API

To trigger an event to switch the environments, run the following graphQL mutation. This will tell Lagoon to begin the process.
1
mutation ActiveStandby {
2
switchActiveStandby(
3
input:{
4
project:{
5
name:"drupal-example"
6
}
7
}
8
){
9
id
10
remoteId
11
}
12
}
Copied!
A task is created in the current active environment tasks tab when a switch event is triggered. You can check the status of the switch here.
Using the remoteId from the switchActiveStandby mutation, we can also check the status of the task.
1
query getTask {
2
taskByRemoteId(id: "<remoteId>") {
3
id
4
name
5
created
6
started
7
completed
8
status
9
logs
10
}
11
}
Copied!

drush aliases

By default, projects will be created with the following aliases that will be available when active/standby is enabled on a project.
    lagoon-production
    lagoon-standby
The lagoon-production alias will point to whichever site is defined as productionEnvironment, and lagoon-standby will always point to the site that is defined as standbyProductionEnvironment.
These aliases are configurable by updating the project. Be aware that changing them may require you to update any scripts that rely on them.
1
mutation updateProject {
2
updateProject(input:{
3
id:1234
4
patch:{
5
productionAlias:"custom-lagoon-production-alias"
6
standbyAlias:"custom-lagoon-standby-alias"
7
}
8
}){
9
productionAlias
10
name
11
standbyAlias
12
}
13
}
Copied!

Notes

When the active/standby trigger has been executed, the productionEnvironment and standbyProductionEnvironments will switch within the Lagoon API. Both environments are still classed as production environment types. We use the productionEnvironment to determine which one is labelled as active. For more information on the differences between environment types, read the documentation for environment types
1
query projectByName {
2
projectByName(name:"drupal-example"){
3
productionEnvironment
4
standbyProductionEnvironment
5
}
6
}
Copied!
Before switching environments:
1
{
2
"data": {
3
"projectByName": {
4
"productionEnvironment": "production-brancha",
5
"standbyProductionEnvironment": "production-branchb"
6
}
7
}
8
}
Copied!
After switching environments:
1
{
2
"data": {
3
"projectByName": {
4
"productionEnvironment": "production-branchb",
5
"standbyProductionEnvironment": "production-brancha"
6
}
7
}
8
}
Copied!
Last modified 9mo ago