Part 1. Getting to know CoreOS
In these first three chapters, youâll get to know what CoreOS is all about. Iâll cover some terminology and the systems that form CoreOS and get you up and running with a sandbox environment. Youâll also start working on an application stack that youâll build on throughout the book.
Chapter 1. Introduction to the CoreOS family
This chapter covers
- Overview of CoreOS systems and concepts
- Understanding common workflow patterns for CoreOS
- Introducing fleet and etcd, and systemd units
Suppose youâve been hired by a new company that wants you to build out a modern infrastructure and operational architecture for its developers. The company has a wide range of application stacks, and you have strong requirements around horizontal scalability and high availability. You know you want Linux, but the idea of maintaining endless operating system updates and changes or setting up complex configuration-management systems is unappealing. You recognize that containerization can make this far easierâyou can separate the operational configuration from the applicationsââbut youâre still left with how to manage all those containers at scale. Plenty of distributions today support Docker, but not in a way that seems designed for large-scale production use.
Enter CoreOS: an OS designed from the ground up to facilitate container operationalization at any scale. Itâs highly fault tolerant and extremely lightweight, and it appears performant, but how do you get started? You know the goal: you want to provide your engineers with a container-based platform as a service, and you know CoreOS can be the hammer to hit that nail. But how do you get it running? How do you adapt or design application architectures to best take advantage of this system?
Note
If you want to know more about where the ideas in CoreOS came from, be sure to read the âBackgroundâ section in the âAbout this bookâ portion of this bookâs front matter.
In this chapter, weâll go over the various parts that make up the CoreOS family of systems, and weâll look a little at how they can solve infrastructure and architecture problems like those just described. By the end of this chapter, youâll have a clear understanding of CoreOS and how its core components fit together, along with some ideas about its utility that you can take into chapter 2, when we discuss building out a local cluster.
1.1. Meet CoreOS
CoreOS is here to solve your scale, availability, and deployment workflow problems. In this chapter, weâll go through a simple application deployment of NGINX (a popular HTTP server) to illustrate how CoreOS achieves some of these solutions, and review some essential systems. With CoreOS, you wonât have to manage packages, initiate lengthy upgrade processes, plan out complex configuration files, fiddle with permissions, plan significant maintenance windows (for the OS), or deal with complicated configuration schema changes. If you fully embrace CoreOSâs features, your cluster of nodes will always have the latest version of the OS, and you wonât have any downtime.
These ideas can be a little difficult to grasp when youâre first getting started with CoreOS, but they embody the philosophy of an immutable OS after boot, which creates an experience with the OS that you probably arenât used to. CoreOSâs distributed scheduler, fleet, manages the state of your application stack, and CoreOS provides the platform on which those systems orchestrate your services. If you have a computer science background, you can consider traditional configuration-management systems as relying heavily on side effects to constantly manipulate the state of the OS, whereas in CoreOS, the state of the OS is created once on boot, never changes, and is lost on shutdown. This is a powerful concept, and it forces architectures with high degrees of idempotence and no hidden side effects, the results of which are vastly improved certainty about the reliability of your systems and drastically reduced need for layers of complex tooling to monitor and manage OSs. In this section, I provide an overview of the parts that make CoreOS tick and how they complement each other.
CoreOS background CoreOS is a Linux distribution based, in a way, on Gentoo Linux. Similar to how Googleâs Chrome OS is based on Gentoo, this only matters for those interested in hacking on CoreOS itself, which isnât covered in this book (although this book would certainly be an excellent guide to understanding what youâre working on).
The reason this probably doesnât matter to you is a bit more complicated. CoreOS is designed to present a small number of services that act as a lightweight, distributed system; the point of CoreOS is that it mostly stays out of your way, and itâs immutably configured on boot, much as a container is. This is very different from virtually all other Linux distributions or OSs as a whole. In chapter 8, weâll dive deeper into cloud-config, which describes the state of the OS, most of which is concerned with cluster discovery and initializing core services that you may want to manage outside of fleet.
On containerization Weâll go into how you can tune your containers to best function with CoreOS, but you should have some experience with Docker and the concepts of containerization to get the most out of this book. You can also check out Docker in Action by Jeff Nickoloff (Manning, 2016, www.manning.com/books/docker-in-action).
1.1.1. The CoreOS family
CoreOS consists of a few critical systems and services that manage all the scalability and fault tolerance it claims to facilitate. Figure 1.1 provides a high-level idea of how the cluster layout looks.
Figure 1.1. CoreOS layout
Weâll go into each of these components in some detail in the next section, and significantly more detail later in the book, but this represents the key systems that make up CoreOS:
- etcd acts as your clusterâs persistent configuration state (see section 1.1.2).
- fleetd acts as your clusterâs distributed runtime scheduler (see section 1.1.3).
- systemd unit files are the mechanism by which fleetd executes the runtime (see section 1.1.4).
- Docker and rkt are the common container platforms that your unit files will run. CoreOS intends all of your runtime to happen in containers, and you can choose from these two platforms (or a combination of both; see section 1.1.5).
The one essential system missing from figure 1.1 is cloud-config, which is used to set the initial configuration state of a machine. Itâs more a detail of infrastructure configuration than a requirement to understand CoreOSâs concepts; section 1.1.6 covers it in detail.
1.1.2. etcd and the distributed configuration state
etcd is a high-reliability distributed key/value store. If youâre familiar with memcached or redis, itâs similar, but with more focus on (distributed) consistency and availability over performance. Itâs accessible via custom command-line tools and is fully RESTful and JSON based. As its name implies, etcd is designed to distribute your system and services configuration. Itâs the data store for fleet (CoreOSâs distributed scheduler).
fleet and CoreOS use etcd to find peers, distribute locks for various purposes, and orchestrate running systemd units across the cluster. Although itâs useful in that regard alone, itâs also designed to be your place to persist configuration in the cluster. In the example later in this chapter, youâll use it to register NGINX instances for a load balancer to discover.
etcd isnât designed for large-object storage or massive performance; its primary purpose is to make the state of the cluster singular. Beyond cloud-config, which sets initial state, no other s...