Deployments
Deployments are configured within the deployments
section of the devspace.yaml
.
Examples
- Mixed
- Component Chart
- Custom Helm Chart
- Manifests
- Kustomizations
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: bitnami/mysql # Deploy chart from bitnami registry
values: ...
- name: "deployment-4" # Name of this deployment
helm: ... # Deploy another Helm Chart
chart:
name: ./chart # Deploy chart from local folder
values: ...
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
deployments:
- name: database # Name of this deployment
helm: # Deploy a Helm Chart
chart:
name: bitnami/mysql # Deploy chart from bitnami registry
values: ...
- name: backend # Name of this deployment
helm: ... # Deploy another Helm Chart
chart:
name: ./chart # Deploy chart from local folder
values: ...
deployments:
- name: backend # Name of this deployment
kubectl: # Deploy Kubernetes manifests or Kustomizations
manifests:
- app/manifests/
- db/deployment.yaml
deployments:
- name: backend # Name of this deployment
kubectl: # Deploy Kubernetes manifests or Kustomizations
kustomize: true
manifests:
- app/kustomization/
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'sdevspace.yaml
(unlessskipBuild: true
) - Deploy the dependency as configured in the
deployments
section of the dependency'sdevspace.yaml
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.
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.
DevSpace will replace the following things:
- registry.url/repo/name that corresponds to a
images.*.image
, will be rewritten toregistry.url/repo/name:generated_tag
- ${runtime.images.image-key.image} that corresponds to a
images.*
key, will be rewritten toregistry.url/repo/name
. You can also use dependency images here with${runtime.dependencies.dep1.images.dep-image.image}
- ${runtime.images.image-key.tag} that corresponds to a
images.*
key, will be rewritten togenerated_tag
. You can also use dependency images here with${runtime.dependencies.dep1.images.dep-image.tag}
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 withkubectl
(optionally usingkustomize
ifkustomize: true
)helm
deployments will be deployed with thehelm
client that comes in-built with DevSpace
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
This command will build images (if necessary) and update the tags within manifests and Helm chart values.