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 Sessiondevspace 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 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 Loft Documentation
npm install -g devspace
yarn global add devspace
brew install devspace
# AMD64 / Intel
curl -s -L "https://github.com/loft-sh/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 install devspace /usr/local/bin;
# ARM64 / Silicon Mac
curl -s -L "https://github.com/loft-sh/devspace/releases/latest" | sed -nE 's!.*"([^"]*devspace-darwin-arm64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o devspace && chmod +x devspace;
sudo install devspace /usr/local/bin;
# AMD64
curl -s -L "https://github.com/loft-sh/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
# ARM64
curl -s -L "https://github.com/loft-sh/devspace/releases/latest" | sed -nE 's!.*"([^"]*devspace-linux-arm64)".*!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/loft-sh/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/loft-sh/devspace-quickstart-nodejs && cd devspace-quickstart-nodejs |
Python | git clone https://github.com/loft-sh/devspace-quickstart-python && cd devspace-quickstart-python |
Java | git clone https://github.com/loft-sh/devspace-quickstart-java && cd devspace-quickstart-java |
Ruby | git clone https://github.com/loft-sh/devspace-quickstart-ruby && cd devspace-quickstart-ruby |
Golang | git clone https://github.com/loft-sh/devspace-quickstart-golang && cd devspace-quickstart-golang |
PHP | git clone https://github.com/loft-sh/devspace-quickstart-php && cd devspace-quickstart-php |
ASP.NET | git clone https://github.com/loft-sh/devspace-quickstart-asp-dotnet && cd devspace-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
Tell DevSpace which namespace to use and start the development mode:
devspace use namespace my-namespace # will be created by DevSpace if it does not exist
devspace dev
As soon as the terminal opens up, you can start your application:
# Node.js
npm start
# Python
python main.py
# Ruby
bundle exec rails server -p 3000 -b 0.0.0.0
# Golang
go run main.go
# Java
mvn package -T 1C -U -Dmaven.test.skip=true # or: gradle build
java -jar target/.../my.jar
# .NET
dotnet run
# PHP
# Your app should be running already but you can still run:
php ...
composer ...
You can now:
http://localhost:PORT
in your browsernodemon
and your application will automatically reload when you edit source code filesWhen 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:8090devspace 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.
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 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
terminal: ... # Customize the terminal to be opened
logs: ... # Configure multi-container log streaming
replacePods: ... # Replace pods during development mode
autoReload: ... # Tells DevSpace when to redeploy (e.g. when a manifest file has been edited)
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: v1beta10
images:
backend: # Key 'backend' = Name of this image
image: my-registry.tld/image1 # Registry and image name for pushing the image
deployments:
- name: database # A deployment for a postgresql database
kubectl: # Deploy using kubectl
manifests:
- postgresql/statefulset.yaml
- postgresql/service.yaml
- name: quickstart-nodejs # A second 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
dev:
ports:
imageName: backend
forward:
- port: 3000
- port: 8080
remotePort: 80
open:
- url: http://localhost:3000/login
sync:
- imageName: backend
localSubPath: ./src
terminal:
imageName: backend
replacePods:
- imageName: backend
replaceImage: loftsh/javascript:latest
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
tags:
- devspace-${DEVSPACE_GIT_COMMIT}-######
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:
kustomize: true
manifests:
- my-manifests/
- more-manifests/
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: john/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/loft-sh/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.
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.
You can use the DevSpace for any private or commercial projects because it is licensed under the Apache 2.0 open source license.
Vagrant.configure(2) do |config| # Specify the base box config.vm.box = "ubuntu/trusty64" # Setup port forwarding config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: tru
转载自https://blog.csdn.net/maopig/article/details/7195048 在linux下,/dev目录是很重要的,各种设备都在下面。下面简单总结一下: dev是设备(device)的英文缩写。/dev这个目录对所有的用户都十分重要。因为在这个目录中包含了所有Linux系统中使用的外部设备。但是这里并不是放的外部设备的驱动程序,这一点和windows,dos操作
多行注释: Ctrl + / 或者 Ctrl + . 取消多行注释: Ctrl + , 这里记录一些个人使用Devcpp时,摸索出来的代码编辑快捷键,感觉非常有用。如果是熟悉eclipse软件使用的开发者,对它在标号上的光标跳转,文本的选取,翻页等等快捷键的使用一定不会陌生,相比之下,很多eclipse里面使用的快捷键,同样适用于Devcpp。 说明一下,这里测试快捷键用的Devcpp的版本号为5
多行注释: Ctrl + / 或者 Ctrl + . 取消多行注释: Ctrl + , 这里记录一些个人使用Devcpp时,摸索出来的代码编辑快捷键,感觉非常有用。如果是熟悉eclipse软件使用的开发者,对它在标号上的光标跳转,文本的选取,翻页等等快捷键的使用一定不会陌生,相比之下,很多eclipse里面使用的快捷键,同样适用于Devcpp。 说明一下,这里测试快捷键用的Devcpp的版本号为5
Dev代码补全 估计好多人都和我一样,为了编程方便使用Dev,但是更新的5.11后,像定义一个容器啊,或者是printf了,就得自己全部输进去,根本不给后面的自动补全内容。在这里为大家解决一下这个问题。DEV其实支持代码补全,只是因为缺省的快捷键是Ctrl+Space,神奇的要命,和切换输入法快捷键完完全全冲突。 解决方法: 打开工具 -> 快捷键选项 ->Show code completion
转载自 https://blog.csdn.net/maopig/article/details/7195048 在linux下,/dev目录是很重要的,各种设备都在下面。下面简单总结一下: dev是设备(device)的英文缩写。/dev这个目录对所有的用户都十分重要。因为在这个目录中包含了所有Linux系统中使用的外部设备。但是这里并不是放的外部设备的驱动程序,这一点和wi
这里记录一些个人使用Devcpp时,摸索出来的代码编辑快捷键,感觉非常有用。如果是熟悉eclipse软件使用的开发者,对它在标号上的光标跳转,文本的选取,翻页等等快捷键的使用一定不会陌生,相比之下,很多eclipse里面使用的快捷键,同样适用于Devcpp。 说明一下,这里测试快捷键用的Devcpp的版本号为5.6.3,同时还穿插它与eclipse,Visual Studio 2013(以下简写为