1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-21 05:55:35 +00:00
catalog/task/blue-green-deploy/0.1
Vincent Demeester d93795673c Update self reference from master to main 🧙
And update references to community, pipeline, etc. too.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
2021-03-19 11:09:49 +00:00
..
samples Add tests for Blue Green Deployment Task 2020-11-03 08:29:22 +00:00
support Add Blue-Green Deployment using K8s 2020-07-30 14:38:02 +01:00
tests Add tests for Blue Green Deployment Task 2020-11-03 08:29:22 +00:00
blue-green-deploy.yaml Update all images using openshift to latest stable 4.6 2021-01-05 10:15:11 +00:00
README.md Update self reference from master to main 🧙 2021-03-19 11:09:49 +00:00

Blue Green Deploy on Kubernetes

The following task can help you to deploy an application using the Blue-Green deployment strategy. This task gives you the flexibility to deploy a version of the application from the blue zone to the green zone without disturbing the previous version in the blue zone. It works by making the service point to the newer version of the application deployed.

  • If you are deploying the first version of the application then it will go into the blue zone and for that you need to provide deployment and service manifests via the workspaces and in the params the service name and version. Sample Kubernetes manifests for version v1 can be found here.
  • For further new deployments, it will get deployed in the other zone and then the current service will now point to the new deployment. For example if we have a deployment running in the blue zone then we will deploy the next deployment in the green zone and make the service point to the green zone or vice versa.

Installing the Task

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/blue-green-deploy/0.1/blue-green-deploy.yaml

Installing the ClusterRoleBinding

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/blue-green-deploy/0.1/support/clusterrolebinding.yaml

Workspaces

  • manifest-dir: Manifest files can be provided via the workspaces.(Default: emptyDir:{} in case no manifest is provided)
  • kubeconfig-dir: If you want to deploy you application to another cluster then you can mount your kubeconfig file via this workspace. (Default: emptyDir:{} in case kubeconfig is not mounted)

Parameters

Usage

This TaskRun runs the Task to deploy the given Kubernetes resource in the green/blue zone and toggle the service to point to the new zone.

Without using ConfigMap

TaskRun :-

apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: blue-green-deploy-run
spec:
  taskRef:
    name: blue-green-deploy-k8s
  params:
    - name: SERVICE_NAME
      value: myapp
    - name: NEW_VERSION
      value: v2
    - name: MANIFEST
      value: "https://raw.githubusercontent.com/tektoncd/catalog/main/task/blue-green-deploy/0.1/samples/v2-deploy/green-deployment.yaml"
  workspaces:
    - name: manifest-dir
      emptyDir: {}

Using ConfigMap

  1. Create the ConfigMap
kubectl create configmap manifests --from-file="green-deployment.yaml"
  1. TaskRun:-
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: blue-green-deploy-run
spec:
  taskRef:
    name: blue-green-deploy-k8s
  params:
    - name: SERVICE_NAME
      value: myapp
    - name: NEW_VERSION
      value: v2
  workspaces:
    - name: manifest-dir
      configMap:
        name: manifests