The Deployment strategy guide explains how to combine the stages in Pipeline to perform different deployment strategies.
A Blue/Green deployment is a deployment strategy that creates two identical environments. One environment (Blue) runs the current application version, and the other environment (Green) runs the new application version. You can use a Blue/Green deployment strategy to reduce deployment risk by increasing application availability and simplifying the rollback process in the event of a deployment failure. When testing is complete in the Green environment, application traffic is moved to the Green environment, and the Blue environment is decommissioned.
-vNNN
suffix. You must also include strategy.
spinnaker
. io/max-version-history
, traffic.spinnaker.io/load-balancers
among the annotations in the ReplicaSets.strategy.spinnaker.io/max-version-history
: Specifies the maximum number of ReplicaSets that Pipeline maintains. You must give a value of 2 or higher to enable blue/green deployments.traffic.spinnaker.io/load-balancers
: Specify the Service Object. Pipeline will modify the Pod's label to match the Service's Selector, enabling traffic to be delivered to your application. The Service Object you specify must have been created through Pipeline.Here's how to configure a pipeline that can do blue/green deployments. You can configure a pipeline by referring to thePipeline template guide.
Deploy -Add a Deploy stageand use the Pipeline to create the Service. Since you typically don't modify the Service when deploying an application, create a different pipeline than the application deployment pipeline to pre-create just the Service.
apiVersion: v1
kind: Service
metadata:
name: my-service
namespace: blue-green
spec:
selector:
frontedBy: my-service
ports:
- protocol: TCP
port: 80
Organize your pipeline in the following order: Deploy - Deploy stage > Deploy - Disable Stage. Configure the Deploy - Deploy Stage to deploy a new version of the application and the Deploy - Disable stage to select an older version of the application.
Deploy - Deploy stage
strategy.
spinnaker
. io/max-version-history
in the annotations must have a value of 2 or greater, and traffic.spinnaker.io/load-balancers
specifies the name of the Service created above.Other metadata, specs, etc. can be modified to suit your environment.
apiVersion: apps/v1
kind: ReplicaSet
metadata:
annotations:
strategy.spinnaker.io/max-version-history: "2"
traffic.spinnaker.io/load-balancers: '["service my-service"]'
labels:
app: myapp
name: myapp-frontend
namespace: blue-green
spec:
replicas: 4
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- image: nginx:stable-alpine3.17-slim
name: frontend