Are you a new contributor to Deis? Your first Pull Request could earn you credit at DigitalOcean! Submit your changes and then email email@example.com. When your PR is merged, the maintainer team will send you a DigitalOcean credit based on the value of your contribution.
This document is for developers who are interested in working directly on the Deis codebase. In this guide, we walk you through the process of setting up a local development environment. While there are many ways to set up your Deis environment, this document covers a specific setup:
We try to make it simple to hack on Deis. However, there are necessarily several moving pieces and some setup required. We welcome any suggestions for automating or simplifying this process.
If you’re just getting into the Deis codebase, look for GitHub issues with the label easy-fix. These are more straightforward or low-risk issues and are a great way to become more familiar with Deis.
You can develop on any supported platform including your laptop, cloud providers or on bare metal. We strongly recommend a minimum 3-node cluster. We strongly suggest using Vagrant and VirtualBox for your virtualization layer during development.
At a glance, you will need:
sudo pip install virtualenv)
In most cases, you should simply install according to the instructions. There are a few special cases, though. We cover these below.
If your local workstation does not support the linux/amd64 target environment, you will have to install Go from source with cross-compile support for that environment. This is because some of the components are built on your local machine and then injected into a docker container.
Homebrew users can just install with cross compiling support:
$ brew install go --with-cc-common
It is also straightforward to build Go from source:
$ sudo su $ curl -sSL https://golang.org/dl/go1.5.src.tar.gz | tar -v -C /usr/local -xz $ cd /usr/local/go/src $ # compile Go for our default platform first, then add cross-compile support $ ./make.bash --no-clean $ GOOS=linux GOARCH=amd64 ./make.bash --no-clean
Once you can compile to
linux/amd64, you should be able to compile Deis’
components as normal.
Deis needs a Docker registry running independently of the Deis cluster. On OS X, you will need Docker Machine (http://docs.docker.com/machine/install-machine/) to run the registry inside of a VirtualBox image.
Previously, Deis used boot2docker to run the registry. However, Docker has deprecated boot2docker in favor of Docker Machine.
Install Docker Machine according to the normal installation instructions. Then create a new image for hosting your Deis Docker registry:
$ docker-machine create --driver virtualbox --virtualbox-disk-size=100000 \ --engine-insecure-registry=192.168.0.0/16 deis-registry
This will create a new virtual machine named deis-registry that will take up as much as 100,000 MB of disk space. Registries tend to be large, so allocating a big disk is a good idea.
Once the deis-registry machine exists, source its values into your environment so your docker client knows how to use the new machine.
$ eval "$(docker-machine env deis-registry)"
Because the registry that we create will not have a valid SSL certificate, we run the local registry as an insecure (HTTP, not HTTPS) registry. Each time Docker Machine reboots, the registry will get a new IP address somewhere in the 192.168.0.0/16 range. We must declare that explicitly when configuring Docker Machine.
At this point, our deis-registry VM can now serve as a registry for Deis’ Docker images. Later we will return to this.
Once the prerequisites have been met, we can begin to work with Deis.
To get Deis running for development, first fork the Deis repository,
then clone your fork of the repository. Since Deis is predominantly written
in Go, the best place to put it is in
$ mkdir -p $GOPATH/src/github.com/deis $ cd $GOPATH/src/github.com/deis $ git clone firstname.lastname@example.org:<username>/deis.git $ cd deis
By checking out the forked copy into the namespace
we are tricking the Go toolchain into seeing our fork as the “official”
If you are going to be issuing pull requests and working with official Deis
repository, we suggest configuring Git accordingly. There are various strategies
for doing this, but the most common is to add an
$ git remote add upstream https://github.com/deis/deis.git
For the sake of simplicity, you may want to point an environment variable to your Deis code:
Throughout the rest of this document,
$DEIS refers to that location.
A number of Deis developers prefer to pull directly from
<username>/deis. If that workflow suits you better, you can set it
up this way:
$ git clone email@example.com:deis/deis.git $ cd deis $ git config remote.origin.pushurl firstname.lastname@example.org:<username>/deis.git
In this setup, fetching and pulling code will work directly with the upstream repository, while pushing code will send changes to your fork. This makes it easy to stay up to date, but also make changes and then issue pull requests.
deisctl is used for interacting with the Deis cluster. While you can use an
deisctl binary, we recommend that developers build it from source.
$ cd $DEIS/deisctl $ make build $ make install # optionally
This will build just the
deisctl portion of Deis. Running
make install will
deisctl command in
You can verify that
deisctl is correctly built and installed by running
deisctl -h. That should print the help text and exit.
To connect to the cluster using
deisctl, you must add the private key to
For example, when using Vagrant:
$ ssh-add ~/.vagrant.d/insecure_private_key
DEISCTL_TUNNEL so the
deisctl client on your workstation can connect to
one of the hosts in your cluster:
$ export DEISCTL_TUNNEL=172.17.8.100
A number of times during this setup, tools will suggest that you export various environment variables. You may find it convenient to store these in your shell’s RC file (~/.bashrc or ~/.zshrc).
deis client is also written in Go. Your Deis client should match your server’s
deisctl, we recommend that developers build
deis from source:
$ cd $DEIS/client $ make build $ make install # optionally $ ./deis Usage: deis <command> [<args>...]
Our host system is now configured for controlling a Deis cluster. The next thing to do is begin standing up a development cluster.
When developing locally, we want deisctl to check our local unit files so that
any changes are reflected in our Deis cluster. The easiest way to do this is
to set an environment variable telling deisctl where to look. Assuming
$DEIS points to the location if the deis source code, we want
something like this:
To start up and configure a local vagrant cluster for development, you can use
$ make dev-cluster
This may take a while to run the first time. At the end of the process, you
will be prompted to run
deis start platform. Hold off on that task for now.
We will come back to it later.
To verify that the cluster is running, you should be able to connect to the nodes on your Deis cluster:
$ vagrant status Current machine states: deis-01 running (virtualbox) deis-02 running (virtualbox) deis-03 running (virtualbox) $ vagrant ssh deis-01 Last login: Tue Jun 2 18:26:30 2015 from 10.0.2.2 * * * ***** ddddd eeeeeee iiiiiii ssss * * * * * * d d e e i s s * * ***** ***** d d e i s ***** * * * d d e i s * * * * * * d d eee i sss ***** * * ***** d d e i s * ***** * * d d e i s * * * * * * d d e e i s s ***** ***** * * ddddd eeeeeee iiiiiii ssss Welcome to Deis Powered by CoreOS
With a dev cluster now running, we are ready to set up a local Docker registry.
The development workflow requires Docker Registry set at the
environment variable. If you’re developing locally you can use the
target to spin up a quick, disposable registry inside a Docker container.
dev-registry prints the registry’s address and port when using
otherwise, use your host’s IP address as returned by
ifconfig with port 5000 for
$ make dev-registry To configure the registry for local Deis development: export DEV_REGISTRY=192.168.59.103:5000
It is important that you export the
DEV_REGISTRY variable as instructed.
If you are developing elsewhere, you must set up a registry yourself. Make sure it meets the following requirements:
- You can push Docker images from your workstation
- Hosts in the cluster can pull images with the same URL
If the development registry is insecure and has an IP address in a range other than
192.168.0.0/16, you’ll have to modify
and whitelist your development registry so the daemons can pull your custom components.
The full environment is prepared. You can now build Deis from source code and then run the platform.
We’ll do three steps together:
deisctl start platform)
Conveniently, we can accomplish all three in one step:
$ make deploy
deisctl list should display all of the services that your Deis
cluster is currently running.
You can now use your Deis cluster in all of the usual ways.
At this point, you are running Deis from the code in your Git clone. But since rebuilding like this is time consuming, Deis has a simplified developer workflow more suited to daily development.
Makefile targets designed to simplify the development workflow.
This workflow is typically:
- Update source code and commit your changes using
make -C <component> buildto build a new Docker image
make -C <component> dev-releaseto push a snapshot release
make -C <component> restartto restart the component
This can be shortened to a one-liner using the
$ make -C controller deploy
You can also use the same tasks on the root
Makefile to operate on all
components at once. For example,
make deploy will build, dev-release,
and restart all components on the cluster.
You can export the
DEIS_STATELESS=True environment variable to skip all
store components when using the root
Makefile. Useful when working
on a stateless platform (Running Deis without Ceph).
In order to cut a dev-release, you must commit changes using
git to increment
the SHA used when tagging Docker images
Deis ships with a comprehensive suite of automated tests, most written in Go. See Testing Deis for instructions on running the tests.
Once your controller is running, here are some helpful commands.
$ deisctl journal controller
$ make -C controller build push restart
$ make -C controller restart
$ deisctl list # determine which host runs the controller $ ssh core@<host> # SSH into the controller host $ nse deis-controller # inject yourself into the container $ cd /app # change into the django project root $ ./manage.py shell # get a django shell
Have commands other Deis developers might find useful? Send us a PR!