Skip to main content
Version: 4.x

Deployments

Deployments are configured within the deployments section of the devspace.yaml.

Examples

deployments:
- name: "deployment-1" # Name of this deployment
helm: # Deploy using the Component Helm Chart
componentChart: true # Use the component chart
values: ... # See: https://devspace.sh/component-chart/docs/introduction

- name: "deployment-2" # Name of this deployment
kubectl: # Deploy Kubernetes manifests or Kustomizations
manifests:
- app/manifests/
- db/deployment.yaml

- name: "deployment-3" # Name of this deployment
helm: # Deploy a Helm Chart
chart:
name: stable/mysql # Deploy chart from stable registry
values: ...

- name: "deployment-4" # Name of this deployment
helm: ... # Deploy another Helm Chart
chart:
name: ./chart # Deploy chart from local folder
values: ...
Sequential Deployment

Unlike images which are build in parallel, deployments will be deployed sequentially following the order in which they are specified in the devspace.yaml.

Run Deployments

When you run one of the following commands, DevSpace will run the deployment process:

  • devspace deploy (before deploying the application)
  • devspace dev (before deploying the application and starting the development mode)

Important Flags

The following flags are available for all commands that trigger the deployment process:

  • -d / --force-deploy redeploy all deployments (even if they could be skipped because they have not changed)
  • -b / --force-build rebuild all images (even if they could be skipped because context and Dockerfile have not changed)

Deployment Process

DevSpace loads the deployments configuration from devspace.yaml and builds one deployment after another in the order that they are specified in the deployments array. Additionally, DevSpace also deploys related projects speficied in dependencies.

1. Deploy Dependencies

DevSpace loads the dependencies section from the devspace.yaml and creates a dependency tree. The current project will represent the root of this tree. Based on this dependency tree, DevSpace will start from the leaves and run these steps for each dependency:

  • Build images of the dependency as configured in the images section of the dependency's devspace.yaml (unless skipBuild: true)
  • Deploy the dependency as configured in the deployments section of the dependency's devspace.yaml
What are Dendencies?

Dependencies allow you to deploy microservices, that the project you are currently deploying relies on. Dependencies can be located in a subpath of your project or they can be automatically loaded from a different git repository.

2. Build, Tag & Push Images

DevSpace triggers the image building process for the images specified in the images section of the devspace.yaml.

3. Tag Replacement

After finishing the image building process, DevSpace searches your deployments for references to the images that are specified in the images section of the devspace.yaml. If DevSpace finds that an image is used by one of your deployments and the deployment does not explicitly define a tag for the image, DevSpace will append the tag that has been auto-generated as part of the automated image tagging during the image building process.

Prevent Hard-Coded Tags

To use automated tag replacement, make sure you do not specify image tags in the deployment configuration.

Replacing or appending tags to images that are used in your deployments makes sure that your deployments are always started using the most recently pushed image tag. This automated process saves a lot of time compared to manually replacing image tags each time before you deploy something.

4. Deploy Project

DevSpace iterates over every item in the deployments array defined in the devspace.yaml and deploys each of the deployments using the respective deployment tool:

  • kubectl deployments will be deployed with kubectl (optionally using kustomize if kustomize: true)
  • helm deployments will be deployed with the helm client that comes in-built with DevSpace
kubectl Required

Deployments with kubectl require kubectl to be installed.



Useful Commands

devspace list deployments

This command lists all deployments and their status:

devspace list deployments

devspace render

This command prints all Kubernetes manifests that would be created when running devspace deploy or devspace dev but without actually deploying them to the cluster:

devspace render

In case of Helm deployments, this command behaves similar to helm install --dry-run --debug

Image Building & Tag Replacement

This command will build images (if necessary) and update the tags within manifests and Helm chart values.