Skip to main content
Version: 6.x (Latest)

Dependencies

DevSpace allows you to define dependencies between several software projects that have a devspace.yaml, e.g. across different git repositories or local folders. This makes DevSpace a great tool for building and deploying software that consists of several microservices. Primary use cases of dependencies are:

  • You want to reuse an already existing devspace.yaml of another project
  • You want to define a more complex pipeline with multiple build, hook and deploy steps
  • You want to define a common build / deploy step for other projects

Dependencies for DevSpace projects are defined within the dependencies section of devspace.yaml.

dependencies:
api-server:
git: https://github.com/my-api-server
branch: stable
pipeline: dev
auth-server:
git: https://github.com/my-auth-server
revision: c967392
profiles:
- production
database-server:
git: https://github.com/my-database-server
tag: v3.0.1
subPath: /configuration
vars:
ROOT_PASSWORD: ${ROOT_PASSWORD}

Dependency Source

DevSpace is able to work with dependencies from the following sources:

Execution Order

Dependencies will be executed in parallel and always before image building and deployments defined in the top-level devspace.yaml. If you want to execute dependencies sequentially, you can define a pipeline to do so. dev configuration that should be reused from a dependency will be executed alongside regular dev configuration specified in the top-level devspace.yaml after the DevSpace deployment pipeline ran through. Example:

dependencies:
dep1:
path: dep1
pipeline: dev
dep2:
path: dep2
pipeline: dev
images:
image1:
image: myimage/image
deployments:
deployment1:
helm:
...
dev:
my-dev:
ports: ...
sync: ...

Explanation

In the above devspace.yaml, execution order would be as followed:

  • Execute dependency dep1's pull secrets, image building & deployments (if dep1 has other dependencies as well, execute those first)
  • Execute dependency dep2's pull secrets, image building & deployments
  • Build image image1
  • Deploy deployment deployment1
  • Start merged portforwarding from dep2 and dev.ports
  • Start sync from dep1 and dev.sync

Referencing Dependencies

Reference Image Names

You can reference dependencies images via my-dependency.image in the ./devspace.yaml:

dependencies:
dep1:
path: dep1

dev:
my-dev:
imageSelector: ${runtime.dependencies.dep1.images.image1}
# Will open a terminal to the pod with the
# image from dep1
terminal: {}

With dep1/devspace.yaml:

images:
image1:
image: myusername/devspace
deployments:
quickstart:
helm:
values:
containers:
- image: myusername/devspace

Referencing Dependencies in Deployment Values / Manifests

It is also possible to reference a dependency's image with runtime variables in a deployment:

dependencies:
dep1:
path: dep1
deployments:
quickstart:
helm:
values:
containers:
- image: ${runtime.dependencies.dep1.image1.image}:${runtime.dependencies.dep1.image1.tag} # -> replaced with 'myusername/devspace:xxxx'

With a dependency dep1/devspace.yaml that looks like:

images:
image1:
image: myusername/devspace

Dependency Resolution

When a DevSpace project has dependencies, DevSpace will:

  1. Resolve all dependencies in a recursive manner and give the dependency an ID based on its path or git repository
  2. Build a non-cyclic dependency tree where each dependency only occurs once (but could have multiple edges)
  3. Choose a leave node from the dependency tree, build its images (unless skip is defined) and deploy its deployments as well as execute defined hooks or pull secrets
  4. Remove the leave node from the tree and repeat step 3 until everything has been deployed

The algorithm used by DevSpace for building and deploying dependencies ensures that all dependencies have been deployed in the correct order before the project you are calling DevSpace from will be built and deployed.

Redundant Dependencies

If DevSpace detects that two projects within the dependency tree define the same child-dependency (i.e. a redundant dependency), DevSpace will try to resolve this by removing the dependency that is "higher" (i.e. found first when resolving dependencies) within the tree.

Circular Dependencies

If DevSpace detects two projects which define each other as dependencies (either directly or via child-dependencies), DevSpace will print a warning showing the problematic dependency path within the dependency tree.

Configuration

dependencies required <dependency_name>:object

Dependencies are sub devspace projects that lie in a local folder or remote git repository that can be executed from within the pipeline. In contrast to imports, these projects pose as separate fully functional DevSpace projects that typically lie including source code in a different folder and can be used to compose a full microservice application that will be deployed by DevSpace. Each dependency name can only be used once and if you want to use the same project multiple times, make sure to use a different name for each of those instances.

<dependency_name> required string

Name is used internally

disabled required boolean false

Disabled excludes this dependency from variable resolution and pipeline runs

Source: Local Filesystem

path required string

Path is the local path where DevSpace can find the artifact. This option is mutually exclusive with the git option.

Source: Git Repository

git required string

Git is the remote repository to download the artifact from. You can either use https projects or ssh projects here, but need to make sure git can pull the project. This option is mutually exclusive with the path option.

subPath required string

SubPath is a path within the git repository where the artifact lies in

branch required string

Branch is the git branch to pull

tag required string

Tag is the tag to pull

revision required string

Revision is the git revision to pull

cloneArgs required string[]

CloneArgs are additional arguments that should be supplied to the git CLI

disableShallow required boolean false

DisableShallow can be used to turn off shallow clones as these are the default used by devspace

disablePull required boolean false

DisablePull will disable pulling every time DevSpace is reevaluating this source

Execution

pipeline required string deploy

Pipeline is the pipeline to deploy by default. Defaults to 'deploy'

vars required <var_name>:string

Vars are variables that should be passed to the dependency

overwriteVars required boolean false

OverwriteVars specifies if DevSpace should pass the parent variables to the dependency

ignoreDependencies required boolean false

IgnoreDependencies defines if dependencies of the dependency should be excluded

namespace required string

Namespace specifies the namespace this dependency should be deployed to