mirror of
https://github.com/tektoncd/catalog.git
synced 2024-11-22 06:02:51 +00:00
a861887585
* Update all images to use the latest stable 4.6 * Modify the task using :latest to pin it to 4.6 Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com> |
||
---|---|---|
.. | ||
samples | ||
support | ||
tests | ||
blue-green-deploy.yaml | ||
README.md |
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 theparams
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/master/task/blue-green-deploy/0.1/blue-green-deploy.yaml
Installing the ClusterRoleBinding
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/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 thisworkspace
. (Default: emptyDir:{} in casekubeconfig
is not mounted)
Parameters
- SERVICE_NAME: The service name pointing to the existing deployment. (Note: The service name for the new deployment should be same)
- NEW_VERSION: The version of the deployment to be deployed in the green/blue zone
- MANIFEST: The deployment manifest URL file path provided in case the manifest is present on Github. (Example: "https://raw.githubusercontent.com/tektoncd/catalog/master/task/blue-green-deploy/0.1/samples/v1-deploy/blue-deployment.yaml")
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/master/task/blue-green-deploy/0.1/samples/v2-deploy/green-deployment.yaml"
workspaces:
- name: manifest-dir
emptyDir: {}
Using ConfigMap
- Create the
ConfigMap
kubectl create configmap manifests --from-file="green-deployment.yaml"
- 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