Skip to main content
Version: 5.14

Config Profiles

DevSpace allows you to define different profiles for different use cases (e.g. working on different services in the same project, starting certain debugging environments) or for different deployment targets (e.g. dev, staging production).

Profiles allow you to define:

Combine several strategies

It is possible to use several strategies together within one profile. The execution order inside a single profile is:

  1. replace
  2. merge
  3. strategicMerge
  4. patches

If you want to change the execution order or need multiple patches take a look at profile parents

Debug Profiles

The following command is useful to verify that the profile modifies the config as intended:

devspace print -p my-profile

The above command would print the config after applying all profile patches and replace statements as well as after replacing all config variables.

A profile has to be configured in the profiles section of the devspace.yaml.

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
patches:
- op: replace
path: images.backend.image
value: john/prodbackend
- op: remove
path: deployments.name=backend.helm.values.containers[1]
- op: add
path: deployments.name=backend.helm.values.containers
value:
image: john/cache

Useful Commands#

devspace print -p [profile]#

The following command is useful to verify that the profile modifies the config as intended:

devspace print -p my-profile

The above command would print the config after applying all profile patches and replace statements as well as after replacing all config variables.

Apply Multiple Profiles with Flags

It is possible to apply multiple profiles in a single command with the --profile-parent flag. This flag can take one or multiple profiles that will be applied before the actual profile in the order that they are specified. If no --profile flag is given the last specfied --profile-parent will be last profile that is applied to the configuration.

Example:

# Apply profile1, profile2 and profile3 in this order
devspace print --profile-parent profile1 --profile-parent profile2 --profile profile3
# Without the --profile flag will have the same output as above
devspace print --profile-parent profile1 --profile-parent profile2 --profile-parent profile3

devspace list profiles#

To get a list of available profiles, you can run this command:

devspace list profiles

devspace use profile [profile]#

To permanently switch to a different profile, you can run this command:

devspace use profile [PROFILE_NAME]
note

Permanently switching to a profile means that all future commands (e.g. devspace deploy or devspace dev) will be executed using this profile until the user resets the profile (see below).

devspace use profile --reset#

To permanently switch back to the default configuration (no profile replaces and patches active), you can run this command:

devspace use profile --reset

devspace [deploy] -p [profile]#

Most DevSpace commands support the -p / --profile flag. Using this flag, you can run a single command with a different profile without switching your profile permenantly:

devspace build -p [PROFILE_NAME]
devspace deploy -p [PROFILE_NAME]
devspace dev -p [PROFILE_NAME]
devspace dev -i -p [PROFILE_NAME]