My first coreos cluster

Robert Fehrmann
Snagajob Engineering
3 min readSep 25, 2014

At the Snagajob engineering team we schedule Hack Days once per month to encourage everybody to be as creative as possible.

So a couple of weeks ago I had heard about docker and coreos at MongoWorld, MongoDB’s annual users conference. The talk was about running a MongoDB instance in a docker container. The idea of using containers sounded very interesting plus you can control resources much better. Take a look at https://coreos.com/ if you like more info.

Recently DigitalOcean, my favorite Cloud platform, started to support Coreos and Docker got a big cash infusion https://blog.docker.com/2014/09/docker-closes-40m-series-c-led-by-sequoia/ . So the goal for my most recent hack day project was to build a coreos cluster and run a simple web-application in a docker container.

To build the coreos cluster I followed this great tutorial on the DigitalOcean blog (https://www.digitalocean.com/community/tutorials/an-introduction-to-coreos-system-components). It guides you step-by-step through the process of building the cluster.

I’m not going to re-state the whole process but want to point out what problems I ran into and how I was able to overcome these.

Part 2 of the tutorial (https://www.digitalocean.com/community/tutorials/how-to-set-up-a-coreos-cluster-on-digitalocean) talks about how to setup your cluster in digital ocean. I’m running windows/cygwin on my client machine and I had added my ssh key already into the SSH keys section on DigitalOcean. Using ssh keys makes your life much easier when working with DigitalOcean but for using coreos it actually is a requirement.

Be sure to run the following 2 commands on in your client session instead of just what’s listed above

$ eval $(ssh-agent)
Agent pid 17148

$ ssh-add
Identity added:

The next step was to get the necessary information for the API calls. Using the API is the way to go. It makes the whole setup process incredibly easy and fast. So what do we need?

Here’s a screenshot from the tutorial

So we need to get the values in red, plus we need to setup an environment variable, i.e $TOKEN (unfortunately that isn’t in red).

The server name (just pick one) and the discovery URL (curl https://discovery.etcd.io/new) are pretty straight forward. But how do we get the SSH Key IDs. Using google gets you quickly to the DigitalOcean API V2 and this command:

curl -X GET “https://api.digitalocean.com/v2/account/keys” -H “Authorization: Bearer $TOKEN”

which requires an access token. Access Tokens again are created and managed in the DigitalOcean UI under Apps & API.

Now you can run the API call to get the SSH Key ID (or IDs) and we are ready to run the API call to create the coreos VM.

From here on forward the tutorial worked like a charm. I build out a three node cluster in matter of minutes and finished the day with a running web-app that was pulling data from netsuite.

Sweet!!

Originally published at engineering.snagajob.com on September 25, 2014.

--

--