Setting up a Docker Swarm Cluster on a W10 platform with Google and Amazon Clouds

In a GitBash window :

After I got docker-machine 0.4.0 from here

I already have a GCE account set up, and a project name so all I’m ready to create my swarm master on Google:

export GCE_PROJECT=”natural-axiom-106513″
export TOKEN=”4506ce594e7afc4d27276205f8710e25″

Capture

For nodes :

./docker-machine create -d google –google-project=${GCE_PROJECT} –google-machine-type=n1-standard-2 –google-disk-size=50 –swarm –swarm-discovery token://${TOKEN} slave01

./docker-machine create -d google –google-project=${GCE_PROJECT} –google-machine-type=n1-standard-2 –google-disk-size=50 –swarm –swarm-discovery token://${TOKEN} slave02

$ ./docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
crate-swarm google Running tcp://104.197.34.189:2376 crate-swarm (master)
slave01 google Running tcp://104.197.96.123:2376 crate-swarm
slave02 google Running tcp://104.197.48.142:2376 crate-swarm

I now have a 2 nodes cluster running on Gcloud

I can add a node on Amazon EC2 :

I need to create a key pair

Let’s create a few  AWS variables :

export AWS_DEFAULT_REGION=us-east-1
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxx
export AWS_ACCESS_KEY_ID=xxxxxxxxxxx

Let’s check our credentials :

(Got the aws cli for windows here)

$ ./AWSCLI/aws ec2 describe-subnets |head
{
“Subnets”: [
{
“VpcId”: “vpc-dae01fbe”,
“CidrBlock”: “172.31.48.0/20”,
“MapPublicIpOnLaunch”: true,
“DefaultForAz”: true,
“State”: “available”,
“AvailabilityZone”: “us-east-1a”,
“SubnetId”: “subnet-5add9171”,

This gives you values you can use (VPCID, subnet name)

export AWS_VPC_ID=vpc-dae01fbe

$ ./docker-machine create –driver amazonec2 –amazonec2-access-key $AWS_ACCESS_KEY_ID –amazonec2-secret-key $AWS_SECRET_ACCESS_KEY –amazonec2-vpc-id $AWS_VPC_ID –amazonec2-subnet-id subnet-5add9171 –amazonec2-zone a –swarm –swarm-discovery token://${TOKEN} awsslave01
Launching instance…
To see how to connect Docker to this machine, run: C:\Users\Jean-Marie\docker-machine env awsslave01

And that’s it !

$ ./docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
awsslave01 * amazonec2 Running tcp://54.165.76.245:2376 crate-swarm
crate-swarm google Running tcp://104.197.34.189:2376 crate-swarm (master)
slave01 google Running tcp://104.197.96.123:2376 crate-swarm
slave02 google Running tcp://104.197.48.142:2376 crate-swarm

Next step is to play with that cluster !

Notes :

I found these pages quite helpful :
https://docs.docker.com/machine/drivers/aws/
http://networkstatic.net/docker-machine-provisioning-on-aws/
http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region
https://aws.amazon.com/cli/?nc1=h_ls
https://github.com/docker/machine/issues/584

Tip : Everytime a creation attempt fails, it leaves traces and you have to clean up the house :

./AWSCLI/aws ec2 delete-key-pair –key-name awsslave01

./docker-machine rm -f awsslave01

Advertisements
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: