Deployment environments
How to update the environment status from builds
Codefresh includes an Environment dashboard to monitor your applications and the builds associated with them. You can access the dashboard by clicking on Environments in the left sidebar of the Codefresh UI.
Currently two types of environments are supported (they look identical in the UI):
- Helm releases
- Plain Kubernetes deployments
In any pipeline that implements a deployment, you can add an extra env
property to instruct Codefresh on which environments are affected by that build. The first time that you run the build, the environment GUI screen is automatically populated with an entry for that environment. Any subsequents builds with then update the environment entry with build and deployment status.
NOTE
You can also create an environment manually from the UI, and a pipeline will update it automatically if ALL properties of the environment match those described in the pipeline YAML.
Usage
Syntax for a freestyle step that deploys to a Kubernetes environment:
YAML
Syntax for a freestyle step that deploys to a Helm environment:
codefresh.yml
You can also use environments in other Codefresh steps such as deploy.
Fields
Field | Description |
---|---|
name |
Arbitrary name of the environment. It can be anything you want. It will appear in the Environment Dashboard GUI |
endpoints |
Array of name , url pairs that mark the application accessible endpoints of this environment (if any). They appear in the Environment GUI as links and allow you to quickly visit an environment with your browser. The endpoint value is a just a link/bookmark to the application endpoint that you want to associate with this environment. In most cases it is the load-balancer/ingress/Kubernetes service exposed by your application. |
type |
Type of environment. Accepted values are either kubernetes or helm-release |
change |
Any text that you want to appear as a description on what the build did to an environment. You can use free text or any Codefresh variable such CF_COMMIT_MESSAGE to get the commit message of the git trigger |
filters |
An array of cluster characteristics so that Codefresh can pull live data from the cluster to display pod and deployment status. For a Kubernetes environment you enter cluster , namespace and for Helm environments you enter cluster , releaseNames |
In all cases the cluster
name is the unique identifier of your cluster as seen in the Kubernetes dashboard screen.
Also notice that the relationship between environments and builds are many to many. A single environment can be affected by different pipelines, and a single pipeline might deploy to multiple environments.
Example for Kubernetes environment
A pipeline that deploys to a Kubernetes cluster:
codefresh.yml
This pipeline is similar to the one described in the Kubernetes quick start guide but has an extra env
block that defines:
- an environment called “orders-prod”
- a single application endpoint at 40.113.201.163 (Kubernetes service or ingress)
- a change entry with a freetext string “updated”
- on a cluster which is linked to Codefresh with the name
my-demo-k8s-cluster
- monitoring pods and deployments found in the
default
namespace
Once the pipeline runs the following environment entry will appear in the environments screen:
Example for Helm environment
A pipeline that deploys a Helm release:
codefresh.yml
This pipeline is similar to the one described in the Helm quick start guide but has an extra env
block that defines:
- an environment called “load testing”
- a single application endpoint at 40.113.201.163 (Kubernetes service or ingress)
- a change entry that is the same as the last commit message (
CF_COMMIT_MESSAGE
variable) - on a cluster which is linked to Codefresh with the name
my-demo-k8s-cluster
- monitoring a Helm release named
my-go-chart-prod
(the release was created in theDeployMyChart
pipeline step )
Once the pipeline runs the following environment entry will appear in the environments screen:
Every time that you run another build of the pipeline the environment status will be updated automatically.
Related articles
Creating pipelines
Managing Kubernetes clusters
Connecting a Kubernetes cluster
Promoting Helm Environments