A functional Consul install

If you don't have one, Install Consul is a great resource to get one set up quickly.

In our examples below, we'll assume a Consul install on a local development machine, listening on the machine's IP address (not localhost) on port 8500, with a datacenter named "dc1", but the concepts should extend to a larger installation. We'll also assume a working docker installation.

Install the tbnctl command line interface (CLI)

tbnctl is a CLI for interacting with the Turbine Labs public API, and is used throughout this guide to set up tbnproxy. Install tbnctl with these commands (Requires installation of Go, and that $GOPATH/bin is in your $PATH):

$ go get -u
$ go install
$ tbnctl login

Use your Houston username and password to login.

Username []:

See the tbnctl Guide for more information.

Get an API Access Token

Create an API Access Token using tbnctl:

$ tbnctl access-tokens add "demo key"
  "access_token_key": "<redacted>",
  "description": "demo key",
  "signed_token": "<redacted>",
  "user_key": "<redacted>",
  "created_at": "2017-08-25T22:11:30.907200482Z",
  "checksum": "d60ed8a6-1a40-49a5-5bb1-5bad322d9723"

You'll need the value of signed_token later on, so keep it somewhere secure.

Create a Zone

The highest-level unit of organization in the Turbine Labs API is a zone. We'll use the zone "testbed" in this guide, but you can substitute your own if you've already created one. To create the testbed zone, run

$ tbnctl init-zone testbed

You should now be able to see your zone by running

$ tbnctl list zone

Setting up service discovery

First, install and run tbncollect on an instance of server of your choice, with your environment variables defined inside of the Docker command, using the signed_token you obtained with tbnctl:

$ docker run -d \
  -e "TBNCOLLECT_API_KEY=<your signed_token>" \
  -e "TBNCOLLECT_API_ZONE_NAME=<your zone name>" \
  -e "TBNCOLLECT_CMD=consul" \
  -e "TBNCOLLECT_CONSUL_HOSTPORT=<your ip address>:8500" \

Use tbncollect help consul to determine which environmental variables you can use and modify.

The all-in-one demo

We'll use the same client application described in our quickstart for these examples. To start the all-in-one client, on port 8080, first run:

$ docker run -p 8080:8080 -d turbinelabs/all-in-one-client:0.14.2

Then expose the container as a Consul service:

$ curl <your ip address>:8500/v1/catalog/register -d '
  "Datacenter": "dc1",
  "Node": "all-in-one-client",
  "Address": "<your ip address>",
  "Service": {
    "ID": "all-in-one-client",
    "Service": "all-in-one-client",
    "Tags": ["tbn-cluster"],
    "Port": 8080

Now start the all-in-one server, on port 8081:

$ docker run -d \
  -p 8081:8080 \
  -e "TBN_COLOR=1B9AE4" \
  -e "TBN_NAME=blue" \

Then expose the container as a Consul service:

$ curl <your ip address>:8500/v1/catalog/register -d '
  "Datacenter": "dc1",
  "Node": "all-in-one-server-blue",
  "Address": "<your ip address>",
  "NodeMeta": {
    "stage": "prod",
    "version": "blue"
  "Service": {
    "ID": "all-in-one-server-blue",
    "Service": "all-in-one-server",
    "Tags": ["tbn-cluster"],
    "Port": 8081

Ensure that these containers have started correctly by running:

$ docker ps
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS              PORTS                    NAMES
71988c96464a        turbinelabs/all-in-one-server:0.14.2   "/bin/sh -c 'node ..."   57 seconds ago      Up 55 seconds>8080/tcp   eloquent_franklin
bd949c322beb        turbinelabs/all-in-one-client:0.14.2   "/bin/sh -c 'envte..."   3 minutes ago       Up 3 minutes>8080/tcp   upbeat_snyder
8d759aff4c90        turbinelabs/tbncollect:latest         "/sbin/my_init"          3 minutes ago       Up 3 minutes                                 musing_roentgen

Now verify that tbncollect has discovered your new pods and added them to the appropriate clusters by running:

$ tbnctl list --format=summary cluster

You should see a name: all-in-one-client cluster and a name: all-in-one-server cluster, each with a single instance. It may take up to 30 seconds for the new clusters to appear.

Adding a domain and proxy

Tbnproxy is the container that handles request routing. It serves traffic for a set of domains, which in turn contain release groups and routes. We'll create the domain first.

Go to, and login with your email address and password.

Click "Settings" in the top right portion of the screen, then "Edit Routes".

The screen should indicate that you have no domains. Click "Add One".

type "testbed-domain" in the Name field, then Click "Add Domain"

The screen should now indicate that you have no proxies. Click "Add One".

type "testbed-proxy" in the Name field, and then check the box next to testbed-domain:80. This indicates that the proxy you're adding will serve traffic for testbed-domain. Click "Add Proxy"

Deploying tbnproxy

Now we're ready to deploy tbnproxy, using the signed_token you obtained with tbnctl, along with the Zone and Proxy names:

$ docker run -d \
  -p 80:80 \
  -e "TBNPROXY_API_KEY=<your signed_token>" \
  -e "TBNPROXY_API_ZONE_NAME=<your zone name>" \
  -e "TBNPROXY_PROXY_NAME=<your proxy name>" \

Verifying your deploy

You should now have tbnproxy running locally on port 80, serving both the all- in-one client and server. Visit localhost in your browser to verify.

Demo exercises

Now that you're up and running with Houston on Consul, let's walk through some product use cases.

What's going on here?

The all-in-one client/server provide a UI and a set of services that help visualize changes in the mapping of user requests to backend services. This lets you visualize the impact of Houston on a real deployment without having to involve real customer traffic or load generators.

The application is composed of three sets of blocks, each simulating a user making a request. These are simple users, and they all repeat the same request forever. The services they call return a color. When a user receives a response it paints the box that color, then waits a random amount of time to make another request. While it’s waiting the colors in the box fade. Users are organized into rows based on URL.

You should see pulsating blue boxes for each service, to indicate the initial state of your production services.

Deployed state

Let’s dig deeper into how tbnproxy routes traffic. Traffic is received by a proxy that handles traffic for a given domain. The proxy maps requests to service instances via routes and rules. Routes let you split your domain into manageable segments, for example /bar and /baz. Rules let you map requests to a constrained set of service instances in clusters, for example “by default send traffic to servers labeled stage=prod. Clusters contain sets of service instances, each of which can be labeled with key/value pairs to provide more information to the routing engine.

Your environment should look like the following:

There is a single domain, local.domain that contains two routes. /api handles requests to our demo service instances, and / handles requests for everything else (in this case the demo app). There are two clusters:

  • The all-in-one-server cluster has one instance, labeled as stage=prod,version=blue. The all-in-one-client cluster has a single instance labeled stage=prod.

  • The all-in-one-server cluster has a single instance labeled stage=prod.

Set up an initial route

The rules currently map api traffic to all instances in the cluster. To enable the release workflow we need to constrain routing to a single version at a single stage, so let's configure Houston to route traffic to the blue version.

  1. Make sure you have the 'testbed' zone selected in the top left portion of the screen.
  2. Click the "Settings" menu in the top right portion of the screen, and then select "Edit Routes".
  3. Click the "Select View" menu in the top left portion of the screen, and select the api route.
  4. Change 1 to 'all-in-one-server' to 1 to 'all-in-one-server' stage = prod & version = blue
  5. Click "Save Release Group"

If you look at the all-in-one client you should still see all blue blocks, because we've constrained the routing to only go to servers in the cluster labeled with version=blue.

Deploying a new version

Now we'll deploy a new version of the server that returns green as the color to paint blocks, on port 8082:

$ docker run -d \
  -p 8082:8080 \
  -e "TBN_COLOR=83D061" \
  -e "TBN_NAME=green" \

Then expose the container as a Consul service:

$ curl <your ip address>:8500/v1/catalog/register -d '
  "Datacenter": "dc1",
  "Node": "all-in-one-server-green",
  "Address": "<your ip address>",
  "NodeMeta": {
    "stage": "prod",
    "version": "green"
  "Service": {
    "ID": "all-in-one-server-green",
    "Service": "all-in-one-server",
    "Tags": ["tbn-cluster"],
    "Port": 8082

Ensure that all containers have started correctly by running:

$ docker ps
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS              PORTS                          NAMES
d544d8bcecdb        turbinelabs/all-in-one-server:0.14.2   "/bin/sh -c 'node ..."   43 seconds ago      Up 41 seconds>8080/tcp         fervent_kilby
c90dea77b4fb        turbinelabs/tbnproxy:latest           "/sbin/my_init"          6 minutes ago       Up 6 minutes>80/tcp, 9999/tcp   serene_hodgkin
71988c96464a        turbinelabs/all-in-one-server:0.14.2   "/bin/sh -c 'node ..."   13 minutes ago      Up 13 minutes>8080/tcp         eloquent_franklin
bd949c322beb        turbinelabs/all-in-one-client:0.14.2   "/bin/sh -c 'envte..."   15 minutes ago      Up 15 minutes>8080/tcp         upbeat_snyder
8d759aff4c90        turbinelabs/tbncollect:latest         "/sbin/my_init"          15 minutes ago      Up 15 minutes                                      musing_roentgen

Your environment now looks like the following:

The new instance has been added to the all-in-one-server cluster, but no traffic is routed to it. When returning to your client app, you should still see only blue blocks, because we set our routing constraints in the previous step.

Testing before release

Let’s test our green version before we release it to customers. tbnproxy allows you to route to service instances based on headers set in the request. Navigate to, log in and select the zone you’re working with (testbed by default). Click "Settings" -> "Edit Routes", and select testbed-domain:80/api from the top left dropdown. You should see the following screen

Click “Add Rule” from the top right, and enter the following values.

This tells the proxy to look for a header called X-Tbn-Version. If the proxy finds that header, it uses the value to find servers in the all-in-one-client cluster that have a matching version label. For example, setting X-Tbn-Version: blue on a request would match blue servers, and X-Tbn-Version: green would match green servers.

The demo app converts a X-Tbn-Version query parameter into a header in calls to the backend; if you navigate to http://<your external IP>?X-Tbn-Version=green you should see all green boxes. Meanwhile going to http://<your-client> without that parameter still shows blue.

This technique is extremely powerful. New software was previewed in production without customers being affected. You were able to test the new software on the live site before releasing to customers. In a real world scenario your testers can perform validation, you can load test, and you can demo to stakeholders without running through a complicated multi-environment scenario, even during another release.

Incremental release

Now we're ready to do an incremental release from blue to green. Right now the default rules for /api send all traffic to blue. Let’s introduce a small percentage of green traffic to customers.

Navigate to, then click "Release Groups" below the top-line charts. The row "server" should be marked "RELEASE READY". Click anywhere in the row to expand it, then click "Start Release".

Let's send 25% of traffic to our new green version by moving the slider and clicking "Start Release". The release group should now be marked "RELEASING".

The all in one client should now show a mix of blue and green. You can increment the green percentage as you like. When you get to 100%, the release is complete.

Congratulations! You've safely and incrementally released a new version of your production software. Both blue and green versions are still running; if a problem were found with green, a rollback to blue would be just as easy.

Testing latency and error rates

In order to demo what errors and latency issues may look like in a production environment, we implemented a few parameters that can be set to illustrate these scenarios. By default, each of the demo servers returns a successful (status code 200) response with its color (as a hex string) as the response body.

URL parameters passed to the client web page at can be used to control the mean latency and error rate of each of the different server colors.

An example

The following URL will show an error rate and delayed response for green and blue servers.

http://<your external IP>/?x-blue-delay=25&x-blue-error=.001&x-green-delay=10&x-green-error=.25

This will simulate a bad green release, and a need to rollback to a known good blue release.

Parameter effect

These parameters can be modified in the above example as follows:

  • x-color-delay: sets the mean delay in milliseconds.
  • x-color-error: sets the error rate, describe as a fraction of 1 (e.g., 0.5 causes an error 50% of the time).

The latency and error rates are passed to the demo servers as HTTP headers with the same name and value as the URL parameters described. You can use these parameters to help you visualize the effects of a bad release, or an issue with the code in a new version of your application, which would be cause to step-down the release and return traffic to a known-good version.

Driving synthetic traffic

If you'd like to drive steady traffic to your all-in-one server without keeping a browser window open, you can run the all-in-one-driver image. If you are running tbnproxy on a port other than 80, you'll need to specify it using the ALL_IN_ONE_DRIVER_HOST environment variable. You can also add error rates and latencies for various using environment variables:

$ docker run -d \
  -e "ALL_IN_ONE_DRIVER_LATENCIES=blue:50ms,green:20ms" \
  -e "ALL_IN_ONE_DRIVER_ERROR_RATES=blue:0.01,green:0.005" \


Now that you've seen what Houston can do with our all-in-one examples and Consul , you can try it out with your own services. If you have questions or run into any trouble, please drop us a line, we're here to help.