Documentation

Sock Shop via Docker Swarm

Please refer to the new Docker Swarm introduction

Pre-requisities

git clone https://github.com/microservices-demo/microservices-demo
cd microservices-demo
curl -sSL https://get.docker.com/ | sh
apt-get install -yq curl jq python-pip unzip build-essential python-dev

curl https://releases.hashicorp.com/packer/0.12.0/packer_0.12.0_linux_amd64.zip -o /root/packer.zip
unzip /root/packer.zip -d /usr/bin

curl https://releases.hashicorp.com/terraform/0.7.11/terraform_0.7.11_linux_amd64.zip -o /root/terraform.zip
unzip /root/terraform.zip -d /usr/bin

pip install awscli

Docker Swarm (Single-Node)

  • Put your docker into the swarm mode
  • Pull the containers using docker-compose
  • Create a Distribution Application Bundle using docker-compose
  • Deploy the dab file
    cd microservices-demo/deploy/docker-swarm/
    docker swarm init
    docker-compose pull
    docker-compose bundle
    docker deploy --bundle-file dockerswarm.dab sockshop

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.

Feel free to run it by issuing the following command:

docker run --rm --net host weaveworksdemos/load-test -d 60 -h localhost:30000 -c 2 -r 100

Cleaning up

docker stack rm dockerswarm

Docker Swarm (Multi-Node)

Begin by setting the appropriate AWS environment variables.

export AWS_ACCESS_KEY_ID=[YOURACCESSKEYID]
export AWS_SECRET_ACCESS_KEY=[YOURSECRETACCESSKEY]
export AWS_DEFAULT_REGION=[YOURDEFAULTREGION]

AWS

aws ec2 create-key-pair -\-key-name docker-swarm -\-query 'KeyMaterial' -\-output text > ~/.ssh/docker-swarm.pem
chmod 600 ~/.ssh/docker-swarm.pem

packer build -only=amazon-ebs deploy/docker-swarm/packer/packer.json
terraform apply deploy/docker-swarm/infra/aws/

gcloud

export TF_VAR_project_name='project-name'
export TF_VAR_credentials_file_path="~/.gcloud/accounts.json"
export TF_VAR_public_key_path="~/.ssh/gcloud_id_rsa.pub"
export TF_VAR_private_key_path="~/.ssh/gcloud_id_rsa"

packer build -only=googlecompute deploy/docker-swarm/packer/packer.json
terraform apply deploy/docker-swarm/infra/gcloud/

Local

export NUM_NODES=2
packer build -only=virtualbox-iso deploy/docker-swarm/packer/packer.json
.deploy/docker-swarm/infra/local/swarm.sh up

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.

AWS & gcloud

Using any IP from the command: terraform output

master_ip=$(terraform output -json | jq -r '.master_address.value' )
docker run --rm weaveworksdemos/load-test -d 300 -h $master_ip:30000 -c 2 -r 100

Local

docker run --rm weaveworksdemos/load-test -d 60 -h 10.0.0.10:30000 -c 2 -r 100

Cleaning up

AWS & Gcloud

terraform destroy -force deploy/docker-swarm/infra/aws/
aws ec2 delete-key-pair -\-key-name docker-swarm
rm ~/.ssh/docker-swarm.pem
swarm_ami=$(aws ec2 describe-images --filter Name=name,Values=docker-swarm --query 'Images[0].{ID:ImageId}' --output text)
aws ec2 deregister-image --image-id $swarm_ami
rm terraform.tfstate
rm terraform.tfstate.backup

Local

./deploy/docker-swarm/infra/local/swarm.sh down