Config Expressions
Config expressions are a powerful feature to load the devspace.yaml in a more dynamic way. A config expression works by specifying $( my bash expression )
instead of a field and the stdout of the bash expression is taken as value instead.
Load a deployment specification from file:
deployments:
- $(cat deployment.yaml)
Change config based on devspace variables:
deployments:
# Inline if-else
- $( [ ${DEVSPACE_NAMESPACE} == "test" ] && cat deployment.yaml || echo "" )
# Multiline if-else
- |-
$(
if [ ${DEVSPACE_CONTEXT} == "minikube" ]; then
cat minikube.yaml
else
echo ""
fi
)
Generate a complete section
dev: $(./my-script.sh ${DEVSPACE_NAMESPACE} ${DEVSPACE_CONTEXT} ${DEVSPACE_PROFILE})
Return JSON
images:
test:
image: my-image/image
build: '$( echo {"disabled": true} )'
New config version v1beta11
:
- Removed
imageName
as selector, please useimageSelector: image(name):tag(name)
instead - Removed
dev.logs.images
, please usedev.logs.selectors
instead - Renamed
hooks.where.container
tohooks.container
commands.appendArgs
now defaults to falsedependencies[*].overrideVars
now defaults to false- Renamed
hooks.when
tohooks.events
, which is a string array now that supports the following events:before:deploy
,after:deploy
,before:deploy:[name]
,after:deploy:[name]
,error:deploy:[name]
,skip:deploy:[name]
: executed while DevSpace deploysdeployments
.[name]
can be replaced with the config name of a deployment or*
to match all.before:render
,after:render
,before:render:[name]
,after:render:[name]
,error:render:[name]
: executed while DevSpace rendersdeployments
duringdevspace render
.[name]
can be replaced with the config name of a deployment or*
to match all.before:purge
,after:purge
,before:purge:[name]
,after:purge:[name]
,error:purge:[name]
: executed while DevSpace purgesdeployments
duringdevspace purge
.[name]
can be replaced with the config name of a deployment or*
to match all.before:build
,after:build
,before:build:[name]
,after:build:[name]
,error:build:[name]
,skip:build:[name]
: executed while DevSpace buildsimages
.[name]
can be replaced with the config name of an image or*
to match all.start:sync:[name]
,stop:sync:[name]
,error:sync:[name]
,restart:sync:[name]
,before:initialSync:[name]
,after:initialSync:[name]
,error:initialSync:[name]
: executed while DevSpace syncs files withdev.sync
.[name]
can be replaced with the config name of a sync configuration or*
to match all.start:portForwarding:[name]
,restart:portForwarding:[name]
,error:portForwarding:[name]
,stop:portForwarding:[name]
: executed while DevSpace port forwards withdev.ports
.[name]
can be replaced with the config name of a port forwarding configuration or*
to match all.start:reversePortForwarding:[name]
,restart:reversePortForwarding:[name]
,error:reversePortForwarding:[name]
,stop:reversePortForwarding:[name]
: executed while DevSpace reverse port forwards withdev.ports
.[name]
can be replaced with the config name of a port forwarding configuration or*
to match all.before:createPullSecrets
,after:createPullSecrets
,error:createPullSecrets
: executed while DevSpace createspullSecrets
devCommand:before:execute
,devCommand:after:execute
,devCommand:error
,devCommand:interrupt
,devCommand:before:sync
,devCommand:after:sync
,devCommand:before:portForwarding
,devCommand:after:portForwarding
,devCommand:before:replacePods
,devCommand:after:replacePods
,devCommand:before:runPipeline
,devCommand:after:runPipeline
,devCommand:before:deployDependencies
,devCommand:after:deployDependencies
,devCommand:before:build
,devCommand:after:build
,devCommand:before:deploy
,devCommand:after:deploy
,devCommand:before:openTerminal
,devCommand:before:streamLogs
: executed at certain lifecycle events during thedevspace dev
commanddeployCommand:before:execute
,deployCommand:after:execute
,deployCommand:error
,deployCommand:interrupt
executed at different checkpoints whendevspace deploy
is executedpurgeCommand:before:execute
,purgeCommand:after:execute
,purgeCommand:error
,purgeCommand:interrupt
executed at different checkpoints whendevspace purge
is executedbuildCommand:before:execute
,buildCommand:after:execute
,buildCommand:error
,buildCommand:interrupt
executed at different checkpoints whendevspace build
is executed
Wildcard and filter paths for patches
It is now possible to use filter paths and wildcards in profile & pod patches. For example:
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: staging
patches:
- op: replace
path: ..[?(@.image=='john/devbackend')].image
value: john/stagingbackend
- op: remove
path: deployments..[?(@.image=='john/debugger')]
For more informations take a look at the docs.
Other Changes
- You can now use
image(default)
andtag(default)
in hook commands and args:
images:
test:
image: test/test
hooks:
- command: |-
./custom-script image(test):tag(test) # -> Transformed to ./custom-script test/test:#####
when:
after:
images: all
- Added new option
hooks[*].container.once
that will execute remote container command hooks only once during the lifetime of a container - DevSpace will now use a replica set instead of single pod as pod replacement
- DevSpace will now set the statefulsets pod name as hostname in the replaced pods
- DevSpace will now also write sync logs to .devspace/logs/sync.log even if shown in terminal
- DevSpace will now try to restart the terminal if an unexpected exit code occurred during
devspace dev
. Can be disabled via the flag--terminal-reconnect=false
- New flag
--reconnect
for commanddevspace enter
to restart the terminal if an unexpected exit code was encountered - New flag
--image-selector
for commandsdevspace enter
,devspace logs
&devspace attach
- Fixed an issue where
pathType
was not automatically set for newer ingress versions - Fixed an issue where namespace and context were wrong in UI commands
- Fixed an issue where replacing pods with the same image selector across different
devspace.yaml
would target the same pods (#1633) - Renamed plugin hook names to match config hook names
- Improved port forwarding & reverse port forwarding logging
- Fixed an issue where paths that include a symlink would not sync correctly