A Simple CoreOS and Etcd Cluster

In my idle moments, I contemplate such things as self-assembling infrastructure-in-a-box.  What I mean by that is how do you go from an an empty room (conceptually) to doing useful work for the business in as few steps as possible, as quickly as possible?  What minimum complement of services do you need, and how do you bootstrap it into existence, autonomously?  The goal is to perform as few manual steps as possible to get to a state where you can easily build out the rest of your infrastructure and start deploying applications right away.  Bootstrapping.  Inception.  Whatever.

In this post, at a high level, I want to lay out a simple application platform bootstrapping exercise.  We’re going to make use of a HOT template for Openstack to bring up a three node CoreOS cluster which performs auto-discovery to assemble an etcd cluster.  This is not a tutorial on Openstack.  I am not covering the obvious question of how to get Openstack running.  The point of this exercise is only to lay the foundation for running clustered applications in Docker containers.

I will wave my hands and assume that you have access to a working Openstack installation for this exercise with the privileges to perform the steps detailed below.  Additionally, you will need to perform these commands from a machine with curl, bash, git, heat, and etcdctl installed.  I am using OS X Mavericks, and used homebrew to install the missing tools.  Any modern Linux distro will work fine, too.  Once you have your workstation in a known-good, working state things are super easy.

1. Get the template

$ git clone https://github.com/bkyoung/coreos-fleet.git

2.  Launch your cluster:

$ cd coreos-fleet/
$ DISCOVERY_URL=$(curl -s https://discovery.etcd.io/new)
$ heat stack-create -f coreos_fleet.template --parameters="discovery_url=$DISCOVERY_URL" coreos_fleet

2. Verify etcd is working:

$ ETCD_PEER=$(heat output-show coreos_fleet coreos1_public_ip | sed -e 's/"//g')
$ etcdctl --peers ${ETCD_PEER}:4001 ls /

It’s that easy.

A note on the template: I chose to include default values for several parameters (they are fake, but representative).  Be sure to modify them for your situation or delete them.  You can pass new values in at invocation time similar to what is shown with the discovery_url.  Just make all your parameters a semicolon separated list inside the quotes.

Leave a Reply