-
Notifications
You must be signed in to change notification settings - Fork 43
Deployment Strategies
- Create a new Application with name "Deployment-strategies-TEAM-NAME"
- Create a pipeline "Service" to Deploy a service which will be used to access the application.
In this pipeline, click on the Add Stage button
In the Type field, select Deploy (Manifest)
This will present some new sections and fields
Go to the Deploy (Manifest) Configuration and Basic Settings section, in Account select eks-stg
In the Manifest Configuration section, and for the Manifest Source, select Artifact
In the Manifest Artifact select your deploy-microservice.yml file
In the Required Artifacts to Bind select your service artifact binding
For reference following is the service which will be deployed
apiVersion: v1
kind: Service
metadata:
labels:
app: sandy-microservice-service
name: sandy-microservice-service
namespace: microservices
spec:
ports:
- name: web
port: 30201
protocol: TCP
targetPort: 8080
selector:
app: sandy-microservice
source: demo
trigger the service pipeline.
- Create a pipeline "red-black Deployment" to Deploy a replica-set of your required application
In your pipeline, click on the Add Stage button
In the Type field, select Deploy (Manifest)
This will present some new sections and fields
Go to the Deploy (Manifest) Configuration and Basic Settings section, in Account select eks-stg
In the Manifest Configuration section, and for the Manifest Source, select Artifact
In the Manifest Artifact select your deploy-microservice.yml file
In the Required Artifacts to Bind select your replica-set artifact binding
For reference following is the replica set which will be deployed
apiVersion: apps/v1
kind: ReplicaSet
metadata:
labels:
app: nginx
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- image: 702037529261.dkr.ecr.us-west-2.amazonaws.com/tony-stark-microservice
name: web
Remember to replace the image with the one which you have pushed into ECR and also dont mention the tag.
- configure an automated trigger in that application.
In Automated Triggers section, click Add Trigger
In the Type drop-down field, select Docker Registry
In the Registry Name field, select my-ecr-registry
In the Image field, select your image
Trigger the pipeline with image tag one. and check the infrastructure-Clusters section. you will find a Replicaset v000 deployed over there.
- Implement red-black Deployment Strategy
5.a enabling red-black Deployment
in the Deploy (Manifest) stage, enable the "Rollout Strategy Options"
select the namespace in which you had deployed the Service (microservice in our case)
select the service
select "red-black" as Strategy
5.b configure manual judgement stage
Select the Deploy (Manifest) stage
Click the Add Stage button
Select Manual Judgement
Add some descriptions in the Instructions field
add "rollback" and "continue" in option field of "Judgment Inputs"
5.c configure roll-back stage
Select the Manual judgement stage
Click the Add Stage button
Select "Disable (Manifest)"
Configuration section select eks-stg as Account
namespace - "microservice", Kind - "replica set", selector - "Choose a target dynamically"
select your replica set in the drop of cluster, and select "newest" as target
in Execution Options , add ${#judgment('Manual Judgment').equals('rollback')} as "Conditional on Expression"
5.d configure "continue" stage
Select the Manual judgement stage
Click the Add Stage button
Select "Delete (Manifest)" Configuration
Configuration section select eks-stg as Account
namespace - "microservice", Kind - "replica set", selector - "Choose a target dynamically"
select your replica set in the drop of cluster, and select "second newest" as target
in Execution Options , add ${#judgment('Manual Judgment').equals('continue')} as "Conditional on Expression"
- before starting the pipeline check the infrastructure/cluster section. there will be one replicaset with version v000 which was deployed in step 4.
6.a "Continue" scenario start the execution of the "red-black deployment" pipeline and select "continue" in the drop down.
check the infrastructure/cluster section again. This time there will be only 1 replicaset v001. which means spinnaker has deleted v000.
6.b "roll back" scenario start the execution of the "red-black deployment" pipeline again and select "rollback" in the drop down.
check the infrastructure/cluster section again. This time there will be 2 replicaset v001 and v002 and v001 will be disabled.