Unraveling Kubernetes: From EC2 to EKS
Tags: aws, containers, kubernetes, eks
Published: 2024-02-09 14:37:03

### What is Kubernetes?
The concept of isolating application code is something that has been around since the 1970s. By the year 2012, containers running on Linux platforms were transformed into an operating system-level virtualization technology, the need to manage multiple interconnected containers at scale became increasingly evident, and multiple technologies were created to solve just that.

Kubernetes was released in September of 2014 (almost two most after Terraform :eyes:). At its core, it is an open-source platform designed to automate the deployment, scaling, and operation of application containers across clusters of hosts. It provides the framework to run distributed systems resiliently, taking care of scaling and failover for your application, providing deployment patterns, and more. Essentially, Kubernetes is about abstracting away the complexity of managing a fleet of containers, which are lightweight, portable, self-sufficient packages that can run cloud-native applications.

![Kubernetes at work](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gy12tjdqdefx4hb9uehe.png)


### The Benefits of Kubernetes

Kubernetes offers a plethora of benefits that have made it the de facto standard for container orchestration:

- **Scalability**: Effortlessly scale your applications up or down based on demand, with Kubernetes handling the complexity of managing container distribution across the cluster.
- **High Availability**: Kubernetes ensures your application is always available, regardless of individual server failures, by distributing containers across multiple nodes.
- **Portability**: Run your applications on any public cloud, private cloud, or on-premises server.
- **Self-healing**: Automatically restarts containers that fail, replaces and reschedules containers when nodes die, kills containers that don't respond to user-defined health checks, and doesn't advertise them to clients until they are ready to serve.

### Historical Need to Run Kubernetes on EC2 VMs

Before the advent of Kubernetes as a managed service in AWS, deploying it on virtual machines, such as AWS EC2, was the norm. This setup involved manually installing Kubernetes on each VM, configuring the network, setting up storage, and ensuring security and isolation between the containers. The process was intricate, involving:

1. Setting up an EC2 instance for the Kubernetes master.
2. Configuring additional EC2 instances to serve as worker nodes.
3. Installing Kubernetes on all instances and configuring them to communicate with each other.
4. Setting up networking to allow containers to communicate within the cluster and with the outside world.

This manual setup was time-consuming and required a deep understanding of Kubernetes internals.

### What is EKS?

Amazon Elastic Kubernetes Service (EKS) is AWS's managed service, making it easy to run Kubernetes on AWS and on-premises with Amazon EKS Anywhere. EKS abstracts away the complexity of installing and managing Kubernetes, providing a highly available and secure Kubernetes control plane. With EKS, AWS manages the Kubernetes master nodes, relieving developers and sysadmins from the operational overhead of managing the Kubernetes infrastructure.

### Differences between EKS vs Running your own Kubernetes Cluster on EC2 VMs

The choice between EKS and self-managed Kubernetes on EC2 boils down to the trade-off between control and convenience:

- **Managed Service vs Manual Configuration**: EKS provides a managed Kubernetes service where the control plane is managed by AWS, reducing the operational complexity. In contrast, running Kubernetes on EC2 requires manual setup and management.
- **Scalability and Availability**: EKS automatically scales the Kubernetes control plane, ensuring high availability without manual intervention. Running Kubernetes on EC2 requires manual scaling and failover management.
- **Security and Compliance**: EKS is integrated with AWS security services, such as IAM, for authentication, simplifying compliance and security management. A self-managed Kubernetes setup requires manual configuration of security policies and networking rules.
- **Cost**: While EKS simplifies Kubernetes management, it comes with additional costs for the managed control plane. Running Kubernetes on EC2 gives you more control over costs, especially if you can optimize your cluster's utilization and manage its complexity.The EKS control plane requires nodes in multiple availability zones to ensure high availability, this translates to  a minimal cost of $75 a month for each Amazon EKS cluster with a standard 3-node configuration.

![EKS Control Plane](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/awq73jfjpnzkyq4g6qv3.jpeg)

### Conclusion

Kubernetes has significantly simplified containerised applications' deployment, scaling, and management. While running Kubernetes on EC2 VMs offers full control over the Kubernetes cluster, it comes with the added complexity of manual management. EKS, on the other hand, provides a managed Kubernetes service that abstracts much of this complexity, allowing developers to focus on building their applications rather than managing the underlying infrastructure. Ultimately, choosing between EKS and a self-managed Kubernetes cluster on EC2 depends on your specific needs, skills, and budget constraints. Regardless of the path chosen, Kubernetes remains a powerful tool in the cloud-native ecosystem, enabling businesses to deploy and manage applications at scale efficiently.