DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

Kubernetes - From ECS 3-Tier Arch to Production Microservices

1. What We Built Already

Students already created:

Frontend Container
        ↓
Backend Container
        ↓
RDS PostgreSQL
Enter fullscreen mode Exit fullscreen mode

Infrastructure:

Users
  ↓
ALB
  ↓
ECS Fargate
  ↓
Frontend Container
  ↓
Backend Container
  ↓
RDS PostgreSQL
Enter fullscreen mode Exit fullscreen mode

Technologies:

  • Docker
  • ECS Fargate
  • ECR
  • RDS
  • AWS Networking
  • Security Groups

This is called:

Three-Tier Architecture


2. Problem with Traditional Backend

Initially companies create:

One frontend
One huge backend
One database
Enter fullscreen mode Exit fullscreen mode

But when traffic grows:

Problems appear:

  • Backend becomes huge
  • One bug crashes entire backend
  • Difficult deployments
  • Scaling becomes expensive
  • One team changes code → affects everyone
  • Downtime during deployments

Example:

Netflix cannot keep:

1 giant backend
Enter fullscreen mode Exit fullscreen mode

Instead they split services.


3. What Are Microservices?

Instead of:

backend-service
Enter fullscreen mode Exit fullscreen mode

We split into:

auth-service
payment-service
course-service
student-service
notification-service
Enter fullscreen mode Exit fullscreen mode

Each service:

  • independent
  • deploys separately
  • scales separately
  • owned by different teams

This is:

Microservice Architecture


4. What is Kubernetes?

Kubernetes (K8s)

Kubernetes is:

Container Orchestration Platform

It manages:

  • containers
  • scaling
  • networking
  • deployments
  • recovery
  • updates

Automatically.

Created by:

Google

Based on:

Borg system

Now maintained by:

CNCF


5. Why Companies Use Kubernetes

Companies need:

  • high availability
  • scaling
  • self healing
  • automation
  • rolling updates
  • multi-cloud portability

Kubernetes solves these problems.

Used by:

  • Netflix
  • Uber
  • Spotify
  • Airbnb
  • Amazon
  • Banks
  • Healthcare companies

6. ECS vs Kubernetes

ECS Kubernetes
AWS only Multi-cloud
Easier More complex
Faster to start Industry standard
Less control Very flexible
AWS manages much You manage more
Simple learning curve Steeper learning curve

7. ECS Flow

In ECS we did:

Docker Build
    ↓
Push to ECR
    ↓
Task Definition
    ↓
ECS Service
    ↓
Running Containers
Enter fullscreen mode Exit fullscreen mode

AWS handled:

  • orchestration
  • scheduling
  • networking

8. Kubernetes Flow

In Kubernetes:

Docker Build
      ↓
Push to ECR
      ↓
Deployment YAML
      ↓
Pods
      ↓
Services
      ↓
Ingress
Enter fullscreen mode Exit fullscreen mode

Kubernetes uses YAML configuration.


9. Kubernetes Architecture

Main components:

Control Plane
    ↓
Worker Nodes
    ↓
Pods
Enter fullscreen mode Exit fullscreen mode

10. Control Plane

Control Plane = brain of Kubernetes

Components:

  • API Server
  • Scheduler
  • Controller Manager
  • etcd

Responsibilities:

  • manage cluster
  • schedule pods
  • maintain desired state

11. Worker Nodes

Worker Nodes run applications.

Inside nodes:

  • kubelet
  • container runtime
  • kube-proxy

Worker nodes host:

Pods


12. What is a Pod?

Pod = smallest Kubernetes object.

A Pod contains:

  • one or more containers

Example:

Pod
 ├── frontend container
 └── helper container
Enter fullscreen mode Exit fullscreen mode

Usually:

  • 1 container per pod

13. Why Pods?

Pods provide:

  • shared networking
  • shared storage
  • lifecycle management

Containers inside pod communicate using:

localhost
Enter fullscreen mode Exit fullscreen mode

14. Deployment

Deployment manages pods.

Example:

Deployment
      ↓
ReplicaSet
      ↓
Pods
Enter fullscreen mode Exit fullscreen mode

Responsibilities:

  • scaling
  • rolling updates
  • self healing
  • restarting failed pods

15. ReplicaSet

ReplicaSet ensures:

desired pods = running pods
Enter fullscreen mode Exit fullscreen mode

Example:

3 replicas requested
1 pod crashes
Kubernetes creates new pod automatically
Enter fullscreen mode Exit fullscreen mode

16. Kubernetes Self-Healing

If pod crashes:

Kubernetes:

  • detects failure
  • recreates pod
  • restores application

Automatically.

This is:

Self-Healing Infrastructure


17. Kubernetes Services

Pods change IPs constantly.

Service gives:

  • stable endpoint
  • internal communication

Types:

  • ClusterIP
  • NodePort
  • LoadBalancer

18. ClusterIP

Default service.

Internal communication only.

Example:

frontend → backend-service
Enter fullscreen mode Exit fullscreen mode

Inside cluster only.


19. NodePort

Exposes service on node port.

Example:

NodeIP:30080
Enter fullscreen mode Exit fullscreen mode

Mostly for labs/testing.


20. LoadBalancer

Creates cloud load balancer.

In AWS:

  • creates ALB/NLB automatically

Used for production.


21. Ingress

Ingress controls:

  • HTTP routing
  • domains
  • SSL
  • path routing

Example:

/api → backend
/admin → admin-service
Enter fullscreen mode Exit fullscreen mode

Ingress acts like:

Smart Traffic Router


22. Kubernetes Networking

Each Pod gets:

  • its own IP

Pods communicate directly.

Kubernetes provides:

  • internal DNS
  • service discovery

Example:

backend-service.default.svc.cluster.local
Enter fullscreen mode Exit fullscreen mode

23. Kubernetes Storage

Containers are temporary.

Databases need persistence.

Kubernetes uses:

  • Persistent Volumes
  • Persistent Volume Claims

BUT:

Production companies usually keep databases outside cluster:

RDS

Aurora

Cloud SQL


24. Why RDS Outside Kubernetes?

Reasons:

  • easier backups
  • managed failover
  • better stability
  • managed scaling
  • less operational risk

Very common architecture:

EKS + RDS
Enter fullscreen mode Exit fullscreen mode

25. Kubernetes Scaling

Kubernetes can scale automatically.

Using:

HPA

Horizontal Pod Autoscaler.

Example:

CPU > 70%
Pods scale from 2 → 10
Enter fullscreen mode Exit fullscreen mode

26. Rolling Updates

Without downtime.

Old pods terminate gradually.

New pods start gradually.

Users never notice deployment.

This is:

Zero Downtime Deployment


27. Production Kubernetes Architecture

Production flow:

Users
  ↓
CloudFront
  ↓
ALB
  ↓
Ingress
  ↓
Frontend Pods
  ↓
Backend Microservices
  ↓
RDS PostgreSQL
Enter fullscreen mode Exit fullscreen mode

Monitoring:

Prometheus
Grafana
Loki
CloudWatch
Enter fullscreen mode Exit fullscreen mode

CI/CD:

GitHub Actions
Jenkins
ArgoCD
Enter fullscreen mode Exit fullscreen mode

28. Kubernetes Security

Production security:

  • RBAC
  • IAM Roles
  • Secrets
  • Network Policies
  • Private Subnets
  • TLS/SSL

Never store passwords in code.

Use:

  • Kubernetes Secrets
  • AWS Secrets Manager

29. Kubernetes YAML

Kubernetes uses YAML files.

Example structure:

apiVersion:
kind:
metadata:
spec:
Enter fullscreen mode Exit fullscreen mode

Main files:

  • deployment.yaml
  • service.yaml
  • ingress.yaml

30. Example Deployment YAML

apiVersion: apps/v1
kind: Deployment

metadata:
  name: frontend

spec:
  replicas: 2

  selector:
    matchLabels:
      app: frontend

  template:
    metadata:
      labels:
        app: frontend

    spec:
      containers:
      - name: frontend
        image: nginx
        ports:
        - containerPort: 80
Enter fullscreen mode Exit fullscreen mode

31. Important kubectl Commands

Create resources:

kubectl apply -f deployment.yaml
Enter fullscreen mode Exit fullscreen mode

View pods:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

View services:

kubectl get svc
Enter fullscreen mode Exit fullscreen mode

Describe pod:

kubectl describe pod pod-name
Enter fullscreen mode Exit fullscreen mode

View logs:

kubectl logs pod-name
Enter fullscreen mode Exit fullscreen mode

32. EKS (Elastic Kubernetes Service)

AWS Managed Kubernetes.

AWS manages:

  • Control Plane
  • High availability
  • etcd

We manage:

  • worker nodes
  • deployments
  • pods

33. Why Companies Love EKS

Benefits:

  • Kubernetes without managing masters
  • AWS integration
  • IAM integration
  • ALB integration
  • CloudWatch integration

Very common in enterprise.


34. ECS vs EKS in Production

ECS:

  • simpler
  • faster
  • easier for AWS-only environments

EKS:

  • portable
  • more powerful
  • more enterprise demand
  • industry standard

35. Real Production Example

E-commerce company:

Microservices:

  • auth-service
  • order-service
  • payment-service
  • inventory-service
  • notification-service

Each service:

  • independent deployment
  • independent scaling

Traffic spike:

  • only payment-service scales

Huge advantage.


36. Monitoring Kubernetes

Observability stack:

Prometheus → metrics
Grafana → dashboards
Loki → logs
Alertmanager → alerts
Enter fullscreen mode Exit fullscreen mode

Your current stack already matches production patterns.


37. CI/CD Pipeline

Modern deployment flow:

Developer
   ↓
GitHub
   ↓
GitHub Actions
   ↓
Docker Build
   ↓
Push to ECR
   ↓
Deploy to EKS
Enter fullscreen mode Exit fullscreen mode

38. Interview Questions

Common DevOps interview questions:

  • What is Pod?
  • Difference between ECS and EKS?
  • What is Deployment?
  • What is Service?
  • What is Ingress?
  • What is HPA?
  • What happens when pod crashes?
  • Difference between container and pod?

39. Career Impact

Kubernetes skills are highly demanded.

Roles:

  • DevOps Engineer
  • SRE
  • Platform Engineer
  • Cloud Engineer
  • Kubernetes Administrator

40. Final Architecture Summary

Current:

3-Tier ECS Architecture
Enter fullscreen mode Exit fullscreen mode

Future:

Production Kubernetes Microservices Platform
Enter fullscreen mode Exit fullscreen mode

Final production vision:

Users
 ↓
CloudFront
 ↓
ALB
 ↓
Ingress
 ↓
Frontend Pods
 ↓
Microservices
 ↓
RDS
 ↓
Monitoring Stack
Enter fullscreen mode Exit fullscreen mode

This is real enterprise architecture used in production today.

Top comments (0)