Installing Flocker

with Docker Swarm on AWS using CloudFormation

In this guide you will learn how to quickly deploy a cluster of servers running Flocker and Docker Swarm. You will launch four EC2 instances in your AWS account, as illustrated below:

A diagram illustrating a cluster of four AWS EC2 instances running Flocker with Docker Swarm.

Follow the steps below to create your cluster. Once it’s up and running we’ll guide you through a tutorial to deploy a sample app.

1

Create an AWS Key Pair

The AWS Key Pair allows you to login to your AWS cluster securely.

Log in to AWS
This button will open AWS in a new window.

AWS key pairs section in console When you have logged in to the AWS console, select your region. This should be the same region where you will create your cluster.
Creating a new AWS key pair Click "Create Key Pair". Give your key pair a meaningful name, like <username>-flocker-test. You'll need this later, so make a note of it.
A downloaded pem file The private key (.pem file) will be downloaded onto your computer.

2

Create a Flocker cluster


Start CloudFormation Configuration Process
This button will open CloudFormation in a new window.

Initial CloudFormation page Click "Next" to proceed past the first page.
Specifying the stack name
  • Enter a Stack name. This can be any descriptive name.
  • Enter your KeyPair name from Step 1. Then enter your AWS AccessKeyID and SecretAccessKey credentials.
Don't know your AWS credentials?
Optionally fill in Volume Hub settings
  • Now add your Volume Hub Token (optional). Volume Hub lets you see your Flocker cluster in a web interface. Create a free Volume Hub account:

    Volume Hub

  • Once you're logged in to the Volume Hub, click below to get your Volume Hub Token:

    Volume Hub token

    Then copy the <YourToken> part from {"token": "<YourToken>"} into the VolumeHubToken field.
Click create
  • Click "Next" on the Options page.
  • Click "Next" on the Review page.
  • Finally, click "Create" to create your cluster.
Wait for the cluster to boot

Wait for the Cluster to Boot

It will take 5-10 minutes for the cluster servers to boot and to configure the Flocker and Docker Swarm services on each server.

Refresh button on CloudFormation console The stack may not appear immediately. Click the "Refresh" button until the new stack appears.
Stack create in progress message Once the stack appears its status will be "CREATE_IN_PROGRESS".
Stack create create complete message After 5-10 minutes the cluster will be ready for use and its status will be "CREATE_COMPLETE". The cluster is now ready.

3

Verify your installation

Click on the "Outputs" tab for your stack. The values displayed on this tab will be used for verifying your installation and also any tutorials you go through.

Stack outputs in CloudFormation

Now open a Terminal window, and run the following commands to log in and verify your cluster is working.

Where a command includes a string like <ClientNodeIP>, use the corresponding value from the Outputs tab.

Where a command has <KeyPath> use the path on your machine to the .pem file you downloaded in Step 1, for example: ~/Downloads/<username>-flocker-test.pem.

chmod 0600 <KeyPath>
ssh -i <KeyPath> ubuntu@<ClientNodeIP> # enter "yes" if prompted
export FLOCKER_CERTS_PATH=/etc/flocker
export FLOCKER_USER=user1
export FLOCKER_CONTROL_SERVICE=<ControlNodeIP> # not ClientNodeIP!
flockerctl status # should list two servers (nodes) running
flockerctl ls # should display no datasets yet
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://<ControlNodeIP>:2376
docker info |grep Nodes # should output "Nodes: 2"
exit

If the commands succeeded, then your Flocker and Docker Swarm cluster is up and running.

You can also verify that your cluster has shown up in the Volume Hub:

Volume Hub

It should look like this:

Cluster appears in Volume Hub

That's it!

Your cluster is now ready. Now try a tutorial.

Deploy an app on your Swarm/Flocker cluster
../_images/01-keys-menu.png ../_images/02-create-key.png ../_images/03-pem-downloaded.png ../_images/10-cloudformation-firstpage.png ../_images/11-cloudformation-stackname.png ../_images/12-cloudformation-settings.png ../_images/13-cloudformation-create.png ../_images/21-refresh.png ../_images/22-create-in-progress.png ../_images/23-create-complete.png ../_images/31-stack-outputs.png ../_images/32-volume-hub-verification.png ../_images/kettle.png