Deploy a service to Kubernetes.
To use this step, the service should already be deployed in the Kubernetes cluster. This step will re-deploy your existing service.
#Syntax
YAML
steps:
step-name:
type: deploy
target: kubernetes
cluster: my-kubernetes-cluster
service: my-app
tag: v0.1.0
Parameter | Description | Required |
---|---|---|
title | The display name of the step. | No |
type | The type of the Microtica built-in step. Should always be deploy for this type of step. | Yes |
target | Should always be kubernetes for this type of step. | Yes |
cluster | The name of the existing Kubernetes cluster. | Yes |
service | The name of the existing service to be deployed. | Yes |
tag | Docker image tag to be applied with the deployment. Default: latest | No |
branch_filter | If specified, deployment will be executed only if the pipeline was triggered by push on the matched branch. Otherwise, deployment will be triggered on every pipeline execution. | No |
#Re-deploy an existing service
We assume that service with name my-app is already being deployed in the Kubernetes cluster with name my-cluster. You can read more about how to create and deploy services here.
In the following example we deploy a service on Kubernetes with an image tag that’s previously been built and pushed to a remote Docker registry.
microtica.yaml
steps:
Clone:
type: git-clone
PushDockerImage:
type: docker-push
image_name: "microtica/my-app"
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
Deploy:
type: deploy
target: kubernetes
cluster: my-cluster
service: my-app
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
To dynamically deploy the image that’s just been built, we use MIC_PIPELINE_EXECUTION_ID as a reference value while pushing the image on a remote Docker registry and use the same value when deploying the service.
#Trigger deploy for a specific branch
To trigger a deploy only if the pipeline was triggered by push on a specific branch, we can use the branch_filter parameter to achieve that.
Basically, if you specify develop as a value, the deployment will be triggered only if push was made on the develop branch.
If branch_filter is not specified, deploy will be triggered on each pipeline execution.
steps:
Clone:
type: git-clone
PushDockerImage:
type: docker-push
image_name: "microtica/my-app"
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
Deploy:
type: deploy
target: kubernetes
cluster: my-cluster
service: my-app
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
branch_filter: develop