Book Image

Learning CoreOS

By : Kingston Smiler. S, Shantanu Agrawal
Book Image

Learning CoreOS

By: Kingston Smiler. S, Shantanu Agrawal

Overview of this book

CoreOS is an open source operating system developed upon the Linux kernel. The rise of CoreOS is directly related to the rise of Docker (a Linux container management system). It is a minimal operating system layer and takes a different approach to automating the deployment of containers. The major difference between CoreOS and other Linux distributions is that CoreOS was designed to deploy hundreds of servers. CoreOS immensely helps the users to create systems, which are easy to scale and manage, making life easier for all, be it developer, QA, or deployer. This book is all about setting up, deploying, and using CoreOS to manage clusters and clouds. It will help you understand what CoreOS is and its benefits as a cloud orchestration platform. First, we’ll show you how to set up a simple CoreOS instance with single node in the cluster and how to run a Docker container inside the CoreOS instance. Next, you’ll be introduced to Fleet and systemd, and will deploy and distribute Docker services across different nodes in cluster using Fleet. Later, you’ll be briefed about running services in a cluster with constraints, publishing the services already running on the cluster to new services, and making your services interact with each other. We conclude by teaching you about advanced container networking. By the end of the book, you will know the salient features of CoreOS and will be able to deploy, administrate, and secure a CoreOS environment.
Table of Contents (15 chapters)
Learning CoreOS
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Introduction to CoreOS


CoreOS is a lightweight cloud service orchestration operating system based on Google's Chrome OS. CoreOS is developed primarily for orchestrating applications/services over a cluster of nodes. Every node in the cluster runs CoreOS and one of the CoreOS nodes in the cluster will be elected as the master node by the etcd service. All the nodes in the cluster should have connectivity to the master node. All the slave nodes in the system provide information about the list of services running inside their system, along with the configuration parameter to the master node. In order to do this, we may have to configure fleet units in such a way that when we start a fleet unit with the fleetctl command, it should push its details such as IP and port to the etcd service. It is the responsibility of the master node to receive the service information and publish to all the other nodes in the cluster. In normal circumstances, the slave nodes won't talk to each other regarding service availability. The etcd service running in all the nodes in the cluster is responsible for electing the master node. All nodes in the system interact with the etcd service of the master node to get the service and configuration information of the services running in all other nodes. The following diagram depicts the CoreOS cluster architecture, wherein all the nodes in the cluster run CoreOS and other vital components of CoreOS like etcd, systemd, and so on. The etcd and fleet services are used for service discovery and cluster management respectively. In this, all three nodes are configured with the same cluster ID, so that all these nodes can be part of a single cluster. It is not possible for a node to be part of multiple clusters.

CoreOS cluster

All the applications or services are deployed as a Linux container in the CoreOS. The Linux container provides a lightweight server virtualization infrastructure without running its own operating system or any hypervisor. It uses the operating system-level virtualization techniques provided by the host OS using the namespace concept. This provides drastic improvements in terms of scaling and performance of virtualization instances running over the physical server. This addresses the first issue of running the application inside a VM.

The following diagram depicts the difference between applications running inside a VM and applications running in an LXC container. In the following diagram, the VM way of virtualization has a guest OS installed in the VM along with the host OS. In a Linux container-based implementation, the container doesn't have a separate copy of the operating system; rather, it uses the service provided by the host operating system for all the OS-related functionalities.

Virtual Machine versus Linux Container

CoreOS extends the existing services provided by Linux to work for a distributed cluster and not limited to a single node. As an example, CoreOS extends the system management service provided by most of the Linux distribution for starting, stopping, or restarting any applications/services to run on a cluster of nodes rather than a single node using the fleet tool. Instead of running an application limited to its own node, the services are submitted to fleet, which acts as a cluster manager and instantiates the service in any one of the nodes in the cluster. It is also possible to launch the container in a specific set of nodes by applying a constraint. This addresses the second issue with using VMs, discussed earlier in this chapter.

CoreOS uses Docker/Rocket as a container to deploy services inside the CoreOS cluster. Docker provides an easy way of bundling a service and its dependent module as a single monolithic image that can be shipped from development. In the deployment, the DevOps person can simply fetch the docker container from the development person and can deploy directly into the CoreOS nodes without performing any operations like building a compilation or build environment and rebuilding the image on the target platform and so on. This bridges the gap between the development and deployment of a service. This addresses the third issue with using VM, discussed earlier in this chapter.