Skip to main content
Version: 5.x

Configure Terminal

There are two main modes how to develop with DevSpace, by streaming the log output of pods in DevSpace or by opening a terminal to the pod you would like to develop with. If you prefer the latter, you can configure the dev.terminal option to tell DevSpace to open a terminal to a target container.

In the dev.terminal section in the devspace.yaml you can configure the terminal:

images:
frontend:
image: myregistry/appfrontend
dependencies:
- name: backend
source:
path: backend
deployments:
- name: frontend
helm:
componentChart: true
values:
containers:
- image: myregistry/appfrontend
command: ["sleep"]
args: ["999999999"]
dev:
terminal:
imageSelector: myregistry/appfrontend
workDir: '/path/to/my/workdir'
# If you would like to open a different shell or start
# it with a different command you can also use
command: ["bash"]
Sleeping Container

You will need to make sure that the container has a terminal equipped and is sleeping so that you can start your application.

Configuration

imageSelector

The imageSelector option expects a string that specifies an image (e.g. my-registry.com/lib/my-image:tag) to select a target pod and container with. The newest running pod that has a container which matches this image will be selected by DevSpace.

In addition, you can also reference images from the images section in the imageSelector with:

  • If the image in imageSelector matches a images.*.image, DevSpace will automatically append the latest built tag during runtime to the imageSelector.
  • You can also let DevSpace resolve the target image and tag by using runtime variables ${runtime.images.IMAGE_NAME}, ${runtime.images.IMAGE_NAME.image} or ${runtime.images.IMAGE_NAME.tag}

For example:

images: 
app:
image: my-registry.com/lib/my-image
dev:
...
# DevSpace will search for the newest pod with a container that
# uses my-registry.com/lib/other-image:latest
- imageSelector: my-registry.com/lib/other-image:latest
# DevSpace will search for the newest pod with a container that
# uses my-registry.com/lib/my-image:xxxxx (latest built tag by DevSpace)
- imageSelector: my-registry.com/lib/my-image
# DevSpace will search for the newest pod with a container that
# uses my-registry.com/lib/my-image:xxxxx (latest built tag by DevSpace)
- imageSelector: ${runtime.images.app}
# DevSpace will search for the newest pod with a container that
# uses my-registry.com/lib/my-image:custom-tag
- imageSelector: ${runtime.images.app.image}:custom-tag
# DevSpace will search for the newest pod with a container that
# uses my-registry.com/lib/my-image:xxxxx (latest built tag by DevSpace)
- imageSelector: ${runtime.images.app.image}:${runtime.images.app.tag}
# DevSpace will search for the newest pod with a container that
# uses the image of app of dependency dep1 with the latest built tag by DevSpace
- imageSelector: ${runtime.dependencies.dep1.images.app.image}:${runtime.dependencies.dep1.images.app.tag}

Example: Setting imageName

images:
frontend:
image: myregistry/appfrontend
backend:
image: myregistry/appbackend
deployments:
- name: backend
helm:
componentChart: true
values:
containers:
- image: myregistry/appbackend
- name: frontend
helm:
componentChart: true
values:
containers:
- image: myregistry/appfrontend
command: ["sleep"]
args: ["999999999"]
dev:
terminal:
imageSelector: myregistry/appbackend

labelSelector

The labelSelector option expects a key-value map of strings with Kubernetes labels. This can be used to select the correct target pod with labels instead of the image name like imageSelector or imageName. If the pod you want to select has multiple containers, make sure to use containerName as well.

Example: Setting labelSelector

dev:
terminal:
labelSelector:
app: my-app
# If the pod has multiple containers make sure to set this
containerName: container1

containerName

If you select a pod via labelSelector and the pod has multiple containers, you'll need to specify a container name with this option.

namespace

If this option is specified DevSpace will search the pod in this namespace.

workDir

If this option is specified DevSpace will open the shell in the specified working directory.

command

The command option expects a string array as optional configuration for how to open the shell for terminal forwarding. If this option is specified, workDir will not work anymore.

Command Termination

If command is a non-interactive command that terminates, DevSpace will run the command and exits after the command has terminated.