Deploy
Deploying to Kubernetes from a Codefresh pipeline
The Deploy step can be used as a step to deploy a pre-built Docker image to a cluster
This step allows to (re)deploy a Kubernetes application in your cluster
It has two modes:
- Using the
service
option. In this case it will redeploy to an existing service/deployment in your cluster . Codefresh will automatically update the service/deployment with the new docker image. - Using the
file_path
option. In this case you provide your own Kubernetes manifest and Codefresh deploys it as-is. It is your own responsibility to do custom replacements here (for example using awk, sed or yq). Thedeploy
step also uses the Codefresh templating mechanism behind the scenes if you want to take advantage of it. For a full templating solution we also suggest you look at Helm.
You need to define either one of these fields in the deploy step. If you define service
you also can select the exact Docker image
with the candidate
field (otherwise Codefresh will just reuse the docker image defined in the existing deployment)
Usage
YAML
Fields
Field | Description | Required/Optional/Default |
---|---|---|
title |
The free-text display name of the step | Optional |
description |
A basic, free-text description of the step. | Optional |
stage |
Parent group of this step. See using stages for more information. | Optional |
kind |
Currently only kubernetes is supported |
Required |
cluster |
Name of your K8s cluster as found in the dashboard | Required |
namespace |
Namespace where the deployment will take place | Required |
service |
Name of the existing service that will updated. You need to provide service OR file_path |
Required/Optional |
file_path |
A deployment manifest. You need to provide service OR file_path |
Required/Optional |
timeout |
Seconds to wait for the deployment to be completed. Default is 120 seconds | Default |
candidate |
Docker image that will be deployed. Only valid if service is defined. Should contain image and name of registry as it appears in the registry integration page. |
Optional |
fail_fast |
Determines pipeline execution behavior in case of step failure.
|
Optional |
strict_fail_fast |
Specifies how to report the Build status when fail_fast is set to false .NOTE: Requires Runner chart upgrade to v6.3.9 or higher. You can set the Build status reporting behavior at the root-level or at the step-level for the pipeline.
NOTES: strict_fail_fast does not impact the Build status reported for parallel steps with fail_fast enabled. Even if a child step fails, the parallel step itself is considered successful. See also Handling error conditions in a pipeline. |
Optional |
when |
Define a set of conditions which need to be satisfied in order to execute this step. You can find more information in the conditional execution of steps article. |
Optional |
on_success , on_fail and on_finish |
Define operations to perform upon step completion using a set of predefined post-step operations. | Optional |
retry |
Define retry behavior as described in retrying a step. | Optional |
Examples
Update existing service using the same Docker image (tagged with branch)
codefresh.yml
Update existing service using a different Docker image (tagged with git hash)
codefresh.yml
Deploy a custom Kuberentes Manifest as is
In this case, only a deployment is created.
codefresh.yml
Advanced Kubernetes deployments
If you find the deploy step limited, feel free to look at the other deployment options offered by Codefresh:
Related articles
Kubernetes deployment quick start
Manage Kubernetes clusters
Using Helm in Codefresh pipelines