Setting Up a CoreOS Cluster on AWS EC2 (with pictures)

This is going to be a quick to the point guide on getting a 3 instance CoreOS cluster running in Amazon Web Services.


You must have an AWS account.
You must have the AWS-Cli installed.


Make sure your AWS-CLI version is AWS-CLI 1.7.23 or better.
In a MAC you can check the AWS-CLI version by typing the following :

aws --version

I do not recommend installing AWS-CLI through MAC HomeBrew because it is outdated, instead I recommend installing the latest AWS-CLI through PIP.

##Security Group First we are going to create a security group for our instances. For simplicity, we are going to make this security group open to the world. Even though security is important, this tutorial serves an educational purposes and you should never have all ports open in production.

Navigate to the AWS security group

Click on create new security group.
You can name the security group whatever you want. I named my security group 'open'. You also have to add a description and for learning sake create an inbound rule that is open to all traffic on all ports and set the source to anywhere. Then click create.

CoreOS Cloud Config

Next lets create a config file for our CoreOS.
Go here to get your CoreOS discovery url :

[]( "target="_blank)

and place the it into the discovery parameter.

    discovery: [your own discovery url]
    addr: $private_ipv4:4001
    peer-addr: $private_ipv4:7001
    - name: etcd.service
      command: start
    - name: fleet.service
      command: start

Save the file as cloud-config.yml. You can also use this Gist.

##Our First AWS CoreOS Cluster We have our security group and our cloud config. I assume by now your AWS-CLI configured with your AWS account. If its not, checkout this guide to help you out. []( "target="_blank).
###Lets Get Our CoreOS Image ID. As of writing this article, the latest CoreOS version 668.2.0. Make sure to find an Amazon Image ID that is as close to the latest version as possible. Other versions may potentially have problems. The image-id I'm using is ami-6b44725b.

###You Need a KeyPair If you don't have a key-pair setup with your AWS account take a look at this guide here []( "target="_blank).

For education purposes, the key name that I'm using is called 'MyKeyPair'.

###Launching The Cluster Execute the following AWS-CLI command in the terminal to launch your cluster :
aws ec2 run-instances --image-id ami-6b44725b --count 3 --instance-type t1.micro --key-name MyKeyPair --security-groups open --user-data file://cloud-config.yml

Replace the parameter values to your values and execute the command in your terminal. The terminal should output a long JSON with instance data. When you look into your AWS EC2 dashboard you should notice 3 micro CoreOS instances launched.

Congratulations. You have your CoreOS cluster. Just to make sure everything is working, get the IP of your instance and ssh into that instance. By default CoreOS uses 'core' as the root user. So in your terminal you would execute the following

ssh -i MyKeyPair.pem core@some-public-ip

and in the machine run

fleetctl list-machines

If you want to check if that particular instance is a leader execute the following :

curl -L

If the instance is not the leader you will get the following: