STEP 1

Install the DevSpace CLI

You can install the DevSpace CLI with the following scripts:

Windows Powershell
Mac Terminal
Linux Bash
Make sure you are ADMIN!1 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'2 md -Force "$Env:Programfiles\devspace"3 wget -UseBasicParsing ((Invoke-WebRequest -URI "https://api.github.com/repos/covexo/devspace/releases/latest" -UseBasicParsing).Content -replace ".*`"(https://github.com[^`"]*devspace-windows-amd64.exe)`".*","`$1") -o $Env:Programfiles\devspace\devspace.exe4 & "$Env:Programfiles\devspace\devspace.exe" "install"
COPY

As an alternative to the installer scripts, you can simply download the binary for your platform from the GitHub Releases page and add the binary to your PATH.

STEP 2

Install Docker

For Linux, Mac and Windows 10 Pro: Follow this link to download and install the Docker Community Edition.

For Windows 10 Home and others: Follow this link to download and install the Docker Toolbox.

Note

If you already have Docker installed, just continue with the next step.

After installing Docker, make sure you are logged in to Docker Hub with this command:

1 docker login
COPY

Note

If you do not have a Docker Hub account, follow this link to sign up for Docker Hub.

STEP 3

Checkout the Demo Project

To show you how to start a DevSpace, clone our demo app with this command:

1 git clone https://github.com/covexo/devspace-quickstart-nodejs2 cd devspace-quickstart-nodejs
COPY

This project contains a mininal webserver with a “Hello World” application. It is only used to demonstrate how the DevSpace CLI works in this quickstart guide. Generally, the DevSpace CLI works with any programming language and can be used with any existing project.

STEP 4

Start the DevSpace

Run devspace up to start a DevSpace for the demo project:

1 devspace up
COPY

When running devspace up for the first time, the DevSpace CLI will automatically create a configuration for your DevSpace. There are a couple of basic questions that you need to answer during this process:

1 What is the major programming language of your project?2 javascript
COPY

For the demo app, just confirm the suggested language with ENTER.

TIP

If your programming language is not listed as supported language, just choose none. This will create a basic Dockerfile for you, which you should customize later on.

The next question asks if you want to use the DevSpace Cloud or your own Kubernetes cluster. To get started quickly, choose to use the DevSpace Cloud and confirm with ENTER.

1 Do you want to use the DevSpace Cloud? (free, ready-to-use Kubernetes)2 yes
COPY

After choosing the DevSpace Cloud, a browser window will open and show the login for the DevSpace Cloud. Currently, we only support GitHub as login method. Click on Login with GitHub and confirm your login with Authorize covexo.

Note

Using the DevSpace Cloud is optional. The DevSpace CLI works with every Kubernetes cluster (cloud, self-hosted, minikube).

Optionally, you can now add the DevSpace Cloud as Kubernetes context. Adding the DevSpace Cloud to your ./kube/config file allows you to run kubectl commands within your Kubernetes namespace provided by the DevSpace Cloud.

1 Do you want to add the DevSpace Cloud to the $HOME/.kube/config file?2 yes
COPY

For this quickstart guide, we want to use Docker Hub as our image registry.

1 Which registry do you want to push to? (‘hub.docker.com’ or URL)2 hub.docker.com
COPY

TIP

The DevSpace CLI can push to any Docker registry (public and private). If you want to know more about pushing images to a private registry, take a look at our docs page for using private registries.

When using Docker Hub, the DevSpace CLI tries to detect your Docker username and suggest a name for your image accordingly:

1 Which image name to you want to use on Docker Hub?2 [your-docker-username]/devspace
COPY

Make sure you have the permission to push this image to Docker Hub and confirm with ENTER.

1 Do you want to create a pull secret automatically for this image?2 yes
COPY

When Kubernetes pulls a private image from a registry, it needs an image pull secret. The DevSpace CLI can automatically create such a secret for you. Choose yes if you plan to make your image private or create an image pull secret manually within your DevSpace Cloud namespace.

STEP 5

Code within the DevSpace

After running devspace up and starting your DevSpace, the DevSpace CLI will initialize a terminal session for you. Every command you run within this terminal will directly be executed within a container of your DevSpace. To start our demo application, run the following command within the DevSpace terminal:

1 npm run dev
COPY

This will start a small web server which listens on port 3000 within your DevSpace. Because the DevSpace CLI automatically added a port-forwarding config for the EXPOSE 3000 statement in the Dockerfile of the demo app, you can now open http://localhost:3000/ within your browser and directly access your demo application.

TIP

If you want to open a second terminal session in parallel, use the command devspace enter. Because most applications need more than one container, you can also change your default terminal container or use devspace enter -c [container-name].

Our demo application uses a hot reloading tool and is configured to reload the web server whenever you change a file. So, let’s take a look at the following file:

/index.js1 const express = require('express')2 const app = express()3 const port = 30004 5 app.get('/', (req, res) => res.send('Hello World!'))6 7 app.listen(port, () => console.log("Example app listening on port " + port))
COPY

Edit line 5 of this file, so the file looks like this:

/index.js1 const express = require('express')2 const app = express()3 const port = 30004 5 app.get('/', (req, res) => res.send('Hello DevSpace!'))6 7 app.listen(port, () => console.log("Example app listening on port " + port))
COPY

After saving the file, the DevSpace CLI will immediatly synchronize the local code change to your DevSpace. This will trigger the hot reloading tool which reloads the web server. If you reload your browser afterwards, you can directly see the result of your change.

Note

By default, the DevSpace CLI will synchronize all project files in both directions (up and down). To use more advanced sync rules, take a look at our sync config guide.

Congratulations! You build your first cloud native application with a DevSpace.
STEP 6

Deploying your Application (optional)

After building your your application, you can also deploy it with the DevSpace CLI. Simply run the following command:

1 devspace deploy
COPY

The DevSpace CLI will print a URL at the end of the deployment process. After the containers are started (this may take up to 5 minutes), your application will be publicly available at this URL. To update your deployment, simply run devspace deploy again.

TIP

By default, you will have a so-called cloudProviderDeployTarget with the name "production" within your config file in .devspace/config.yaml. When you run devspace deploy, your helm chart will be deployed to this target. For more information about deploying applications with DevSpace CLI, check our DevSpace Deployment Guide.

What next?

You may want to take a look at the examples on GitHub or check out the DevSpace CLI Documentation

What is a DevSpace?

A DevSpace is a cloud native workspace that lets you build, test and run code directly inside any Kubernetes cluster.

What is the DevSpace CLI?

The DevSpace CLI is an open-source, command-line tool that allows you to create DevSpaces and connect them with your local workspace.

What is the DevSpace Cloud?

The DevSpace Cloud lets you easily create and manage hosted DevSpaces without the need to maintain your own Kubernetes cluster.

Do I need Docker or Kubernetes to use a DevSpace?

No! We recommend installing Docker but it is not required. If you do not have a Kubernetes cluster, simply use the DevSpace Cloud.

Is the DevSpace CLI completly free and open source?

Yes! You can find the source code on GitHub. The tool is free to use in any private and even in commercial projects.

How much does the DevSpace Cloud cost?

The DevSpace Cloud allows you to create
1 DevSpace for free. Any additional DevSpace will cost $10 / month.