1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-25 06:17:50 +00:00
catalog/task/blue-green-deploy/0.1
vinamra28 611101496d Use RBAC v1 instead of v1beta1 in tasks' tests
RBAC v1beta1 was deprecated in kubernetes and was removed in recent
versions.

Signed-off-by: vinamra28 <jvinamra776@gmail.com>
2022-06-14 08:20:02 +01: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 Use RBAC v1 instead of v1beta1 in tasks' tests 2022-06-14 08:20:02 +01:00
blue-green-deploy.yaml Add linux/amd64 platform annotation to the rest of the tasks 2021-10-29 17:08:38 +01:00
README.md Add linux/amd64 platform annotation to the rest of the tasks 2021-10-29 17:08:38 +01: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

Platforms

The Task can be run on linux/amd64 platform.

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