Configure Interactive Mode
The development mode of DevSpace can be started using the -i / --interactive flag which overrides the ENTRYPOINT of an image with [sleep, 999999] and opens an interactive terminal session for one of the containers that use the 'sleeping' image. Due to the ENTRYPOINT override, the application has not been started within the container and the user can start the application manually through the interactive terminal session.
To control the default behavior when using the interactive mode, you can configure the dev.interactive section in the devspace.yaml.
images:
frontend:
image: dscr.io/${DEVSPACE_USERNAME}/appfrontend
backend:
image: john/appbackend
database:
image: john/database
deployments:
- name: app-frontend
helm:
componentChart: true
values:
containers:
- image: dscr.io/${DEVSPACE_USERNAME}/appfrontend
- name: app-backend
helm:
componentChart: true
values:
containers:
- image: john/appbackend
name: some-container
- image: john/appbackend
dev:
interactive:
images:
- name: backend
entrypoint:
- tail
cmd:
- -f
- /dev/null
- name: frontend
entrypoint:
- /debug_entrypoing.sh
terminal:
imageName: backend
containerName: some-container
Start Interactive Mode
Start the interactive mode using this command:
devspace dev -i
Configuration
images
The images option expects an array of objects having the following properties:
namestating an image name which references an image in theimageswithindevspace.yaml(required)entrypointdefining anENTRYPOINToverride that will be applied only in interactive mode (optional)cmddefining aCMDoverride that will be applied only in interactive mode (optional)
ENTRYPOINT and CMD overrides for interactive mode work the same way as regular overrides for image building. However, they take precedence over regular overrides and are only used during interactive mode.
By default, DevSpace asks which image to override when starting interactive mode (or skips the question if only one image is defined). This image will then be built using the ENTRYPOINT [sleep, 999999] override if not configured differently via images.
Example: Setting Interactive Mode Images
images:
frontend:
image: dscr.io/${DEVSPACE_USERNAME}/appfrontend
backend:
image: john/appbackend
database:
image: john/database
deployments:
- name: app-frontend
helm:
componentChart: true
values:
containers:
- image: dscr.io/${DEVSPACE_USERNAME}/appfrontend
- name: app-backend
helm:
componentChart: true
values:
containers:
- image: john/appbackend
name: some-container
- image: john/appbackend-sidecar
dev:
interactive:
images:
- name: backend
entrypoint:
- tail
cmd:
- -f
- /dev/null
- name: frontend
entrypoint:
- /debug_entrypoing.sh
Explanation:
- The above example defines 3 images and 2 deployments.
- The
imagesoption defines that the imagebackendshould be built using aENTRYPOINT [tail]and usingCMD [-f, /dev/null]when building this image in interactive mode - The
imagesoption defines that the imagefrontendshould be built using aENTRYPOINT [/debug_entrypoint.sh]when building this image in interactive mode
terminal
The terminal option expects an object having the following properties:
imageNameto select a container based on an image specified inimageslabelSelectorto select a pod based a Kubernetes label selectorcontainerNameto select a container based on its name (optional, useful if pod has multiple containers)namespaceto select a container from a namespace different than the default namespace of the current kube-contextcommanddefines a command to run when starting the terminal session (default:/bin/bashwith fallback/bin/sh)
The first four options are used to select the appropriate pod / container. If you specify multiple these config options, they will be jointly used to select the pod / container (think logical AND / &&).
If command is a non-interactive command that terminates, DevSpace will run the command and exits after the command has terminated.
Example: Configuring Terminal for Interactive Mode
images:
frontend:
image: dscr.io/${DEVSPACE_USERNAME}/appfrontend
backend:
image: john/appbackend
database:
image: john/database
deployments:
- name: app-frontend
helm:
componentChart: true
values:
containers:
- image: dscr.io/${DEVSPACE_USERNAME}/appfrontend
- name: app-backend
helm:
componentChart: true
values:
containers:
- image: john/appbackend
name: some-container
- image: john/appbackend-sidecar
dev:
interactive:
terminal:
imageName: backend
containerName: some-container
Explanation:
The above configuration would open the container with name some-container that belongs to the deployment app-backend when running devspace dev -i.
defaultEnabled
The defaultEnabled option expects a boolean that determines if interactive mode should be started by default even if no -i / --interactive flag was provided.
Default Value For defaultEnabled
defaultEnabled: false
Example: Enabling Interactive Mode By Default
images:
backend:
image: john/appbackend
deployments:
- name: app-backend
helm:
componentChart: true
values:
containers:
- image: john/appbackend
name: some-container
- image: john/appbackend-sidecar
dev:
interactive:
defaultEnabled: true
images:
- name: backend
entrypoint:
- /debug_entrypoing.sh
terminal:
imageName: backend
containerName: some-container
Explanation:
Running devspace dev with the above configuration leads to:
- during image building: the overrides defined in
imageswould be applied - after deployment: an interactive terminal session for a container with name
some-containerand with imagejohn/appbackendwould be started
