DevSpace allows you to develop applications directly inside a Kubernetes cluster.
The biggest advantages of developing directly inside Kubernetes is that your dev environment will be very similar to your production environment and you can have a much greater confidence that everything will work in production when shipping new features.
Start Development Mode
Run the following command to start your application in development mode:
devspace dev, the
dev section in
devspace.yaml becomes important:
devspace dev will do the following:
- Build and deploy your application
- Stream the logs of all containers deployed during the deployment process
- Forward all ports specified in the
dev.portssection in the
- Sync all file changes according to the sync config in
dev.sync, so you can restart your application inside the running container without having to rebuild images or redeploy anything
1. Edit Files & Restart
devspace dev is running, your source code files will be synchronized between your local project folder and your containers running inside Kubernetes. This allows you to code with your favorite IDE or text editor without having to rebuild your images or redeploy your containers.
Try it and just edit a file!
You will see that the logs show how DevSpace restarts your application inside the container:
2. Open UI (in the browser)
devspace dev, DevSpace starts a client-only UI for Kubernetes. You can see that in the output of
devspace dev which should contain a log line similar to this one:
By default, DevSpace starts the development UI on port
8090 but if the port is already in use, it will use a different port. If
devspace dev is running, you can open the link shown in the
devspace dev logs, e.g. http://localhost:8090
You can also start the UI without running
devspace dev using this command:
Runs on Localhost
The UI of DevSpace is open-source just like the rest of the CLI and it runs entirely on localhost.
3. Use Port Forwarding
devspace dev is running, you can access your application via
localhost:[PORT] because DevSpace starts port forwarding for all ports specified in the
dev.ports section of your project's
Port forwarding also allows you to attach to remote debuggers if you package them into your development Docker image. This allows you to set breakpoints in your IDE and the code execution will break inside the remote container while you can debug in your IDE.
devspace init, DevSpace detects all ports within your Dockerfile (i.e.
EXPOSE [PORT] lines) and automatically configures forwarding for them when creating the
Learn more about how to configure port forwarding.
It is highly discouraged to run
devspace dev multiple times in parallel because multiple instances of port forwarding and file synchronization will disturb each other. Instead:
devspace enterto open additional terminal sessions without port forwarding and file sync
devspace logsto start log streaming without port forwarding and file sync
devspace syncto sync files on-demand without starting port forwarding etc.
devspace uito open the localhost development UI in the browser