Kubernetes vs Amazon ECS
In this updated blog post we’ll compare Kubernetes with Amazon ECS (EC2 Container Service). We’ll walk you through high-level discussions of Kubernetes and Amazon ECS, and then compare these two competing solutions. For completeness, we provide an overview of Kubernetes. If you have already read the previous posts which compare Kubernetes to Docker Swarm or Mesos + Marathon, you can skip this section.
Overview of Kubernetes
According to the Kubernetes website, “Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.” Kubernetes was built by Google based on their experience running containers in production using an internal cluster management system called Borg (sometimes referred to as Omega). The architecture for Kubernetes, which relies on this experience, is shown below:
Recommended Readings
As you can see from the figure above, there are a number of components associated with a Kubernetes cluster. The master node places container workloads in user pods on worker nodes or itself. The other components include:
- etcd: This component stores configuration data which can be accessed by the Kubernetes master’s API Server by simple HTTP or JSON API.
- API Server: This component is the management hub for the Kubernetes master node. It facilitates communication between the various components, thereby maintaining cluster health.
- Controller Manager: This component ensures that the clusters’ desired state matches the current state by scaling workloads up and down.
- Scheduler: This component places the workload on the appropriate node.
- Kubelet: This component receives pod specifications from the API Server and manages pods running in the host.
The following list provides some other common terms associated with Kubernetes:
- Pods: Kubernetes deploys and schedules containers in groups called pods. Containers in a pod run on the same node and share resources such as filesystems, kernel namespaces, and an IP address.
- Deployments: These building blocks can be used to create and manage a group of pods. Deployments can be used with a service tier for scaling horizontally or ensuring availability.
- Services: These are endpoints that can be addressed by name and can be connected to pods using label selectors. The service will automatically round-robin requests between pods. Kubernetes will set up a DNS server for the cluster that watches for new services and allows them to be addressed by name. Services are the “external face” of your container workloads.
- Labels: These are key-value pairs attached to objects. They can be used to search and update multiple objects as a single set.
Overview of Amazon ECS
Amazon ECS is the Docker-compatible container orchestration solution from Amazon Web Services. It allows you to run containerized applications on EC2 instances and scale both of them. The following diagram shows the high-level architecture of ECS.
As shown above, ECS Clusters consist of tasks which run in Docker containers, and container instances, among many other components. Here are some AWS services commonly used with ECS:
- Elastic Load Balancer: This component can route traffic to containers. Two kinds of load balancing are available: application and classic.
- Elastic Block Store: This service provides persistent block storage for ECS tasks (workloads running in containers).
- CloudWatch: This service collects metrics from ECS. Based on CloudWatch metrics, ECS services can be scaled up or down.
- Virtual Private Cloud: An ECS cluster runs within a VPC. A VPC can have one or more subnets.
- CloudTrail: This service can log ECS API calls. Details captured include type of request made to Amazon ECS, source IP address, user details, etc.
ECS, which is provided by Amazon as a service, is composed of multiple built-in components which enable administrators to create clusters, tasks and services:
- State Engine: A container environment can consist of many EC2 container instances and containers. With hundreds or thousands of containers, it is necessary to keep track of the availability of instances to serve new requests based on CPU, memory, load balancing, and other characteristics. The state engine is designed to keep track of available hosts, running containers, and other functions of a cluster manager.
- Schedulers: These components use information from the state engine to place containers in the optimal EC2 container instances. The batch job scheduler is used for tasks that run for a short period of time. The service scheduler is used for long running apps. It can automatically schedule new tasks to an ELB.
- Cluster: This is a logical placement boundary for a set of EC2 container instances within an AWS region. A cluster can span multiple availability zones (AZs), and can be scaled up/down dynamically. A dev/test environment may have 2 clusters: 1 each for production and test.
- Tasks: A task is a unit of work. Task definitions, written in JSON, specify containers that should be co-located (on an EC2 container instance). Though tasks usually consist of a single container, they can also contain multiple containers.
- Services: This component specifies how many tasks should be running across a given cluster. You can interact with services using their API, and use the service scheduler for task placement.
Note that ECS only manages ECS container workloads – resulting in vendor lock-in. There’s no support to run containers on infrastructure outside of EC2, including physical infrastructure or other clouds such as Google Cloud Platform and Microsoft Azure. The advantage, of course, is the ability to work with all the other AWS services like Elastic Load Balancers, CloudTrail, CloudWatch etc.
Further details about Amazon ECS can be found in AWS ECS Documentation.
Kubernetes vs. Amazon ECS
Application Definition | |
Application Scalability Constructs | |
High Availability | |
Load Balancing | |
Auto-scaling for the Application | |
Rolling Application Upgrades and Rollback | |
Health Checks | |
Block Storage | |
Two storage APIs: The first provides abstractions for individual storage backends (e.g. NFS, AWS EBS, Ceph, Flocker). The second provides an abstraction for a storage resource request (e.g. 8 Gb), which can be fulfilled with different storage backends. Modifying the storage resource used by the Docker daemon on a cluster node requires temporarily removing the node from the cluster. Kubernetes offers several types of persistent volumes with block or file support. Examples include iSCSI, NFS, FC, Amazon Web Services, Google Cloud Platform, and Microsoft Azure. The emptyDir volume is non-persistent and can used to read and write files with a container. | Storage support is limited to Amazon Web Services. EBS volumes can be specified by using ECS task definitions (JSON files) and connected to container instances. Task definitions have a “containerDefinitions” section which can be used to enable “mountPoints.” Multiple containers on a container instance can be connected to an EBS storage volume. (Reference: Amazon Web Services Docs) |
Networking | |
The networking model is a flat network, enabling all pods to communicate with one another. Network policies specify how pods communicate with each other. The flat network is typically implemented as an overlay. The model requires two CIDRs: one from which pods get an IP address, the other for services. | ECS is supported in a VPC, which can include multiple subnets in multiple AZs. Communication within a subnet cannot be restricted using AWS tools. |
Service Discovery | |
Services can be found using environment variables or DNS. Kubelet adds a set of environment variables when a pod is run. Kubelet supports simple “{SVCNAME_SERVICE_HOST}” and “{SVCNAME_SERVICE_PORT}” variables, as well as Docker links compatible variables. DNS Server is available as an addon. For each Kubernetes service, the DNS Server creates a set of DNS records. With DNS enabled in the entire cluster, pods will be able to use service names that automatically resolve. | Services can be found using an ELB and a CNAME. A single ELB can be used per service. Route53 private hosted zones can be used to ensure that the ELB CNAMEs are only resolvable within your VPC. |
Performance and Scalability | |
With the release of 1.6, Kubernetes scales to 5,000-node clusters. Multiple clusters can be used to scale beyond this limit. | ECS has been scaled-up to over a 1000 container nodes without noticeable performance degradation. (Deep Dive on Microservices and Amazon ECS, skip to 11:27) |
Synopsis
Advantages of Kubernetes Over Amazon ECS | |
|
|
Disadvantages of Kubernetes | |
|
|
Common Features | |
|
Takeaways
Though both container orchestration solutions are validated by notable names, Kubernetes appears to be significantly more popular online, in the media, and among developers.
Above all, Kubernetes eclipses ECS through its ability to deploy on any x86 server (or even a laptop). Unlike ECS, Kubernetes is not restricted to the Amazon cloud. In fact, Kubernetes can be deployed on Amazon in a traditional cloud or hybrid cloud model, and serve as an alternative to those interested in containers using Amazon.
Customers looking to leverage Kubernetes’ capabilities across clouds and on-premises can use products such as Platform9 Managed Kubernetes. Such offerings can eliminate lock-in and let you focus on deploying containerized applications instead of managing an enterprise Kubernetes deployment on your own. Further details on Platform9 Managed Kubernetes and other deployment models, including Minikube, kubeadm and public clouds, can be found in The Ultimate Guide to Deploy Kubernetes.
This post concludes this blog series about Kubernetes vs Swarm, Kubernetes vs Mesos, and Kubernetes vs Amazon ECS. We’re looking forward to putting out an updated comparison ebook soon.
- Beyond Kubernetes Operations: Discover Platform9’s Always-On Assurance™ - November 29, 2023
- KubeCon 2023 Through Platform9’s Lens: Key Takeaways and Innovative Demos - November 14, 2023
- Getting to know Nate Conger: A candid conversation - June 12, 2023