Documentation

Sock Shop on Nomad

Goal

The goal of this demo is to demonstrate running the Sock Shop on Nomad while using Weave Net to provide secure networking, and Weave Scope to monitor the deployment.

Dependencies

Weave Cloud

There are two options available here.

  • A local instance of Weave Scope which is already configured to run and become availabe on port 4040.
  • Create a account at cloud.weave.works and using the provided token set the environment variable export SCOPE_TOKEN=<token>

Getting Started

This example sets up a Nomad cluster with one server and three nodes. Make sure you have at least 6272MB of RAM available.

The easiest way to get started is to simply run

$ vagrant up

This will:

  • Bring up the Vagrant boxes
  • Install all the dependencies
  • Setup the Nomad cluster

Disclaimer: If this is the first time that you are running this, it may take a while pulling all the Vagrant images, installing packages and what not, so please be patient. The output is quite verbose, so at all points you shoulld know what is going on and what went wrong if anything fails.

Run with Fluentd + ELK based logging

Although this step is option, if you want to run the application using a more advanced logging setup based on Fluentd + ELK stack, you can do so by running the following Nomad jobs:

root@local:/# vagrant ssh ci-sockshop-nomad-node1
ubuntu@ci-sockshop-nomad-node1:/# nomad run logging-elk.nomad
ubuntu@ci-sockshop-nomad-node1:/# nomad run logging-fluentd.nomad

Once both jobs finish starting you can view the Kibana interface by opening page http://192.168.59.102:5601.

Starting the application

To start the application you will need to ssh into the ci-sockshop-nomad-node1 box and run the respective Nomad jobs:

root@local:/# vagrant ssh ci-sockshop-nomad-node1
ubuntu@ci-sockshop-nomad-node1:/# nomad run netman.nomad
ubuntu@ci-sockshop-nomad-node1:/# nomad run weavedemo.nomad

The output from the following commands should be similar to what’s displayed below:

ubuntu@ci-sockshop-nomad-node1:/#  nomad run netman.nomad
==> Monitoring evaluation "858414a3"
    Evaluation triggered by job "netman"
    Allocation "0e3a6a5a" modified: node "9b8300f6", group "main"
    Evaluation status changed: "pending" -> "complete"
==> Evaluation "858414a3" finished with status "complete"
ubuntu@ci-sockshop-nomad-node1:/# nomad run weavedemo.nomad
==> Monitoring evaluation "0ad17a84"
    Evaluation triggered by job "weavedemo"
    Allocation "5c1ebc22" modified: node "9b8300f6", group "frontend"
    Allocation "8a7f7f52" modified: node "9b8300f6", group "payment"
    Allocation "f3a76ce1" modified: node "9b8300f6", group "accounts"
    Allocation "d5fac4c8" modified: node "9b8300f6", group "login"
    Allocation "d6526050" modified: node "9b8300f6", group "orders"
    Allocation "efeddd3e" modified: node "9b8300f6", group "shipping"
    Allocation "45368041" modified: node "9b8300f6", group "queue-master"
    Allocation "5d519978" modified: node "9b8300f6", group "cart"
    Allocation "732f4f54" modified: node "9b8300f6", group "catalogue"
    Allocation "75fbee96" modified: node "9b8300f6", group "rabbitmq"
    Evaluation status changed: "pending" -> "complete"
==> Evaluation "0ad17a84" finished with status "complete"

Locating The Endpoint

Taking the Allocation ID of the frontend task group above we can ask Nomad about its status:

ubuntu@ci-sockshop-nomad-node1:/# nomad alloc-status 5c1ebc22
ID            = 5c1ebc22
Eval ID       = c318487e
Name          = weavedemo.frontend[0]
Node ID       = 9b8300f6
Job ID        = weavedemo
Client Status = running

Task "edgerouter" is "running"
Task Resources
CPU    Memory          Disk     IOPS  Addresses
0/100  9.8 MiB/32 MiB  300 MiB  0     http: 192.168.59.102:80
                                      https: 192.168.59.102:443

Recent Events:
Time                    Type        Description
07/01/16 18:04:36 CEST  Started     Task started by client
07/01/16 18:02:54 CEST  Received    Task received by client

Task "front-end" is "running"
Task Resources
CPU    Memory          Disk     IOPS  Addresses
0/100  61 MiB/128 MiB  300 MiB  0

Recent Events:
Time                    Type      Description
07/01/16 18:05:54 CEST  Started   Task started by client
07/01/16 18:02:54 CEST  Received  Task received by client

If you look carefully, you will notice that the edgerouter task is running and among the resources that have been allocated for it, ports 80 (HTTTP) and 443 (HTTPS) have been bound to the IP 192.168.59.102. Visiting this IP should yield a running sock shop, while visiting this IP on port 4040 should show the Weave Scope dashboard unless configured to use Weave Coud, then visit cloud.weave.works to check.

Run tests

There is a separate load-test available to simulate user traffic to the application. For more information see Load Test. This will send some traffic to the application, which will form the connection graph that you can view in Scope or Weave Cloud.

docker run --rm weaveworksdemos/load-test -d 300 -h 192.168.59.102 -c 2 -r 100

Cleaning Up

vagrant destroy -f