Skip to content

Instantly share code, notes, and snippets.

@wallnerryan
Last active June 16, 2016 19:46
Show Gist options
  • Save wallnerryan/be1311c083f1994f059e830cfd4a220d to your computer and use it in GitHub Desktop.
Save wallnerryan/be1311c083f1994f059e830cfd4a220d to your computer and use it in GitHub Desktop.

What you will be doing

In this small, self-guided workshop you will deploy and migrate a Redis database between hosts in a UCP cluster. You'll follow step-by-step instructions to:

  1. Add a Docker License to a Docker UCP Cluster.
  2. Add an extra UCP node the cluster so we can migrate a database between hosts.
  3. Use Docker compose to deploy an app with Redis backed by Flocker volumes and add some data to the app.
  4. Destroy the app. Argh!
  5. Start the app back up on a different node to demonstrate data movement. Phew.

Get started with the Demo

Step 1- Add license to Docker UCP

Click over to the UCP tab and click I Understand the Risks --> Add Exception.. and Confirm Security Exception when presented with Untrusted Connection warning.

Add Exception

Confirm

Login

Next log into UCP with admin/orca and choose the dockercon.lic license from the Desktop. Click upload license in the Docker UCP Dashboard.

Licene

Take note of the output on the terminal from the previous ReadyDockerconDemo, there will be a fingerprint output for your Controller, it looks something like the below example. Copy this string to your clipboard.

Note, the information you would need to copy in below example output is: SHA-256 Fingerprint=FB:37:77:71:D6:F5:DB:8A:D6:00:CC:DC:73....:F4

# Example output from terminal
INFO[0062] UCP Server SSL: SHA-256 Fingerprint=FB:37:77:71:D6:F5:DB:8A:D6:00:CC:DC:73:90:17:DE:2C:99:CB:4D:A2:65:64:F3:76:4D:04:35:81:7D:B4:F4 
INFO[0062] Login as "admin"/"orca" to UCP at https://172.16.78.250:443 

Step 2 - Add a second node to your UCP cluster

You will add a node, node2. Add it to the UCP cluster by copying the command below and paste it into your terminal and replace the <SHA1 fingerprint copied previously> with the fingerprint from above.

$ vagrant ssh node2 -c "docker run --rm -it --name ucp \
   -v /var/run/docker.sock:/var/run/docker.sock \
   -e UCP_ADMIN_USER=admin -e UCP_ADMIN_PASSWORD=orca \
   docker/ucp join \
   --fresh-install \
   --san node2 \
   --host-address 172.16.78.251 \
   --url https://172.16.78.250 \
   --fingerprint <SHA1 fingerprint copied previously>"

After this completes, navigate back to the dashboard and verify you have 2 nodes. https://node1/#/dashboard Then navigate to https://node1/#/user, scroll down and click Create a Client Bundle. Then copy the bundle that was downloaded, and unzip the client bundle.

$ mv ~/Downloads/ucp-bundle-admin.zip .
$ unzip ucp-bundle-admin.zip

Execute the env.sh script to set the appropriate environment

$ source env.sh

Run docker info to verify it works.

Step 3 - Deploy Redis using Docker Compose

Go to the app/ folder and run the first example.

$ cd app/
$ docker-compose -f dockercon-node1.yml up -d

Navigate to http://node1 and click the page to add docker images. You can also enter your email if you would like to continue later. Feel free to navigate to https://node1/#/volumes and search flocker to see the volumes being used in this demo.

Step 4 - Delete the app. Cause chaos.

Delete the app and remove the containers.

$ docker-compose -f dockercon-node1.yml stop
$ docker-compose -f dockercon-node1.yml rm -f

Step 5 - Migrate the app to a new node, restore order. Thanks Flocker!

Bring the app back up on the second node.

$ docker-compose -f dockercon-node2.yml up -d

See that is on node2 now. Visit http://node2/, you should see the same images as before. Data movement!

Step 6 - Restart the environment for the next person

When you are done, double click ReadyDockerconDemo on the Desktop before leaving the workstation so someone else can give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment