Production CoreOS on AWS EC2

22 Jan 2016

In previous posts, we learnt about installing CoreOS on VirtualBox to get you up to speed with cloud-config files and the general installation process. We also learnt about various CoreOS components, such as systemd, fleet, and etcd. However, if you want to run CoreOS in production, there are several other things to take care of: security, system failures, cluster scaling, and remote access, to name just a few.

CoreOS ensures scalability and failsafe clustering out of the box. And cloud deployment is the way to go if you want scalable, secure infrastructure. But how do you get a CoreOS cluster running in the cloud? There are several related questions. Do you need to install CoreOS on all the nodes separately? What about the cloud-config files? How does a cluster get defined logically?

In this post I’ll go over the CoreOS installation process and hopefully answer these questions for you.

Installation

First step is to select a CoreOS channel you’d like to install.

There are three channels: stable, beta, and alpha.

  • The alpha channel has the bleeding edge software releases. You get the newest code, but it hasn’t been tested in real world conditions.
  • The beta channel has promoted alpha releases. You can expect fewer bugs, because it’s already been run in other setups.
  • The stable channel has promoted beta releases. These releases are considered fit for regular use. If you are looking to use CoreOS for your production systems, choose the stable channel.

CoreOS maintains a list of all available options for Amazon EC2.

You’ll notice the PV and HVM options under the AMI type column. PV stands for paravirtual and HVM stands for hardware virtual machine. The major difference between PV and HVM is the boot process. HVM is considered relevant for high performance, large capacity use cases. PV is the general choice for smaller instances. Check out AWS documentation for more information on this.

Once you have decided on a release channel, select the corresponding tab in the Amazon EC2 page and then click on the Launch Stack button next to your AWS region and AMI type.

Here’s what that looks like:

launch stack regions

This will take you to your AWS console CloudFormation stack template page.

The cloud formation page has four stages: Select Template, Specify Details, Options, and Review.

In the first stage, there is nothing much to do. The Amazon S3 template URL should be auto-populated and you can just click Next. In the second stage, fill in parameters like ClusterSize, InstanceType, KeyPair, and so on, for your cluster. For the DiscoveryURL section, you need to generate a new token for your cluster using https://discovery.etcd.io/new?size=X, where X is the cluster size.

Here’s what that screen looks like:

CloudFormation template details

You can skip the next two sections: Options and Review. Just click on Create button in Review section to launch your instances. Wait for a few moments and you’ll see the stack page tell you your stack has been created.

You can now move over to the EC2 dashboard and see all the three instances running.

Cloud-Config Setup

If you read my previous post on CoreOS installation on VirtualBox or are aware of cloud-config files in general, you may be wondering: we did not create a user in a cloud-config file? Indeed, we did not create a cloud-config file at all? How is our CoreOS cluster going to get initial settings?

We used the CoreOS template for AWS so cloud-config was there the whole time, it was just hidden.

If you want to see the cloud-config for yourself, you can see it in the first step of the CloudFormation page. Just click the View in designer link next to specify an Amazon S3 template URL text box.

You’ll see something like this:

cloud-config details

CoreOS sets the default cloud-config file for your cluster via the cloud stack formation template. To change or add settings in the cloud-config file, you’ll need to either stop the machine or recreate it. You can read all about the various cloud-config options in the CoreOS docs.

Since the cloud-config we’re using is populated with default values, CoreOS uses the core user without password authentication. You'll need to add an SSH key via the AWS console to log in to your instances.

Connect to the Instance and See Stuff in Action

Let’s connect to one of the systems in the cluster and see if it works.

Open your command prompt and type:

ssh -i <path_to_Key_File> core@<ip address>

If everything is right, you’ll see the CoreOS command prompt as below.

CoreOS command prompt

If so, the cluster is running and you can access it. Success!

Conclusion

In this tutorial we learnt how to install CoreOS on AWS, using the CoreOS AWS template. The process is fairly simple and doesn’t need much technical experience with CoreOS or AWS. The only pre-condition to get started is an active AWS account.

In summary: head over to the CoreOS on EC2 page and choose the CoreOS release you’d like to install. Finally click on the Launch Stack button next to the release, fill in the details in the AWS CloudFormation stack page and you’re good to go.

In future posts we will see the various components of CoreOS in action.

Posted in CoreOS, AWS, Tutorial

triangle square circle

Did you enjoy this post?