Book Image

Mastering Elastic Kubernetes Service on AWS

By : Malcolm Orr, Yang-Xin Cao (Eason)
5 (1)
Book Image

Mastering Elastic Kubernetes Service on AWS

5 (1)
By: Malcolm Orr, Yang-Xin Cao (Eason)

Overview of this book

Kubernetes has emerged as the de facto standard for container orchestration, with recent developments making it easy to deploy and handle a Kubernetes cluster. However, a few challenges such as networking, load balancing, monitoring, and security remain. To address these issues, Amazon EKS offers a managed Kubernetes service to improve the performance, scalability, reliability, and availability of AWS infrastructure and integrate with AWS networking and security services with ease. You’ll begin by exploring the fundamentals of Docker, Kubernetes, Amazon EKS, and its architecture along with different ways to set up EKS. Next, you’ll find out how to manage Amazon EKS, encompassing security, cluster authentication, networking, and cluster version upgrades. As you advance, you’ll discover best practices and learn to deploy applications on Amazon EKS through different use cases, including pushing images to ECR and setting up storage and load balancing. With the help of several actionable practices and scenarios, you’ll gain the know-how to resolve scaling and monitoring issues. Finally, you will overcome the challenges in EKS by developing the right skill set to troubleshoot common issues with the right logic. By the end of this Kubernetes book, you’ll be able to effectively manage your own Kubernetes clusters and other components on AWS.
Table of Contents (28 chapters)
1
Part 1: Getting Started with Amazon EKS
7
Part 2: Deep Dive into EKS
13
Part 3: Deploying an Application on EKS
20
Part 4: Advanced EKS Service Mesh and Scaling
24
Part 5: Overcoming Common EKS Challenges

Building and pushing a container image to ECR

If we consider a simple API using Python and FastAPI, shown next, we need to first package that up into a Docker image locally. We can then test if it is working locally before we push it to ECR. I’ve chosen Python and FastAPI as they are very simple to get up and running, but you can create the container using any language or framework.

The Python code in the main.py file is shown next:

#!/usr/bin/env python3
'''simple API server that returns Hello World'''
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
    return {"message": "Hello World"}

We will also need a requirements.txt file, which will have the following entries:

nyio==3.6.1
click==8.1.3
fastapi==0.83.0
h11==0.13.0
httptools==0.5.0
idna==3.3
importlib-metadata==4.12.0
pydantic==1.10.2
python-dotenv==0.21.0
PyYAML==6.0
sniffio==1.3.0
starlette==0.19.1
typing...