Skip to main content
Version: 5.x

Profiles: Parents

The parents option is optional and expects the names of other profiles which should be applied before this profile. The profiles are applied in the order they are specified. It is also possible to apply profiles from distant devspace.yamls. The kind of profile inheritance that the parents option provides can help to reduce redundancy when multiple profiles need to change the config in a similar way.

Execution Order

A parent profile is applied before the profile that defines the parent. A parent profile can have parents of its own.

Example: Defining a Parent Profile

images:
backend:
image: john/devbackend
backend-debugger:
image: john/debugger
deployments:
- name: backend
helm:
componentChart: true
values:
containers:
- image: john/devbackend
- image: john/debugger
profiles:
- name: production
parents:
- profile: staging
patches:
- op: add
path: deployments.name=backend.helm.values.containers
value:
image: john/cache
- name: staging
replace:
images:
backend:
image: john/backendprod
patches:
- op: replace
path: deployments.name=backend.helm.values.containers[0].image
value: john/backendprod
- op: remove
path: deployments.name=backend.helm.values.containers[1]

When the production profile is active, the replace and patches statements configured in staging would be applied first because of the parents statement in line 16. After applying the staging profile, DevSpace would additionally apply the currently active production profile. In this example, the production profile is based on the staging profile and the only difference is that the production profile adds another container to the backend deployment which is using the image john/cache.

Example: Defining multiple Parent Profiles

version: v1beta9
profiles:
- name: multi-parents
# Field that applies the profile deployments first and then the profile images
parents:
- profile: deployments
- profile: images
- name: deployments
replace:
deployments:
- name: my-deployment
helm:
componentChart: true
values:
containers:
- name: test
- name: images
replace:
images:
test:
image: mydockeruser/devspace
createPullSecret: true

It is also possible to load a profile from a different source with the option profiles.*.parents.*.source that can define profiles that lie in a different devspace.yaml:

Example: Define a profile from a different devspace.yaml

version: v1beta9
profiles:
- name: dev
parents:
# Will load the profile images from the devspace.yaml specified in other-folder/devspace.yaml
- profile: images
source:
path: other-folder # devspace.yaml will be automatically appended to the path (same syntax as with dependencies)
# or load from url
# path: https://raw.githubusercontent.com/my-org/my-repo/master/devspace.yaml
# or load from git
# git: https://github.com/loft-sh/devspace.git
- profile: deployments
source:
path: other-folder-2

Under source the same options can be specified as for loading dependencies.

Apply Multiple Profiles with Flags

It is possible to apply multiple profiles in a single command with the --profile flag. This flag can take one or multiple profiles that will be applied in the order that they are specified.

Example:

# Apply profile1, profile2 and profile3 in this order
devspace print --profile profile1 --profile profile2 --profile profile3