πŸš€ Day 27/30 – Kubernetes Basics with AWS EKS | 30 Days DevOps + Cloud + SRE Interview Prep

Series: 30 Days DevOps Interview Preparation
Author: Tathagat Gaikwad

Welcome to Day 27 of my 30-Day DevOps + Cloud + SRE Interview Preparation Challenge.
Today’s focus is on Kubernetes (K8s) – the de facto standard for container orchestration.

If you’ve ever wondered:
πŸ‘‰ How do big companies like Netflix, Spotify, and Amazon deploy and scale thousands of containers daily?
πŸ‘‰ How do we ensure applications stay up even if servers fail?

The answer is: Kubernetes.


πŸ”Ή What is Kubernetes?

Kubernetes (often abbreviated as K8s) is an open-source container orchestration platform originally developed by Google.

It automates:

  • πŸ“¦ Container deployment

  • πŸ“ˆ Scaling applications up or down

  • βš–οΈ Load balancing traffic

  • πŸ’€ Self-healing (restarting failed containers, rescheduling them on healthy nodes)

  • πŸ”„ Rolling updates and rollbacks

πŸ‘‰ Think of Docker as a shipping container and Kubernetes as the global logistics company managing thousands of containers across the globe.


πŸ—οΈ Core Kubernetes Concepts

  1. Pod β†’ The smallest deployable unit in Kubernetes. A Pod usually runs one container, but can run multiple tightly coupled containers.

  2. Deployment β†’ Ensures that the right number of Pods are running. Provides rolling updates and rollbacks.

  3. ReplicaSet β†’ Maintains a stable set of replicas (Pods).

  4. Service β†’ Exposes Pods to the network.

    • ClusterIP β†’ Internal access only within the cluster.

    • NodePort β†’ Exposes the service externally via NodeIP:Port.

    • LoadBalancer β†’ Integrates with cloud providers (AWS, GCP, Azure) to expose services externally with load balancing.


πŸ› οΈ Practical – Setting up Kubernetes on AWS EKS

For today’s hands-on, we’ll use Amazon Elastic Kubernetes Service (EKS) – a managed Kubernetes service.

Step 1: Install Prerequisites

# Install AWS CLI
sudo apt-get update && sudo apt-get install -y awscli  

# Install eksctl (EKS cluster creation tool)
curl --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz
sudo mv eksctl /usr/local/bin  

# Install kubectl
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/latest/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin

Step 2: Create an EKS Cluster

eksctl create cluster \
--name devops-cluster \
--version 1.28 \
--region ap-south-1 \
--nodegroup-name devops-nodes \
--node-type t3.medium \
--nodes 2 \
--nodes-min 1 \
--nodes-max 3 \
--managed

This creates:

  • A Kubernetes cluster named devops-cluster

  • 2 worker nodes in AWS


Step 3: Verify Cluster Connection

kubectl get nodes
kubectl cluster-info

You should see your EKS nodes ready. πŸŽ‰


Step 4: Deploy a Sample App

# Create a deployment
kubectl create deployment myapp --image=nginx  

# Expose it as a NodePort service
kubectl expose deployment myapp --type=NodePort --port=80  

# Get the service details
kubectl get svc myapp

Now, access your app at http://<NodePublicIP>:<NodePort>.


Step 5: Scale and Rollout

# Scale to 3 replicas
kubectl scale deployment myapp --replicas=3  

# Check rollout status
kubectl rollout status deployment/myapp  

# Update image (rolling update)
kubectl set image deployment/myapp nginx=nginx:1.21 --record  

# Rollback if needed
kubectl rollout undo deployment/myapp

🎯 Kubernetes Interview Questions & Detailed Answers

Q1: What is the difference between Docker and Kubernetes?
πŸ‘‰ Docker is for building and running containers.
πŸ‘‰ Kubernetes is for managing containers across multiple hosts (scheduling, scaling, networking).
They complement each other, not replace.


Q2: What is a Pod in Kubernetes?
πŸ‘‰ A Pod is the smallest unit in Kubernetes, representing a running process.

  • Usually holds 1 container

  • Can hold multiple tightly coupled containers (e.g., a main app + sidecar container)

  • All containers inside a Pod share the same IP address, network, and storage.


Q3: How does Kubernetes ensure high availability?
πŸ‘‰ Kubernetes ensures HA by:

  • Maintaining the desired state via Deployments and ReplicaSets.

  • Rescheduling Pods to healthy nodes if a node crashes.

  • Distributing traffic via Services and Load Balancers.


Q4: What is the difference between ClusterIP, NodePort, and LoadBalancer?

  • ClusterIP β†’ Default, internal-only, used for communication inside the cluster.

  • NodePort β†’ Exposes app externally on a specific port across all nodes (<NodeIP>:<Port>).

  • LoadBalancer β†’ Integrates with cloud providers to automatically create an external load balancer.


Q5: How do rolling updates and rollbacks work in Kubernetes?

  • Rolling Update: Replaces Pods gradually without downtime.
kubectl set image deployment/myapp nginx=nginx:1.21 --record
  • Rollback: Reverts to the previous working version.
kubectl rollout undo deployment/myapp

βœ… Takeaways from Day 27

  • Kubernetes is the industry standard for container orchestration.

  • Hands-on practice with Pods, Deployments, and Services gives you confidence for interviews.

  • Cloud-native DevOps roles almost always expect basic Kubernetes knowledge.


πŸ’‘ If you’re also preparing for DevOps interviews, let’s connect!
I’ll share more daily learnings + projects in this #30DaysOfDevOps journey.

#DevOps #Kubernetes #AWS #EKS #Cloud #SRE #InterviewPreparation

0
Subscribe to my newsletter

Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tathagat Gaikwad
Tathagat Gaikwad