New Feature: Pod Replacing
With dev.replacePods
we introduced a new feature that gives you the option to exchange an already running or just deployed pod with a modified version. This is especially useful if you:
- Need to configure or disable an option on a pod which is not configurable via your helm chart or manifests
- Do not want to use DevSpace for your pipeline and instead only want to use DevSpace for development
- Want to debug a setup with an already deployed app by exchanging a single pod temporarily with modifications
For example:
version: v1beta10
deployments:
- name: my-app
helm:
componentChart: true
values:
containers:
- name: my-container
image: idonotexist:neverexisted # this will create a failing pod
dev:
# DevSpace will try to find a pod with the given label selector. If found (even if its currently in a failed state)
# DevSpace will copy the pod, scale down the owning ReplicaSet, Deployment or StatefulSet
# and create the new modified pod in the cluster.
replacePods:
- labelSelector:
app.kubernetes.io/component: my-app
replaceImage: ubuntu:latest # you could also use image(default):tag(default) if you want to make this more dynamic
patches:
- op: replace
path: spec.containers.name=my-container.command
value: ["sleep"]
- op: replace
path: spec.containers.name=my-container.args
value: ["9999999999"]
- op: replace
path: spec.containers.name=my-container.workingDir
value: "/workdir"
# This will create a terminal to the replaced pod
terminal:
labelSelector:
app.kubernetes.io/component: my-app
# This will sync to the replaced pod's working directory
sync:
- labelSelector:
app.kubernetes.io/component: my-app
For more informations take a look at the devspace docs
Dependency Changes
With v5.12.0, we greatly improved dependencies and you are now able to reference dependency images and reuse dependency dev
configuration. This makes it possible to create much more flexible pipelines and enables you to outsource parts of your devspace.yaml
enterly.
For example, you can now reference dependency images in every imageName
field via dependency1.image1
. In deployment values, you can now use image(dependency1.image1):tag(dependency1.image1)
to insert an image that was built within a dependency. You can even reference dependencies of dependencies via depdency1.dependency2.image1
. You can also run a command of a dependency with devspace run dependency1.command
now.
For example ./devspace.yaml
:
version: v1beta10
dependencies:
- name: dep1
source:
path: ./dep1
dev:
ports: true
deployments:
- name: quickstart
helm:
componentChart: true
values:
containers:
- image: image(dependency1.image1):tag(dependency1.image1) # will be replaced with -> myrepo/image:xxxx
dev:
# Will open a terminal to the pod with the
# image from dep1
terminal:
imageName: dep1.image1
Then the dependency ./dep1/devspace.yaml
could look like this:
version: v1beta10
images:
image1:
image: myrepo/image
dev:
ports:
- imageName: image1
forward:
- port: 3000
This makes it a lot easier to divide your devspace.yaml
into multiple parts or to build a much complexer pipeline with multiple build and deploy steps.
For more informations take a look at the devspace docs
New Config Version v1beta10
With the new config version v1beta10
we cleaned up some options that were now deprecated for a while (especially dev.interactive
was changed). Older config versions will still continue to work as expected and there are no breaking changes as DevSpace will convert them automatically in memory, you can see how DevSpace translates your current config by running devspace print
. We changed the following options with v1beta10
:
- Removed
dev.interactive
completely. We also removed all related documentation regarding interactive mode and encourage users to usedev.terminal
instead, which opens a terminal without touching the Dockerfile and is much easier to understand. If you need to exchange the entrypoint of the container with DevSpace, we encourage you to use eitherimages[*].entrypoint
&images[*].cmd
, setcommand
&args
in your deployment (if thats supported by your helm chart or manifests) or use the new featuredev.replacePods
to modify the pod'sspec.containers[*].command
&spec.containers[*].args
- New section
dev.terminal
which if set, will tell DevSpace to open a terminal by default instead of printing logs. dev.sync[*].waitInitialSync
is now true by default- Removed
images[*].tagsAppendRandom
&images[*].preferSyncOverRebuild
dependencies[*].name
is now required (for older config versions, the array index will be used as dependency name)- New section
dependencies[*].dev
to specify which dev config should be reused from the dependency (currently onlyports
andsync
are supported)
Removal of deprecated commands
We removed the deprecated commands devspace add deployment
, devspace add image
, devspace add port
, devspace add sync
, devspace remove deployment
, devspace remove image
, devspace remove port
, devspace remove sync
, devspace status sync
and devspace update config
.
Other New Features
- You can now execute hooks or variables with
source: command
via the integrated golang shell. The advantage of this shell is that it works cross platform and you can use logical expressions such asecho 123 && echo 456
. DevSpace will use the shell if nohooks[*].args
orvars[*].args
are provided and only ahooks[*].command
orvars[*].command
is configured:
vars:
- name: MY_VAR_FROM_SHELL
command: "echo value"
- name: MY_VAR_DIRECT
command: "echo"
args: ["value"]
hooks:
- command: "echo 123 && echo 456"
when:
before:
images: all
- New
vars[*].value
that is a shortcut for usingvars[*].source: none
andvars[*].default
- New command
devspace reset pods
to reset changes made bydev.replacePods
- New
commands[*].args
that if defined will execute the command directly instead of in a golang shell - The helpers
image()
andtag()
that can be used within helm deployment values or kubectl manifests can now also be used to reference an image key inimages.*
or in a dependency. If naming of an image key name and the actual image collide, the image key has precedence. For example
version: v1beta10
images:
default:
image: myusername/devspace
deployments:
- name: quickstart
helm:
componentChart: true
values:
containers:
- image: image(default):tag(default) # <- will be replaced during deploy with myusername/devspace:xxxxx. You can also use dependency1.image1 to reference a dependency image instead
- New flag
--all
/-a
fordevspace purge
to purge dependencies as well (the old flag--dependencies
is now deprecated) - New predefined variable
${DEVSPACE_USER_HOME}
that holds the user's home directory
Other Changes
- Completely refactored
devspace init
: there are now more options to choose from how you want to initialize yourdevspace.yaml
. We also setdev.replacePods
withdev.terminal
now by default instead of printing logs and reloading the container process. profiles[*].patches
anddev.replacePods[*].patches
withop: replace
patches do not fail if the target path does not exist anymore and behave like aop: add
insteadprofiles[*].patches
anddev.replacePods[*].patches
withop: remove
patches do not fail if the target path does not exist anymore and do nothing instead- Fixed an issue where image build caching of dependencies was sometimes not working correctly
- Fixed an issue where
hooks[*].when.before.images
was triggered even though the image was not built - Updated kaniko to
v1.5.2
- Updated internal kubernetes version to
v1.20.4
- Improvements to dependency execution and output