|
| 1 | +--- |
| 2 | +title: "Blue-Green Synchronized Deployments" |
| 3 | +description: "Deploy groups of applications together using Blue-Green deployment strategy" |
| 4 | +--- |
| 5 | + |
| 6 | +# Blue-Green Synchronized Deployments in Porter |
| 7 | + |
| 8 | +Porter supports Blue-Green synchronized deployments to help you coordinate the rollout of tightly coupled applications. This guide explains how to configure and use this feature. |
| 9 | + |
| 10 | +## What is a Blue-Green Synchronized Deployment? |
| 11 | + |
| 12 | +Blue-Green deployment is a strategy that maintains two identical environments (blue and green) to minimize downtime and risk during application updates: |
| 13 | + |
| 14 | +- The **blue environment** is the currently active production environment |
| 15 | +- The **green environment** is the new version being deployed |
| 16 | + |
| 17 | +With Porter's synchronized Blue-Green deployments, you can coordinate multiple applications that need to be deployed together as a single unit. This is particularly useful for: |
| 18 | + |
| 19 | +- Microservices architectures where APIs must stay compatible |
| 20 | +- Frontend and backend components that need to maintain version compatibility |
| 21 | +- Any group of applications that must be deployed in sync to function properly |
| 22 | + |
| 23 | +## Configuring Blue-Green Deployments |
| 24 | + |
| 25 | +You can configure Blue-Green deployment synchronization in two ways: through your porter.yaml file or via the Porter dashboard. |
| 26 | + |
| 27 | +### Configuration in porter.yaml |
| 28 | + |
| 29 | +To enable Blue-Green deployments, add the `deploymentStrategy` section to your `porter.yaml` for each application you want to include in the synchronized group: |
| 30 | + |
| 31 | +```yaml |
| 32 | +version: v2 |
| 33 | +name: frontend |
| 34 | +services: |
| 35 | +- name: web |
| 36 | + run: node index.js |
| 37 | + type: web |
| 38 | + instances: 1 |
| 39 | + ... |
| 40 | +build: |
| 41 | + context: ./ |
| 42 | + method: docker |
| 43 | + dockerfile: ./Dockerfile |
| 44 | +deploymentStrategy: |
| 45 | + kind: blueGreen |
| 46 | + blueGreen: |
| 47 | + group: [name-for-the-group] |
| 48 | +``` |
| 49 | +
|
| 50 | +Key configuration points: |
| 51 | +- Set `deploymentStrategy.kind` to `blueGreen` |
| 52 | +- Use the `blueGreen.group` field to specify a group name |
| 53 | +- All applications with the same group name will be deployed together |
| 54 | +- Make sure all applications in the group are deployed with the same image tag |
| 55 | + |
| 56 | +### Configuration in the Porter Dashboard |
| 57 | + |
| 58 | +You can also configure Blue-Green deployments directly in the Porter dashboard: |
| 59 | + |
| 60 | +1. Navigate to your application dashboard |
| 61 | +2. Go to the "Settings" tab |
| 62 | +3. Find the "Blue-Green Deployment Group" section |
| 63 | +4. Select an existing group from the dropdown or type a new group name |
| 64 | +5. Save your changes |
| 65 | + |
| 66 | + |
| 67 | +*Blue-Green deployment group configuration in application settings* |
| 68 | + |
| 69 | +## Understanding Blue-Green Deployment Status |
| 70 | + |
| 71 | +When you deploy applications that are part of a Blue-Green group, the Porter dashboard will show detailed status information in the Activity feed. |
| 72 | + |
| 73 | + |
| 74 | +*Blue-Green deployment status displayed in the Activity feed* |
| 75 | + |
| 76 | +## Requirements and Limitations |
| 77 | + |
| 78 | +For Blue-Green synchronized deployments to work correctly: |
| 79 | + |
| 80 | +1. **Same Image Tag Requirement**: All applications in a Blue-Green group must be deployed with the same image tag. This is typically the commit SHA for applications deployed from GitHub. If you have a mono repo and your apps are deployed from the same branch, the default workflow files created by Porter should be comaptible with this feature. |
| 81 | + |
| 82 | +2. **Deployment Time Window**: All applications in a group must complete their deployment within a 20 min time window with the same image tag. If one application fails to deploy or takes too long, the entire group deployment is considered failed and reverted. |
| 83 | + |
| 84 | + |
| 85 | +## Example Use Case |
| 86 | + |
| 87 | +Consider a scenario with a frontend application and its backend API that must stay compatible: |
| 88 | + |
| 89 | +1. Configure both applications with the same Blue-Green group: |
| 90 | + |
| 91 | +```yaml |
| 92 | +# backend/porter.yaml |
| 93 | +version: v2 |
| 94 | +name: backend |
| 95 | +services: |
| 96 | +- name: web |
| 97 | + run: python server.py |
| 98 | + type: web |
| 99 | + instances: 1 |
| 100 | + ... |
| 101 | +build: |
| 102 | + context: ./ |
| 103 | + method: docker |
| 104 | + dockerfile: ./Dockerfile |
| 105 | +deploymentStrategy: |
| 106 | + kind: blueGreen |
| 107 | + blueGreen: |
| 108 | + group: primary |
| 109 | +
|
| 110 | +
|
| 111 | +# frontend/porter.yaml |
| 112 | +version: v2 |
| 113 | +name: frontend |
| 114 | +services: |
| 115 | +- name: web |
| 116 | + run: node index.js |
| 117 | + type: web |
| 118 | + instances: 1 |
| 119 | + ... |
| 120 | +build: |
| 121 | + context: ./ |
| 122 | + method: docker |
| 123 | + dockerfile: ./Dockerfile |
| 124 | +deploymentStrategy: |
| 125 | + kind: blueGreen |
| 126 | + blueGreen: |
| 127 | + group: primary |
| 128 | +``` |
| 129 | + |
| 130 | +2. When deploying a new version, Porter will: |
| 131 | + - Deploy both applications simultaneously |
| 132 | + - Wait for all applications to be ready before promoting traffic |
| 133 | + - Ensure both are successful before considering the deployment complete |
| 134 | + - Roll back all applications if any of them fail |
| 135 | + |
| 136 | +3. The dashboard will show the status of the synchronized deployment in real time, making it easy to identify any issues. |
| 137 | + |
| 138 | +By using Blue-Green synchronized deployments, you ensure that interdependent applications are always deployed in compatible versions, reducing the risk of downtime or broken functionality due to version mismatches. |
0 commit comments