AWS EKS and Kubernetes Introduction
# CHAPTER 22
AWS EKS and Kubernetes Introduction
1. Introduction
While Amazon ECS (Chapter 21) is a brilliant, easy-to-use container orchestrator, it is proprietary to AWS. If you build your company's infrastructure on ECS and later decide to move to Google Cloud or Microsoft Azure, you have to rewrite your entire orchestration architecture. To avoid this "Vendor Lock-in," the global tech industry standardized on Kubernetes (K8s), an open-source container orchestrator originally built by Google. Because Kubernetes is notoriously difficult to set up, AWS offers Amazon EKS (Elastic Kubernetes Service) to manage the hardest parts for you.2. Learning Objectives
By the end of this chapter, you will be able to:- Define Kubernetes (K8s) and understand why it is the industry standard.
- Understand the difference between the Kubernetes Control Plane and Worker Nodes.
- Define fundamental K8s concepts: Pods, Deployments, and Services.
- Understand the role of Amazon EKS in managing the Control Plane.
- Contrast EKS with ECS.
3. Beginner-Friendly Explanation
Imagine a massive symphony orchestra (Your application).- The Musicians (Containers): The individuals playing the instruments (Your Docker containers doing the actual computing work).
- The Conductor (Kubernetes): The maestro waving the baton. The conductor doesn't play an instrument; they orchestrate. They tell the violins to play louder (scale up containers), and if a trumpet player falls off their chair (container crash), the conductor immediately points to a backup player to take their place.
If you had to build the Conductor's podium and hire the Conductor yourself, it would take months. Amazon EKS simply rents you a world-class Conductor who is already standing on the podium, ready to direct your musicians.
4. Why Kubernetes? (The "K8s" Acronym)
*Note: K8s is shorthand for Kubernetes (K + 8 letters + s).* Kubernetes is cloud-agnostic. A configuration file written for Kubernetes will run perfectly on AWS, Azure, Google Cloud, or even the servers sitting in your company's basement. This gives massive enterprises the ultimate flexibility to move their code anywhere in the world.5. Kubernetes Architecture Basics
A Kubernetes Cluster is divided into two main sections:- 1. The Control Plane (The Brain): The master servers that make global decisions, schedule containers, and monitor health. In a self-managed cluster, configuring the Control Plane is agonizingly complex.
- 2. The Worker Nodes (The Muscle): The actual EC2 servers where your containers run.
The Magic of EKS: With Amazon EKS, AWS completely hides and manages the Control Plane for you. You pay $0.10 an hour, and AWS guarantees the "Brain" never crashes. You only have to manage the Worker Nodes.
6. Kubernetes Vocabulary
Kubernetes has its own complex language. Forget everything you learned in ECS.- Pod: The smallest unit in K8s. A Pod is a wrapper around 1 (or sometimes more) Docker container(s). K8s does not manage containers directly; it manages Pods.
- Deployment: A blueprint that tells K8s: "I want 3 identical Pods of my web server running at all times." If a Pod dies, the Deployment creates a new one.
- Service: Because Pods are constantly dying and being reborn with new IP addresses, you cannot rely on their IPs. A K8s Service provides a single, static IP address and Load Balancer to route traffic to the dynamic Pods.
7. Mini Project: Deploying an App on Kubernetes
You do not use the AWS Console to manage Kubernetes. You use a command-line tool calledkubectl.
Step-by-Step Conceptual Flow:
-
1.
Create EKS Cluster: Use the AWS Console or the
eksctlCLI tool to provision the EKS Control Plane.
-
2.
Add Node Group: Tell EKS to launch 3 EC2
t3.mediuminstances to act as Worker Nodes.
-
3.
Write a YAML Manifest: You write a configuration file (
deployment.yaml) on your laptop:
-
4.
Deploy: In your terminal, you run:
kubectl apply -f deployment.yaml.
-
5.
The Magic:
kubectlsends the YAML to the EKS Control Plane. The Control Plane reads it, realizes you want 3 Nginx web servers, and instantly deploys 3 Pods across your EC2 Worker Nodes.
8. Best Practices
- Fargate with EKS: Just like ECS, EKS supports AWS Fargate! If you do not want to manage the EC2 Worker Nodes, you can configure your EKS cluster to use Fargate profiles. AWS will run your Kubernetes Pods on invisible serverless infrastructure.
9. Common Mistakes
-
Choosing EKS for Simple Projects: EKS is expensive ($70/month just for the Control Plane, not including your EC2 servers) and requires a steep learning curve to master
kubectland YAML manifests. Do not use Kubernetes for a simple 3-container website. Use ECS. Only choose EKS if you are building massive, multi-team enterprise microservices or require multi-cloud portability.
10. Exercises
- 1. Define a Kubernetes "Pod". Why does K8s manage Pods instead of managing individual Docker containers directly?
- 2. Explain the fundamental advantage of utilizing Kubernetes over Amazon ECS regarding Vendor Lock-in.
11. MCQs with Answers
When utilizing Amazon EKS (Elastic Kubernetes Service), which component of the Kubernetes architecture is fully managed, patched, and highly available automatically by AWS, relieving the customer of administrative burden?
In Kubernetes, what is the purpose of a "Service" resource?
12. Interview Questions
- Q: Compare Amazon ECS with Amazon EKS. As a Cloud Architect, what specific business and technical requirements would compel you to recommend the steep learning curve of EKS over the simplicity of ECS?
- Q: Walk me through the core components of Kubernetes. Explain the relationship between a Container, a Pod, a Deployment, and a Service.