From 1c8025ce8df86077955185c2225d9c370cefcd70 Mon Sep 17 00:00:00 2001 From: willb Date: Thu, 31 May 2018 16:09:45 -0400 Subject: [PATCH 1/3] add canary deploy to pipeline --- Jenkinsfile | 23 +++++++++++++++++ train-schedule-kube-canary.yml | 45 ++++++++++++++++++++++++++++++++++ train-schedule-kube.yml | 1 + 3 files changed, 69 insertions(+) create mode 100644 train-schedule-kube-canary.yml diff --git a/Jenkinsfile b/Jenkinsfile index 7878be11..3ac7d574 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,13 +38,36 @@ pipeline { } } } + stage('CanaryDeploy') { + when { + branch 'master' + } + environment { + CANARY_REPLICAS = 1 + } + steps { + kubernetesDeploy( + kubeconfigId: 'kubeconfig', + configs: 'train-schedule-kube-canary.yml', + enableConfigSubstitution: true + ) + } + } stage('DeployToProduction') { when { branch 'master' } + environment { + CANARY_REPLICAS = 0 + } steps { input 'Deploy to Production?' milestone(1) + kubernetesDeploy( + kubeconfigId: 'kubeconfig', + configs: 'train-schedule-kube-canary.yml', + enableConfigSubstitution: true + ) kubernetesDeploy( kubeconfigId: 'kubeconfig', configs: 'train-schedule-kube.yml', diff --git a/train-schedule-kube-canary.yml b/train-schedule-kube-canary.yml new file mode 100644 index 00000000..1d829372 --- /dev/null +++ b/train-schedule-kube-canary.yml @@ -0,0 +1,45 @@ +kind: Service +apiVersion: v1 +metadata: + name: train-schedule-service-canary +spec: + type: NodePort + selector: + app: train-schedule + track: canary + ports: + - protocol: TCP + port: 8080 + nodePort: 8081 + +--- + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: train-schedule-deployment-canary + labels: + app: train-schedule +spec: + replicas: $CANARY_REPLICAS + template: + metadata: + labels: + app: train-schedule + track: canary + spec: + containers: + - name: train-schedule + image: $DOCKER_IMAGE_NAME:$BUILD_NUMBER + ports: + - containerPort: 8080 + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 15 + timeoutSeconds: 1 + periodSeconds: 10 + resources: + requests: + cpu: 200m \ No newline at end of file diff --git a/train-schedule-kube.yml b/train-schedule-kube.yml index c7277658..18138567 100644 --- a/train-schedule-kube.yml +++ b/train-schedule-kube.yml @@ -25,6 +25,7 @@ spec: metadata: labels: app: train-schedule + track: stable spec: containers: - name: train-schedule From 59088f384eb497964bba377f0349eba201bc3b32 Mon Sep 17 00:00:00 2001 From: whboyd Date: Fri, 1 Jun 2018 12:31:51 -0400 Subject: [PATCH 2/3] Update train-schedule-kube-canary.yml --- train-schedule-kube-canary.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/train-schedule-kube-canary.yml b/train-schedule-kube-canary.yml index 1d829372..9922ce94 100644 --- a/train-schedule-kube-canary.yml +++ b/train-schedule-kube-canary.yml @@ -22,6 +22,10 @@ metadata: app: train-schedule spec: replicas: $CANARY_REPLICAS + selector: + matchLabels: + app: train-schedule + track: canary template: metadata: labels: @@ -42,4 +46,4 @@ spec: periodSeconds: 10 resources: requests: - cpu: 200m \ No newline at end of file + cpu: 200m From 0f01d170a46e14f92d3c4e570806009a6400fe77 Mon Sep 17 00:00:00 2001 From: whboyd Date: Thu, 20 Jun 2019 11:59:46 -0400 Subject: [PATCH 3/3] Update train-schedule-kube-canary.yml --- train-schedule-kube-canary.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train-schedule-kube-canary.yml b/train-schedule-kube-canary.yml index 9922ce94..697f891e 100644 --- a/train-schedule-kube-canary.yml +++ b/train-schedule-kube-canary.yml @@ -14,7 +14,7 @@ spec: --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: train-schedule-deployment-canary