In Kong Gateway terms, for a blue-green deployment you need the following:
- A Gateway Service and a Route
- A
blue
Upstream and a green
Upstream
- Targets configured for each Upstream
You can then toggle the host
parameter in the Gateway Service to either Upstream as needed, effectively switching from blue to green and back with one command.
For example, given the following basic Gateway Service, Route, and blue
and green
Upstreams:
services:
- name: example-service
host: blue
path: "/anything"
routes:
- name: example-route
hosts:
- "example.domain.com"
upstreams:
- name: blue
targets:
- target: 192.168.34.15:80
weight: 100
- target: 192.168.34.16:80
weight: 50
- name: green
targets:
- target: 192.168.34.17:80
weight: 100
- target: 192.168.34.18:80
weight: 100
This example starts with the Gateway Service pointing to the blue
Upstream.
To activate the blue-green switch, you just need to update the host
property of the existing Gateway Service.
For example, switch the Service host
parameter to green
:
services:
- name: example-service
host: green
In this case, the example uses the default round-robin load balancing,
so the green
Targets will be queued up in the order they were originally accessed, with weighting applied.
You can switch back and forth between the blue
and the green
Upstreams at any time, and the switch will be immediate.