Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new mongo image for tutorial - fixes 383 #476

Merged
merged 10 commits into from
Aug 11, 2014
23 changes: 2 additions & 21 deletions docs/gettingstarted/tutorial/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,10 @@ mkdir -p /opt/flocker
truncate --size 1G /opt/flocker/pool-vdev
zpool create flocker /opt/flocker/pool-vdev

TAR="/tmp/vagrant-cache/dockerfile_mongodb.tar"
IMAGE="dockerfile/mongodb"
IMAGE="clusterhq/mongodb"
# Get the images needed for the tutorial. This has to happen eventually and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest simplifying this to just a docker pull given the image is so small.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then removing references to vagrant-cachier - less fragility, less steps.

# doing it now aggregates all of the waiting in one place.
if [ -e "${TAR}" ]; then
# Load a cached version.
docker load < "${TAR}"
else
# Get it from the internet.
docker pull "${IMAGE}"
# Cache it if possible
if [ -d /tmp/vagrant-cache ]; then
docker save "${IMAGE}" > "${TAR}"
fi
fi

# XXX This is a hack to reduce the size of the mongodb image. It can be removed
# when we have created a smaller mongo image for use in this tutorial. See
# https://github.com/ClusterHQ/flocker/issues/383
mkdir /var/tmp/dockerbuild
cd /var/tmp/dockerbuild
echo "FROM dockerfile/mongodb\nCMD mongod --dbpath=/data --noprealloc --smallfiles" > Dockerfile
docker build --tag mongodb-tutorial .
docker pull "${IMAGE}"
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
Expand Down
6 changes: 5 additions & 1 deletion docs/gettingstarted/tutorial/exposing-ports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ We will once again run these configuration files with ``flocker-deploy``:
alice@mercury:~/flocker-tutorial$ flocker-deploy port-deployment.yml port-application.yml
alice@mercury:~/flocker-tutorial$ ssh root@172.16.255.250 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d117c7e653e dockerfile/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-port-example
4d117c7e653e clusterhq/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-port-example
alice@mercury:~/flocker-tutorial$

This time we can communicate with the MongoDB application by connecting to the node where it is running.
Using the ``mongo`` command line tool we will insert an item into a database and check that it can be found.
You should try to follow along and do these database inserts as well.

**Note:** To keep your download for the tutorial as speedy as possible, we've bundled the latest dev version of MongoDB in to a micro-sized Docker image.
*You should not use this image for production.*

If you get a connection refused error try again after a few seconds; the application might take some time to fully start up.

.. code-block:: console
Expand Down
2 changes: 1 addition & 1 deletion docs/gettingstarted/tutorial/minimal-application.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"version": 1
"applications":
"mongodb-example":
"image": "mongodb-tutorial"
"image": "clusterhq/mongodb"
4 changes: 2 additions & 2 deletions docs/gettingstarted/tutorial/moving-applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ To fix this, use ``flocker-deploy`` with the simple configuration files given ab
alice@mercury:~/flocker-tutorial$ flocker-deploy minimal-deployment.yml minimal-application.yml
alice@mercury:~/flocker-tutorial$ ssh root@172.16.255.250 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d117c7e653e dockerfile/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-example
4d117c7e653e clusterhq/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-example
alice@mercury:~/flocker-tutorial$

``flocker-deploy`` has made the necessary changes to make your node match the state described in the configuration files you supplied.
Expand Down Expand Up @@ -84,7 +84,7 @@ and that MongoDB has been successfully moved to ``172.16.255.251``:

alice@mercury:~/flocker-tutorial$ ssh root@172.16.255.251 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d117c7e653e dockerfile/mongodb:latest mongod 3 seconds ago Up 2 seconds 27017/tcp, 28017/tcp mongodb-example
4d117c7e653e clusterhq/mongodb:latest mongod 3 seconds ago Up 2 seconds 27017/tcp, 28017/tcp mongodb-example
alice@mercury:~/flocker-tutorial$

At this point you have successfully deployed a MongoDB server in a container on your VM.
Expand Down
2 changes: 1 addition & 1 deletion docs/gettingstarted/tutorial/port-application.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"version": 1
"applications":
"mongodb-port-example":
"image": "mongodb-tutorial"
"image": "clusterhq/mongodb"
"ports":
- "internal": 27017
"external": 27017
13 changes: 1 addition & 12 deletions docs/gettingstarted/tutorial/vagrant-setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ First create a tutorial directory:
alice@mercury:~/$ cd flocker-tutorial
alice@mercury:~/flocker-tutorial$

Next download the Vagrant configuration and the Flocker repository configuration files by right clicking on the links below.
Next download the Vagrant configuration and the Flocker repository configuration files by right clicking on the links below.
Save them in the *flocker-tutorial* directory and preserve their filenames.

* :download:`Vagrant configuration <Vagrantfile>`
Expand All @@ -104,17 +104,6 @@ Save them in the *flocker-tutorial* directory and preserve their filenames.
clusterhq-flocker.repo Vagrantfile
alice@mercury:~/flocker-tutorial$

The tutorial ``Vagrantfile`` can take advantage of `vagrant-cachier`_ to avoid certain redundant downloads.
You will probably want to install this plugin:

.. code-block:: console

alice@mercury:~/flocker-tutorial$ vagrant plugin install vagrant-cachier
Installing the 'vagrant-cachier' plugin. This can take a few minutes...
Installed the plugin 'vagrant-cachier (0.7.2)'!
...
alice@mercury:~/flocker-tutorial$

Then use ``vagrant up`` to start and provision the VMs:

.. code-block:: console
Expand Down
4 changes: 2 additions & 2 deletions docs/gettingstarted/tutorial/volume-application.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"version": 1
"applications":
"mongodb-volume-example":
"image": "mongodb-tutorial"
"image": "clusterhq/mongodb"
"ports":
- "internal": 27017
"external": 27017
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to change the mount point to be /data/db rather than /data.

"volume":
# The location within the container where the data volume will be
# mounted:
"mountpoint": "/data"
"mountpoint": "/data/db"
14 changes: 11 additions & 3 deletions docs/gettingstarted/tutorial/volumes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Next we'll use a new configuration file that moves the application to a differen
alice@mercury:~/flocker-tutorial$ flocker-deploy port-deployment-moved.yml port-application.yml
alice@mercury:~/flocker-tutorial$ ssh root@172.16.255.251 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d117c7e653e dockerfile/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-port-example
4d117c7e653e clusterhq/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-port-example
alice@mercury:~/flocker-tutorial$

If we query the database the records we've previously inserted have disappeared!
Expand Down Expand Up @@ -62,7 +62,7 @@ Then we'll run these configuration files with ``flocker-deploy``:
alice@mercury:~/flocker-tutorial$ flocker-deploy volume-deployment.yml volume-application.yml
alice@mercury:~/flocker-tutorial$ ssh root@172.16.255.250 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d117c7e653e dockerfile/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-volume-example
4d117c7e653e clusterhq/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-volume-example
alice@mercury:~/flocker-tutorial$

Once again we'll insert some data into the database:
Expand Down Expand Up @@ -90,7 +90,7 @@ Next we'll move the application to the other node.
alice@mercury:~/flocker-tutorial$ flocker-deploy volume-deployment-moved.yml volume-application.yml
alice@mercury:~/flocker-tutorial$ ssh root@172.16.255.251 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d117c7e653e dockerfile/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-volume-example
4d117c7e653e clusterhq/mongodb:latest mongod 2 seconds ago Up 1 seconds 27017/tcp, 28017/tcp mongodb-volume-example
alice@mercury:~/flocker-tutorial$

This time however the data has moved with the application:
Expand All @@ -108,3 +108,11 @@ This time however the data has moved with the application:
At this point you have successfully deployed a MongoDB server and communicated with it.
You've also seen how Flocker allows you to move an application's data to different locations in cluster as the application is moved.
You now know how to run stateful applications in a Docker cluster using Flocker.

If you would like to remove the virtual machines created for this tutorial, you can now finish off by running:

.. code-block:: console

alice@mercury:~/flocker-tutorial$ vagrant destroy

Confirm that you would like to remove the node1 and node2 virtual machines when prompted.