DevSpace allows you to develop applications directly inside a Kubernetes cluster with a very fast hot reloading workflow.
Choose Cluster & Namespace
Before you can start the development mode in DevSpace, you need to make sure DevSpace uses the right cluster and namespace:
devspace use context # to select the right Kubernetes cluster
devspace use namespace my-namespace # will be automatically created during deployment
You can use the
devspace use context and
devspace use namespace commands whenever needed. One of the design goals of DevSpace is to allow you to seamlessly switch between clusters (even between localhost and remote clusters) and namespaces as needed.
Start Dev Container
Run the following command to deploy the project and start your dev container:
devspace dev will execute the pipeline named
dev that is defined in your
# This is a list of `pipelines` that DevSpace can execute (you can define your own)
# This is the pipeline for the main command: `devspace dev` (or `devspace run-pipeline dev`)
run_dependencies --all # 1. Deploy any projects this project needs (see "dependencies")
create_deployments --all # 2. Deploy Helm charts and manifests specfied as "deployments"
start_dev app # 3. Start dev mode "app" (see "dev" section)
The pipeline is written in bash syntax but it is an emulated bash, i.e. it runs the same way on any machine, no matter if Linux, Mac, or Windows. You can edit the pipeline script in
devspace.yaml as needed.
The pipeline you see above, runs 3 commands:
run_dependencies --alldeploys all
devspace.yaml(i.e. other microservices that may be needed and potentially live in other git repositories with separate
create_deployments --alldeploys everything defined in the
--all, you could also pass the names of some deployments to this command instead, e.g.
create_deployments app database)
start_dev appstarts the development mode named
appwhich is defined in the
Once the terminal to your dev container opens, run the command to start your application:
- Your Own Project
# or: npm run dev
# or: yarn start
bundle exec rails server -p 3000 -b 0.0.0.0
go run main.go
# Your application may already be running
# Try to open the browser on localhost to access it
# You can also run other commands now:
# Whatever command is needed to start your application
1. File Sync
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 locally but still be able to run and debug your application directly inside the dev container that is running inside Kubernetes.
Try it and just edit a file!
To change which files should be synchronized, you can edit the
sync configuration within the
dev section of your
2. Port Forwarding
DevSpace forwards ports from localhost to your dev container and can also reverse-forward ports from the dev container to your local machine. This is useful to access your application on localhost, e.g. access a UI or API in the browser, or to attach your IDE to a remote debugger running inside your dev container.
To change which ports should be forwarded, you can edit the
ports configuration within the
dev section of your
3. DevSpace UI
devspace dev, DevSpace starts a client-only, localhost UI. 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 output, e.g. http://localhost:8090