Skip to content

Instantly share code, notes, and snippets.

@wallnerryan
Last active October 30, 2015 13:28
Show Gist options
  • Select an option

  • Save wallnerryan/6f9fc4b3049aa7f1ae5b to your computer and use it in GitHub Desktop.

Select an option

Save wallnerryan/6f9fc4b3049aa7f1ae5b to your computer and use it in GitHub Desktop.

From a brand new Flocker cluster install via uft: 2 Agent + 1 Master

For more inforamation on installing flocker on aws easily, please see (http://doc-dev.clusterhq.com/labs/installer.html#labs-installer)

You will end up with a way to list your nodes.

wallnerryan@mac:-> uft-flocker-volumes list-nodes
SERVER     ADDRESS      
2cdbc6d7   <private ip for node1>
7bfb9668   <private ip for node2>

You will also have the ability to list your volumes that flocker knows about.

wallnerryan@mac:-> uft-flocker-volumes list
DATASET   SIZE   METADATA   STATUS   SERVER 

SSH

Once this is setup, you should keep track of your public and private IP addresses in amazon. We can do this by creating environment variables on our local machine so that it is easier to reference. You can retrive these from your cluster.yml under agent_nodes:

PUBLIC IPs

export NODE1=<public ip for node1>
export NODE2=<public ip for node2>
export MASTER=<public ip for master>

PRIVATE IPS

export PNODE1=<private ip for node1>
export PNODE2=<private ip for node2>

Also, keep the path to your AWS Key in a ENV virable.

export KEY=/Path/to/your/aws/ec2/user.pem
chmod 0600 $KEY

Right now the flocker uft installer does not install Docker Swarm for you, so we need to log in to these nodes and make sure the docker daemon is visible externally. We'll also log the output to a logfile for reference.

Change Docker to run external

ssh -i $KEY root@$NODE1 
service docker stop
docker daemon -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 >> /tmp/dockerlogs 2>&1 &
service flocker-docker-plugin restart

ssh -i $KEY root@$NODE2 
service docker stop
docker daemon -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 >> /tmp/dockerlogs 2>&1 &
service flocker-docker-plugin restart

ssh -i $KEY root@$MASTER 
service docker stop
docker daemon -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 >> /tmp/dockerlogs 2>&1 &

We need to open Swarm ports in AWS Security Groups.

  • We will use and open Inbound Ports (2375 from internal docker clients, and 2357 for external Swarm Manager access from MyIP)
  • Note: You need to reference the correct VPC ID when you create the sec group as well.
  • Note: Also open any other ports that your application may use, like 8080
  • Note: Hopefully this will becomes automated for a demo Swarm installation with Flocker
  • Reference Security Groups Docs: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html

We need to Install Swarm now

ssh -i $KEY root@$MASTER docker run --rm swarm create

Example: you will get output, save the output Keep track of UUID (e5ad76cbba2a88981fc586ddeae5ea52)

Export it export CLUSTERKEY=e5ad76cbba2a88981fc586ddeae5ea52

Start Swarm Agents

ssh -i $KEY root@$NODE1 docker run -d swarm join --addr=$PNODE1:2375 token://$CLUSTERKEY

ssh -i $KEY root@$NODE2 docker run -d swarm join --addr=$PNODE2:2375 token://$CLUSTERKEY

Start Swarm Master

ssh -i $KEY root@$MASTER docker run -d -p 2357:2375 swarm manage token://$CLUSTERKEY

Use Swarm

(if you have docker-machine running or boot2docker, then ENV are set for TLS, lets unset them so we can talk to our exposed Swarm Manager)

unset DOCKER_TLS_VERIFY
unset DOCKER_CERT_PATH
docker -H tcp://$MASTER:2357 info

or

export DOCKER_HOST=tcp://$MASTER:2357
docker info

Example output

docker -H tcp://$MASTER:2357 info
Containers: 6
Images: 3
Role: primary
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 3
 ip-10-0-151-193: 10.0.151.193:2375
  └ Containers: 2
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 3.86 GiB
  └ Labels: executiondriver=native-0.2, kernelversion=3.13.0-63-generic, operatingsystem=Ubuntu 14.04.3 LTS, storagedriver=aufs
 ip-10-0-212-211: 10.0.212.211:2375
  └ Containers: 2
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 3.86 GiB
  └ Labels: executiondriver=native-0.2, kernelversion=3.13.0-63-generic, operatingsystem=Ubuntu 14.04.3 LTS, storagedriver=aufs
CPUs: 3
Total Memory: 11.58 GiB
Name: 2fc1477e208b
Example App
 docker -H tcp://$MASTER:2357 run -d -it -v demo:/var/lib/mysql --volume-driver=flocker --name MySQL-1 wallnerryan/mysql

See volume (in separate term under where cluster.yml lives)

uft-flocker-volumes list
DATASET                                SIZE     METADATA    STATUS         SERVER                  
fe01ce2a-7fba-48fa-baed-7c982a04e229   75.00G   name=demo   attached ✅   7bfb9668 (10.0.151.193) 
Trouble Shooting
//TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment