⭐️ Do you like DevSpace? Support the project with a star ⭐️
Building modern, distributed and highly scalable microservices with Kubernetes is hard - and it is even harder for large teams of developers. DevSpace is the next-generation tool for fast cloud-native software development.
DevSpace allows you to store all your workflows in one declarative config file: devspace.yaml
DevSpace helps your team to standardize deployment and development workflows without requiring everyone on your team to become a Kubernetes expert.
devspace.yaml
and simply commits it via gitdevspace deploy
to deploy the project (including image building and deployment of other related project etc.) and they have a running instance of the projectGiving everyone on your team on-demand access to a Kubernetes cluster is a challenging problem for system administrators and infrastructure managers. If you want to efficiently share dev clusters for your engineering team, take a look at www.loft.sh.
Instead of rebuilding images and redeploying containers, DevSpace allows you to hot reload running containers while you are coding:
Deploying and debugging services with Kubernetes requires a lot of knowledge and forces you to repeatedly run commands like kubectl get pod
and copy pod ids back and forth. Stop wasting time and let DevSpace automate the tedious parts of working with Kubernetes:
DevSpace is battle tested with many Kubernetes distributions including:
DevSpace also lets you switch seamlessly between clusters and namespaces. You can work with a local cluster as long as that is sufficient. If things get more advanced, you need cloud power like GPUs or you simply want to share a complex system such as Kafka with your team, simply tell DevSpace to use a remote cluster by switching your kube-context and continue working.
DevSpace runs as a single binary CLI tool directly on your computer and ideally, you use it straight from the terminal within your IDE. DevSpace does not require a server-side component as it communicates directly to your Kubernetes cluster using your kube-context, just like kubectl.
Stop wasting time for running the same build and deploy commands over and over again. Let DevSpace automate your workflow and build cloud-native applications directly inside Kubernetes.
devspace build
docker login my-registry.tld
)devspace deploy
devspace dev
devspace ui
devspace enter
to open a Interactive Terminal Session
devspace logs
/ devspace logs -f
for Fast, Real-Time Logs (optionally streaming new logs)devspace sync
for quickly starting a Bi-Directional, Real-Time File Synchronization on demanddevspace analyze
reporting crashed containers, missing endpoints, scheduling errors, ...devspace purge
(deletes all helm charts, manifests etc. defined in the config)devspace use context
shows a list of contexts (select to set current kube-context)devspace use namespace
shows a list of namespaces (select to set defaut namespace for current context)devspace remove context
shows a list of contexts (select to remove a kube-context)DevSpace provides a plugin for loft.sh which allows users to run command such as devspace create space
or devspace create vcluster
for creating namespaces and virtual Kubernetes clusters in shared dev clusters.
Loft is a server-side solution for Kubernetes multi-tenancy and efficient cluster sharing which provides:
For more infos and install intructions for loft, see: www.github.com/loft-sh/loft
npm install -g devspace
yarn global add devspace
curl -s -L "https://github.com/devspace-cloud/devspace/releases/latest" | sed -nE 's!.*"([^"]*devspace-darwin-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o devspace && chmod +x devspace;
sudo mv devspace /usr/local/bin;
curl -s -L "https://github.com/devspace-cloud/devspace/releases/latest" | sed -nE 's!.*"([^"]*devspace-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o devspace && chmod +x devspace;
sudo install devspace /usr/local/bin
md -Force "$Env:APPDATA\devspace"; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12';
Invoke-WebRequest -UseBasicParsing ((Invoke-WebRequest -URI "https://github.com/devspace-cloud/devspace/releases/latest" -UseBasicParsing).Content -replace "(?ms).*`"([^`"]*devspace-windows-amd64.exe)`".*","https://github.com/`$1") -o $Env:APPDATA\devspace\devspace.exe;
$env:Path += ";" + $Env:APPDATA + "\devspace";
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User);
If you get the error that Windows cannot find DevSpace after installing it, you will need to restart your computer, so that the changes to the
PATH
variable will be applied.
Project | Command |
---|---|
Node.js | git clone https://github.com/devspace-cloud/quickstart-nodejs && cd quickstart-nodejs |
Python | git clone https://github.com/devspace-cloud/quickstart-python && cd quickstart-python |
Java | git clone https://github.com/devspace-cloud/quickstart-java && cd quickstart-java |
Ruby | git clone https://github.com/devspace-cloud/quickstart-ruby && cd quickstart-ruby |
Golang | git clone https://github.com/devspace-cloud/quickstart-golang && cd quickstart-golang |
PHP | git clone https://github.com/devspace-cloud/quickstart-php && cd quickstart-php |
ASP.NET | git clone https://github.com/devspace-cloud/quickstart-asp-dotnet && cd quickstart-asp-dotnet |
cd /path/to/my/project/root
If you are using DevSpace for the first time, we recommend to get started with one of the demo projects listed above.
Initializing a project will create the configuration file devspace.yaml
which tells DevSpace how to deploy your project.
devspace init
Take a look at the Configuration Examples to learn more about
devspace.yaml
Choose the cluster, you want to deploy your project to. If you are not sure, pick the first option. It is very easy to switch between the options later on.
devspace create space my-app # requires login via GitHub or email
DevSpace automatically sets up a kube-context for this space, so you can also access your isolated namespace using
kubectl
,helm
or any other Kubernetes tool.
If you want to deploy to a local Kubernetes cluster, make sure your current kube-context points to this cluster and tell DevSpace which namespace to use:
# Tell DevSpace which namespace to use (will be created automatically during deployment)
devspace use namespace my-namespace
If you want to deploy to a remote Kubernetes cluster, make sure your current kube-context points to this cluster and tell DevSpace which namespace to use:
# Tell DevSpace which namespace to use (will be created automatically during deployment)
devspace use namespace my-namespace
To share a cluster with everyone on your team, install loft, then connect your cluster to your loft instance and then create an isolated Kubernetes namespace via the loft plugin for DevSpace.
# Install the loft plugin for DevSpace
devspace add plugin https://github.com/loft-sh/loft-devspace-plugin
# Login to your loft instance via the CLI
devspace login https://your-loft-instance.tld
# Create an isolated Kubernetes namespace via loft
devspace create space my-namespace
The loft plugin for DevSpace will automatically set up a kube-context for every space you create, so you can also access your isolated namespace using
kubectl
,helm
or any other Kubernetes tool.
loft is a multi-tenancy manager for Kubernetes which allows you to connect clusters that you want to make available for your engineering teams. After connecting a cluster, engineers will be able to create isolated namespaces and even virtual Kubernetes clusters within the cluster whenever they need access to Kubernetes.
loft is maintained by the same people who are developing DevSpace.
loft makes sure that developers cannot break out of their namespaces by configuring RBAC, network policies, pod security policies etc. By default, these restrictions are very strict and do not even allow pods from different namespaces to communicate with eather other. You can configure every security setting that loft enforces using the UI of loft and even set custom limits for different members of your team.
Take a look at the loft documentation for details on how to add users to a cluster that is connected to loft.
The most important command in DevSpace starts the development mode and lets you directly code within your Kubernetes cluster using terminal proxy, port forwarding and real-time code synchronization.
devspace dev
You can now:
http://localhost:PORT
in your browsernodemon
and your application will automatically reload when you edit source code filesRun
devspace dev -i
to use interactive mode: overrides your DockerfileENTRYPOINT
with[sleep, 999999]
and opens the terminal proxy, so you can manually run the start command for your application, e.g.npm start
. Interactive mode is great for debugging containers that keep crashing or starting an application in hot reloading mode when the Dockerfile ENTRYPOINT generally starts a rather production-like version of the application.
When running 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:
#########################################################
[info] DevSpace UI available at: http://localhost:8090
#########################################################
By default, DevSpace starts the development UI on port 8090
but if the port is already in use, it will use a different port.
You can access the development UI once you:
devspace dev
logs in the browser, e.g. http://localhost:8090
devspace ui
(e.g. in a separate terminal parallel to devspace dev
)Once the UI is open in your browser, it will look similar to this screenshot:
Initializing a project will create the configuration file devspace.yaml
which tells DevSpace how to deploy your project.
devspace deploy -p production
The -p / --profile
flag tells DevSpace to apply a certain profile defined in your devspace.yaml
. A profile changes the base configuration by, for example, applying config patches. This allows you to have one base configuration and adapt it for different deployment targets and environment (e.g. dev as base config and a profile for production).
Having issues? Take a look at the Troubleshooting Guides and learn how to fix common issues.
You can now open your application in the browser using the following command:
devspace open
When DevSpace asks you how to open your application, choose the first option "via localhost" because it will work no matter what cluster you are using.
If you want to connect a domain, check out our guide on how to connect a domain by creating an ingress with DevSpace.
Congratulations! You just deployed your first project to Kubernetes using DevSpace.
Follow these links to more about how to use DevSpace:
Command | Important Flags / Notes |
---|---|
devspace dev Starts the development mode |
-b • Rebuild images (force) -d • Redeploy everything (force) -i • Interactive mode (overrides ENTRYPOINT with [sleep, 999999] and starts interactive terminal session)
|
devspace ui Opens the localhost development UI |
|
devspace open Opens your application after starting port-forwarding or generating an ingress |
|
devspace enter Opens a terminal session for a container |
|
devspace enter -- [command] Runs a command inside a container |
|
devspace logs Prints the logs of a container |
-f • Stream logs (follow/attach) |
devspace analyze Analyzes your namespace for issues |
|
devspace build Build, tag and push images (no deploy) |
-t [TAG] • Use specified [TAG] to tag all images |
devspace cleanup images Deletes old images (locally, built by DevSpace) |
This is very useful after you built a lot of images and your local Docker daemon runs out of space (error: no space left on device ) |
devspace attach Attaches to a running container |
Requires stdin and tty to be true |
devspace use space [NAME] Switch into a different (existing) Space |
If you do not provide a [NAME] , DevSpace will show a selector with a list of all your Spaces. |
devspace use namespace [NAME] Switch to a different namespace |
If you do not provide a [NAME] , DevSpace will show a selector with a list of available namespaces. |
devspace use context [NAME] Switch to a different kube-context |
If you do not provide a [NAME] , DevSpace will show a selector with a list of available kube-contexts. |
You can configure DevSpace with the devspace.yaml
configuration file that should be placed within the root directory of your project. The general structure of a devspace.yaml
looks like this:
# File: ./devspace.yaml
version: {config-version}
images: # DevSpace will build these images in parallel and push them to the respective registries
{image-a}: ... # tells DevSpace how to build image-a
{image-b}: ... # tells DevSpace how to build image-b
...
deployments: # DevSpace will deploy these [Helm charts | manifests | ... ] one after another
- {deployment-1} # could be a Helm chart
- {deployment-2} # could be a folder with kubectl manifests
...
dev: # Special config options for `devspace dev`
ports: ... # Configure port-forwarding
open: ... # Configure auto-open for opening URLs after starting development mode
sync: ... # Configure file synchronization
logs: ... # Configure multi-container log streaming
autoReload: ... # Tells DevSpace when to redeploy (e.g. when a manifest file has been edited)
interactive: ... # Customize Interactive Mode (devspace dev -i)
dependencies: # Tells DevSpace which related projects should be deployed before deploying this project
- {dependency-1} # Could be another git repository
- {dependency-2} # Could point to a path on the local filesystem
...
vars: # Make your config dynamic and easier to share (ask a question if env var is not defined)
- name: DOMAIN_NAME # Will be used as ${DOMAIN_NAME} in config
question: Which hostname should we use for the ingress?
profiles: # Configure different profiles (e.g. dev, staging, prod, debug-backend)
- name: debug-backend
patches: # Change the config with patches when this profile is active
- op: replace
path: images.default.entrypoint
value: [npm, run, debug]
commands: # Custom commands: define reusable commands and run them via: devspace run [command-name]
- name: debug-backend # The best way to share your workflows with other team mates
command: devspace dev -i --profile=debug-backend
hooks: # Customize all workflows using hooks
- command: echo
args:
- "before image building"
when:
before:
images: all
# File: ./devspace.yaml
version: v1beta9
images:
backend: # Key 'backend' = Name of this image
image: my-registry.tld/image1 # Registry and image name for pushing the image
createPullSecret: true # Let DevSpace automatically create pull secrets in your Kubernetes namespace
deployments:
- name: quickstart-nodejs # Name of this deployment
helm: # Deploy using Helm
chart: # Helm chart to be deployed
name: component-chart # DevSpace component chart is a general-purpose Helm chart
version: 0.1.3
repo: https://charts.devspace.sh
values: # Override Values for chart (van also be set using valuesFiles option)
containers: # Deploy these containers with this general-purpose Helm chart
- image: my-registry.tld/image1 # Image of this container
resources:
limits:
cpu: "400m" # CPU limit for this container
memory: "500Mi" # Memory/RAM limit for this container
service: # Expose this component with a Kubernetes service
ports: # Array of container ports to expose through the service
- port: 3000 # Exposes container port 3000 on service port 3000
- name: database # A second deployment for a postgresql database
helm:
chart:
name: stable/postgresql
values:
postgresqlDatabase: "db_website"
postgresqlUsername: "db_user"
postgresqlPassword: ${DB_PASSWORD}
resources:
requests:
memory: 0
cpu: 0
dev:
ports:
forward:
- port: 3000
- port: 8080
remotePort: 80
image: backend
open:
- url: http://localhost:3000/login
sync:
- localSubPath: ./src
containerPath: .
image: backend
autoReload:
paths:
- ./manifests/**
dependencies:
- source:
git: https://github.com/my-api-server
- source:
path: ../my-auth-server
The following sections show code snippets with example sections of a devspace.yaml
for certain use cases.
# File: ./devspace.yaml
images:
auth-server:
image: dockerhub-username/my-auth-server # Push to Docker Hub (no registry hostname required) => uses ./Dockerfile by default
createPullSecret: true # Create a Kubernetes pull secret for this image before deploying anything
webserver:
image: myregistry.tld/username/my-webserver # Push to private registry
createPullSecret: true
dockerfile: ./webserver/Dockerfile # Build with --dockerfile=./webserver/Dockerfile
context: ./webserver # Build with --context=./webserver
database:
image: another-registry.tld/my-image # Push to another private registry
createPullSecret: true
dockerfile: ./db/Dockerfile # Build with --dockerfile=./db/Dockerfile
context: ./db # Build with --context=./db
# The following lines define custom tag schemata for this image (default tag schema is: ${DEVSPACE_RANDOM})
tags:
- ${DEVSPACE_USERNAME}-devspace-${DEVSPACE_GIT_COMMIT}-${DEVSPACE_RANDOM}
Take a look at the documentation for more information about configuring builds with Docker.
# File: ./devspace.yaml
images:
auth-server:
image: dockerhub-username/my-auth-server # Push to Docker Hub (no registry hostname required) => uses ./Dockerfile by default
build:
kaniko: # Build this image with kaniko
cache: true # Enable caching
insecure: false # Allow kaniko to push to an insecure registry (e.g. self-signed SSL certificate)
webserver:
image: myregistry.tld/username/my-webserver # This image will be built using Docker with kaniko as fallback if Docker is not running
createPullSecret: true
dockerfile: ./webserver/Dockerfile # Build with --dockerfile=./webserver/Dockerfile
context: ./webserver # Build with --context=./webserver
Take a look at the documentation for more information about building images with kaniko.
# File: ./devspace.yaml
images:
auth-server:
image: dockerhub-username/my-auth-server # Push to Docker Hub (no registry hostname required) => uses ./Dockerfile by default
build:
custom:
command: "./scripts/builder"
args: ["--some-flag", "flag-value"]
imageFlag: "image"
onChange: ["./Dockerfile"]
webserver:
image: myregistry.tld/username/my-webserver # This image will be built using Docker with kaniko as fallback if Docker is not running
createPullSecret: true
dockerfile: ./webserver/Dockerfile # Build with --dockerfile=./webserver/Dockerfile
context: ./webserver # Build with --context=./webserver
Take a look at the documentation for more information about using custom build scripts.
# File: ./devspace.yaml
deployments:
- name: quickstart-nodejs
helm:
componentChart: true
values:
containers:
- image: my-registry.tld/image1
resources:
limits:
cpu: "400m"
memory: "500Mi"
Learn more about:
# File: ./devspace.yaml
deployments:
- name: default
helm:
chart:
name: redis
version: "6.1.4"
repo: https://kubernetes-charts.storage.googleapis.com
Learn more about:
# File: ./devspace.yaml
deployments:
- name: my-nodejs-app
kubectl:
manifests:
- manifest-folder/
- some-other-manifest.yaml
Learn more about:
# File: ./devspace.yaml
deployments:
- name: my-deployment
kubectl:
manifests:
- my-manifests/
- more-manifests/
kustomize: true
Take a look at the documentation for more information about deploying manifests with kustomize.
# File: ./devspace.yaml
deployments:
- name: my-deployment
kubectl:
manifests:
- manifest-folder/
- some-other-manifest.yaml
- name: my-cache
helm:
chart:
name: redis
version: "6.1.4"
repo: https://kubernetes-charts.storage.googleapis.com
DevSpace processes all deployments of a project according to their order in the devspace.yaml
. You can combine deployments of different types (e.g. Helm charts and manifests).
Take a look at the documentation to learn more about how DevSpace deploys projects to Kubernetes.
# File: ./devspace.yaml
dependencies:
- source:
git: https://github.com/my-api-server
- source:
git: https:/my-private-git.tld/my-auth-server
- source:
path: ../my-auth-server
profile: production
Before deploying a project, DevSpace resolves all dependencies and builds a dependency tree which will then be deployed in a buttom-up fashion, i.e. the project which you call devspace deploy
in will be deployed last.
Take a look at the documentation to learn more about how DevSpace deploys dependencies of projects.
# File: ./devspace.yaml
dev:
sync:
- localSubPath: ./src # relative to the devspace.yaml
# Start syncing to the containers current working directory (You can also use absolute paths)
containerPath: .
# This tells devspace to select pods that have the following labels
labelSelector:
app.kubernetes.io/component: default
app.kubernetes.io/name: devspace-app
# Only download changes to these paths, but do not upload any changes (.gitignore syntax)
uploadExcludePaths:
- node_modules/
# Only upload changes to these paths, but do not download any changes (.gitignore syntax)
downloadExcludePaths:
- /app/tmp
# Ignore these paths completely during synchronization (.gitignore syntax)
excludePaths:
- Dockerfile
- logs/
The above example would configure the sync, so that:
./src
will be synchronized to the container's working directory .
(specified in the Dockerfile)./src/node_modules
would not be uploaded to the containerTake a look at the documentation to learn more about configuring file synchronization during development.
# File: ./devspace.yaml
dev:
autoReload:
paths:
- ./Dockerfile
- ./manifests/**
This configuration would tell DevSpace to redeploy your project when the Dockerfile changes or any file within ./manifests
.
Take a look at the documentation to learn more about configuring auto-reloading for development.
# File: ./devspace.yaml
images:
default:
image: ${DEVSPACE_USERNAME}/image-name
tags:
- ${DEVSPACE_GIT_COMMIT}-${DEVSPACE_TIMESTAMP}
- latest
DevSpace allows you to use certain pre-defined variables to make the configuration more flexible and easier to share with others. Additionally, you can add your own custom variables.
Take a look at the documentation to learn more about using variables for dynamic configuration.
# File: ./devspace-configs.yaml
images:
backend:
image: john/devbackend
backend-debugger:
image: john/debugger
deployments:
- name: app-backend
helm:
componentChart: true
values:
containers:
- image: john/devbackend
- image: john/debugger
profiles:
- name: production
patches:
- op: replace
path: images.backend.image
value: john/prodbackend
- op: remove
path: deployments[0].component.containers[1]
- op: add
path: deployments[0].component.containers
value:
image: john/cache
DevSpace allows you to define different profiles for different use cases (e.g. working on different services in the same project, starting certain debugging enviroment) or for different deployment targets (e.g. dev, staging production).
You can tell DevSpace to switch permenantly to another profile using this command: devspace use profile [config-name]
Alternatively, you can temporarily use a different profile for running a single command using the -p / --profile [NAME]
flag.
Take a look at the documentation to learn more about using config profiles and patches.
# File: ./devspace.yaml
hooks:
- command: echo
args:
- "before image building"
when:
before:
images: all
The command defined in this hook would be executed before building the images defined in the config.
Take a look at the documentation to learn more about using hooks.
This problem can be caused by many different things.
There is no single solution for this but here are some steps to troubleshoot this problem:
Run this command within your project:
devspace analyze
Make sure your Dockerfile works correctly. Use Google to find the best solutions for creating a Dockerfile for your application (often depends on the framework you are using).
If your pods are crashing, you might have the wrong ENTRYPOINT
or something is missing within your containers. A great way to debug this is to start the interactive development mode using:
devspace dev -i
With the interactive mode, DevSpace will override the ENTRYPOINT
in our Dockerfile with [sleep, 999999]
and open a terminal proxy. That means your containers will definitively start but only in sleep mode. After the terminal opens you can run the start command for your application yourself, e.g. npm start
.
Run the following commands to find issues:
# Failing Pods
kubectl get po # Look for terminated, crashed or pending pods (restart > 1 is usually not good)
kubectl describe po [POD_NAME] # Look at the crash reports Kubernetes provides
# Network issues
kubectl get svc # See if there is a service for your app
kubectl get ep # Make sure every service has endpoints (if not: make sure you are using the right ports in your devspace.yaml and make sure your pods are running)
kubectl get ing # Make sure there is an ingress for your app
Error response from daemon: Get https://[registry]/v2/: x509: certificate has expired or is not yet valid
This might happen when the VM of your Docker daemon has the wrong date/time.
Make sure the VM of your Docker daemon has the correct date/time. For Docker Desktop, you can run the following script to fix the issue:
HOST_TIME=$(date -u +"%Y.%m.%d-%H:%M:%S");
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/docker-vm alpine /bin/sh -c "date -s $HOST_TIME"
Help us make DevSpace the best tool for developing, deploying and debugging Kubernetes apps.
If you find a bug while working with the DevSpace, please open an issue on GitHub and let us know what went wrong. We will try to fix it as quickly as we can.
You are more than welcome to open issues in this project to:
This project is mainly written in Golang. If you want to contribute code:
GO111MODULE=on
GOFLAGS=-mod=vendor
git clone https://github.com/devspace-cloud/devspace && cd devspace
go build -o devspace[.exe]
./devspace [SOME_COMMAND]
See Contributing Guideslines for more information.
DevSpace is an open-source command-line tool that provides everything you need to develop, deploy and debug applications with Docker and Kubernetes. It lets you streamline deployment workflows and share them with your colleagues through a declarative configuration file devspace.yaml
.
YES. DevSpace is open-source and you can use it for free for any private projects and even for commercial projects.
loft is a multi-tenancy manager for Kubernetes which allows you to connect clusters that you want to make available for your engineering teams. After connecting a cluster, engineers will be able to create isolated namespaces and even virtual Kubernetes clusters within the cluster whenever they need access to Kubernetes.
loft is maintained by the same people who are developing DevSpace.
Yes. You can either use a local cluster such as Docker Desktop Kubernetes, minikube, or Kind, but you can also use a remote cluster such as GKE, EKS, AKS, RKE (Rancher), or DOKS.
Yes. DevSpace is using your regular kube-context. As long as you can run kubectl
commands with a cluster, you can use this cluster with DevSpace as well.
Helm is the package manager for Kubernetes. Packages in Helm are called Helm charts. Learn more about Helm charts.
You can use the DevSpace for any private or commercial projects because it is licensed under the Apache 2.0 open source license.