Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav — full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with ❤️ & By - Anubhav

© 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 05 · Production & GitOpsChapter 33 of 33
32.
Phase 05Read time ~21 minDifficulty intermediate

Final Production-Style Kubernetes Project

Warrior, this is the final chapter of your Kubernetes course.

In this chapter
  • 01🎯 What We Are Building
  • 02KubeTask — AI-Powered Task Management Platform
  • 03🏗️ Complete Technology Stack
  • 04📁 Project Structure
  • 05🐳 Step 1 — Dockerize the Applications
  • 06Backend Dockerfile
  • 07Next.js Dockerfile
  • 08🏷️ Image Versioning
  • 09Namespace
  • 10ConfigMap
  • 11Secret
  • 12PostgreSQL
  • 13PostgreSQL Deployment
  • 14PostgreSQL PVC
  • 15PostgreSQL Service
  • 16Redis
  • 17Node.js Backend Deployment
  • 18Backend Service
  • 19HPA
  • 20Next.js Frontend Deployment
  • 21Ingress
  • 22🔐 RBAC
  • 23🛡️ NetworkPolicy
  • 24Database Migration Job
  • 25CronJob
  • 26📊 Monitoring
  • 27📈 Grafana Dashboard
  • 28📝 Centralized Logging
  • 29🚀 CI/CD Pipeline
  • 30GitHub Actions
  • 31GitOps With Argo CD
  • 32🔄 Complete Production Deployment Flow
  • 33🔥 Production Traffic Flow
  • 34⚡ What Happens During Traffic Spike?
  • 35💥 What Happens When a Pod Crashes?
  • 36💥 What Happens When a Node Dies?
  • 37🔐 Production Security Architecture
  • 38☁️ AWS EKS Production Architecture
  • 39🧠 Your Complete Kubernetes Mental Model
  • 40🧩 Kubernetes Concepts — Final Map
  • 41🧪 Final Hands-On Project Roadmap
  • 42Phase 1 — Local
  • 43Phase 2
  • 44Phase 3
  • 45Phase 4
  • 46Phase 5
  • 47Phase 6
  • 48Phase 7
  • 49Phase 8
  • 50Phase 9
  • 51Phase 10
  • 52Phase 11
  • 53Phase 12
  • 54Phase 13
  • 55Phase 14
  • 56🏆 Production Checklist
  • 57Application
  • 58Kubernetes
  • 59Storage
  • 60CI/CD
  • 61GitOps
  • 62Observability
  • 63🎯 Final Kubernetes Interview Questions
  • 64Beginner
  • 65Intermediate
  • 66Advanced
  • 67Production
In this chapter (67 sections)
01🎯 What We Are Building02KubeTask — AI-Powered Task Management Platform03🏗️ Complete Technology Stack04📁 Project Structure05🐳 Step 1 — Dockerize the Applications06Backend Dockerfile07Next.js Dockerfile08🏷️ Image Versioning09Namespace10ConfigMap11Secret12PostgreSQL13PostgreSQL Deployment14PostgreSQL PVC15PostgreSQL Service16Redis17Node.js Backend Deployment18Backend Service19HPA20Next.js Frontend Deployment21Ingress22🔐 RBAC23🛡️ NetworkPolicy24Database Migration Job25CronJob26📊 Monitoring27📈 Grafana Dashboard28📝 Centralized Logging29🚀 CI/CD Pipeline30GitHub Actions31GitOps With Argo CD32🔄 Complete Production Deployment Flow33🔥 Production Traffic Flow34⚡ What Happens During Traffic Spike?35💥 What Happens When a Pod Crashes?36💥 What Happens When a Node Dies?37🔐 Production Security Architecture38☁️ AWS EKS Production Architecture39🧠 Your Complete Kubernetes Mental Model40🧩 Kubernetes Concepts — Final Map41🧪 Final Hands-On Project Roadmap42Phase 1 — Local43Phase 244Phase 345Phase 446Phase 547Phase 648Phase 749Phase 850Phase 951Phase 1052Phase 1153Phase 1254Phase 1355Phase 1456🏆 Production Checklist57Application58Kubernetes59Storage60CI/CD61GitOps62Observability63🎯 Final Kubernetes Interview Questions64Beginner65Intermediate66Advanced67Production

We’ll now combine almost everything you learned into one realistic production architecture:

Next.js → Node.js API → PostgreSQL + Redis → Kubernetes → Ingress → HPA → Monitoring → Logging → CI/CD → Argo CD


1. 🎯 What We Are Building#

Let's build a production-style application called:

KubeTask — AI-Powered Task Management Platform#

Architecture:

                         INTERNET
                            │
                            ▼
                    ┌───────────────┐
                    │   DNS / HTTPS │
                    └───────┬───────┘
                            │
                            ▼
                    ┌───────────────┐
                    │    Ingress    │
                    └───────┬───────┘
                            │
              ┌─────────────┴─────────────┐
              │                           │
              ▼                           ▼
       ┌─────────────┐             ┌─────────────┐
       │   Next.js   │             │  Node.js    │
       │  Frontend   │             │     API     │
       └─────────────┘             └──────┬──────┘
                                         │
                         ┌───────────────┼───────────────┐
                         │               │               │
                         ▼               ▼               ▼
                   PostgreSQL         Redis        AI Worker
                   Database           Cache         / RAG
                         │               │
                         ▼               ▼
                      Persistent       Cache
                      Storage          Data

And around the application:

             ┌──────────────────────────────┐
             │         Kubernetes            │
             │                              │
             │  ┌────────────────────────┐  │
             │  │ Deployments            │  │
             │  │ Services               │  │
             │  │ Ingress                │  │
             │  │ HPA                    │  │
             │  │ ConfigMaps             │  │
             │  │ Secrets                │  │
             │  │ RBAC                   │  │
             │  │ NetworkPolicies        │  │
             │  │ Jobs / CronJobs        │  │
             │  └────────────────────────┘  │
             │                              │
             └──────────────────────────────┘

2. 🏗️ Complete Technology Stack#

We'll use:

Layer Technology
Frontend Next.js
Backend Node.js + Express
Database PostgreSQL
Cache Redis
AI Worker Python/Node.js
Container Docker
Orchestration Kubernetes
Package Manager Helm
Configuration Kustomize
Ingress NGINX / cloud ingress
Monitoring Prometheus
Dashboards Grafana
Logging Fluent Bit + Loki/ELK
CI GitHub Actions
Registry ECR
GitOps Argo CD
Cloud AWS EKS

3. 📁 Project Structure#

A realistic repository could look like:

kube-task/
│
├── frontend/
│   ├── app/
│   ├── package.json
│   ├── Dockerfile
│   └── ...
│
├── backend/
│   ├── src/
│   ├── package.json
│   ├── Dockerfile
│   └── ...
│
├── worker/
│   ├── src/
│   ├── requirements.txt
│   └── Dockerfile
│
├── k8s/
│   ├── namespace.yaml
│   │
│   ├── frontend/
│   │   ├── deployment.yaml
│   │   └── service.yaml
│   │
│   ├── backend/
│   │   ├── deployment.yaml
│   │   ├── service.yaml
│   │   ├── hpa.yaml
│   │   └── serviceaccount.yaml
│   │
│   ├── postgres/
│   │   ├── deployment.yaml
│   │   ├── service.yaml
│   │   └── pvc.yaml
│   │
│   ├── redis/
│   │   ├── deployment.yaml
│   │   └── service.yaml
│   │
│   ├── ingress.yaml
│   ├── configmap.yaml
│   ├── secret.yaml
│   ├── network-policy.yaml
│   └── migration-job.yaml
│
├── helm/
│   └── kube-task/
│
├── .github/
│   └── workflows/
│       └── deploy.yml
│
└── README.md

4. 🐳 Step 1 — Dockerize the Applications#

Backend Dockerfile#

FROM node:22-alpine
 
WORKDIR /app
 
COPY package*.json ./
 
RUN npm ci --omit=dev
 
COPY . .
 
EXPOSE 3000
 
CMD ["node", "src/server.js"]

Build:

docker build -t kube-task-api:1.0 .

Run:

docker run -p 3000:3000 kube-task-api:1.0

5. Next.js Dockerfile#

For production, Next.js can use standalone output.

next.config.js:

module.exports = {
  output: "standalone"
};

Dockerfile:

FROM node:22-alpine AS builder
 
WORKDIR /app
 
COPY package*.json ./
 
RUN npm ci
 
COPY . .
 
RUN npm run build
 
FROM node:22-alpine AS runner
 
WORKDIR /app
 
ENV NODE_ENV=production
 
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
 
EXPOSE 3000
 
CMD ["node", "server.js"]

This gives us a smaller production runtime than shipping the entire development environment.


6. 🏷️ Image Versioning#

Never depend on:

latest

Prefer:

kube-task-api:1.0.0

or:

kube-task-api:8f31c2a

where:

8f31c2a

is the Git commit SHA.

Even better in production:

kube-task-api@sha256:...

because the digest identifies an immutable image.


7. Namespace#

Create:

apiVersion: v1
kind: Namespace
 
metadata:
  name: kube-task

Apply:

kubectl apply -f namespace.yaml

Check:

kubectl get namespaces

8. ConfigMap#

Our non-sensitive configuration:

apiVersion: v1
kind: ConfigMap
 
metadata:
  name: kube-task-config
  namespace: kube-task
 
data:
  NODE_ENV: "production"
  PORT: "3000"
  REDIS_HOST: "redis"
  REDIS_PORT: "6379"
  POSTGRES_HOST: "postgres"
  POSTGRES_PORT: "5432"

Remember:

ConfigMap
    ↓
Non-sensitive configuration

9. Secret#

Sensitive values:

apiVersion: v1
kind: Secret
 
metadata:
  name: kube-task-secret
  namespace: kube-task
 
type: Opaque
 
stringData:
  POSTGRES_USER: "appuser"
  POSTGRES_PASSWORD: "strong-password"
  POSTGRES_DB: "kube_task"
  JWT_SECRET: "super-secret-value"

⚠️ Don't commit real production secrets like this to Git.

In a real EKS environment, you'd typically use something such as:

AWS Secrets Manager
        ↓
External Secrets / secret integration
        ↓
Kubernetes Secret
        ↓
Pod

10. PostgreSQL#

For learning, we can run PostgreSQL inside Kubernetes.

PostgreSQL Deployment#

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: postgres
  namespace: kube-task
 
spec:
  replicas: 1
 
  selector:
    matchLabels:
      app: postgres
 
  template:
    metadata:
      labels:
        app: postgres
 
    spec:
      containers:
        - name: postgres
 
          image: postgres:16
 
          ports:
            - containerPort: 5432
 
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: kube-task-secret
                  key: POSTGRES_USER
 
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: kube-task-secret
                  key: POSTGRES_PASSWORD
 
            - name: POSTGRES_DB
              valueFrom:
                secretKeyRef:
                  name: kube-task-secret
                  key: POSTGRES_DB
 
          volumeMounts:
            - name: postgres-storage
              mountPath: /var/lib/postgresql/data
 
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: postgres-pvc

11. PostgreSQL PVC#

apiVersion: v1
kind: PersistentVolumeClaim
 
metadata:
  name: postgres-pvc
  namespace: kube-task
 
spec:
  accessModes:
    - ReadWriteOnce
 
  resources:
    requests:
      storage: 20Gi

Architecture:

PostgreSQL Pod
      │
      ▼
   PVC 20Gi
      │
      ▼
Persistent Volume
      │
      ▼
Cloud Disk

12. PostgreSQL Service#

apiVersion: v1
kind: Service
 
metadata:
  name: postgres
  namespace: kube-task
 
spec:
  selector:
    app: postgres
 
  ports:
    - port: 5432
      targetPort: 5432

Now backend can connect using:

postgres:5432

Not:

localhost:5432

This is an extremely important Kubernetes concept.

Inside backend:

localhost

means:

the backend container/Pod's own network namespace.

Whereas:

postgres

means:

PostgreSQL Kubernetes Service.


13. Redis#

Redis can be exposed internally:

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: redis
  namespace: kube-task
 
spec:
  replicas: 1
 
  selector:
    matchLabels:
      app: redis
 
  template:
    metadata:
      labels:
        app: redis
 
    spec:
      containers:
        - name: redis
          image: redis:7-alpine
          ports:
            - containerPort: 6379

Service:

apiVersion: v1
kind: Service
 
metadata:
  name: redis
  namespace: kube-task
 
spec:
  selector:
    app: redis
 
  ports:
    - port: 6379
      targetPort: 6379

Backend:

REDIS_HOST=redis
REDIS_PORT=6379

14. Node.js Backend Deployment#

Now the important part.

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: backend
  namespace: kube-task
 
spec:
  replicas: 3
 
  strategy:
    type: RollingUpdate
 
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
 
  selector:
    matchLabels:
      app: backend
 
  template:
 
    metadata:
      labels:
        app: backend
 
    spec:
 
      serviceAccountName: backend-sa
 
      containers:
 
        - name: backend
 
          image: 123456789.dkr.ecr.ap-south-1.amazonaws.com/kube-task-api:1.0.0
 
          ports:
            - containerPort: 3000
 
          envFrom:
            - configMapRef:
                name: kube-task-config
 
            - secretRef:
                name: kube-task-secret
 
          resources:
 
            requests:
              cpu: "250m"
              memory: "256Mi"
 
            limits:
              cpu: "500m"
              memory: "512Mi"
 
          startupProbe:
            httpGet:
              path: /health
              port: 3000
 
            failureThreshold: 30
            periodSeconds: 5
 
          readinessProbe:
            httpGet:
              path: /ready
              port: 3000
 
            periodSeconds: 10
 
          livenessProbe:
            httpGet:
              path: /health
              port: 3000
 
            periodSeconds: 10

Look at how many concepts are now coming together:

Deployment
   +
ServiceAccount
   +
ConfigMap
   +
Secret
   +
Resources
   +
Startup Probe
   +
Readiness Probe
   +
Liveness Probe
   +
Rolling Update

This is why Kubernetes becomes powerful when you combine the individual concepts.


15. Backend Service#

apiVersion: v1
kind: Service
 
metadata:
  name: backend
  namespace: kube-task
 
spec:
  selector:
    app: backend
 
  ports:
    - port: 80
      targetPort: 3000
 
  type: ClusterIP

Therefore:

Backend Service :80
       ↓
Backend Pod :3000

Frontend can call:

http://backend

16. HPA#

Now suppose traffic increases.

We want:

3 Pods
   ↓
4 Pods
   ↓
5 Pods
   ↓
...
   ↓
10 Pods

HPA:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
 
metadata:
  name: backend-hpa
  namespace: kube-task
 
spec:
 
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: backend
 
  minReplicas: 3
  maxReplicas: 10
 
  metrics:
 
    - type: Resource
 
      resource:
        name: cpu
 
        target:
          type: Utilization
          averageUtilization: 70

Architecture:

Traffic
   │
   ▼
Backend Pods
   │
   ▼
CPU increases
   │
   ▼
HPA
   │
   ▼
More Pods

17. Next.js Frontend Deployment#

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: frontend
  namespace: kube-task
 
spec:
  replicas: 3
 
  selector:
    matchLabels:
      app: frontend
 
  template:
 
    metadata:
      labels:
        app: frontend
 
    spec:
 
      containers:
 
        - name: frontend
 
          image: 123456789.dkr.ecr.ap-south-1.amazonaws.com/kube-task-frontend:1.0.0
 
          ports:
            - containerPort: 3000
 
          resources:
 
            requests:
              cpu: "200m"
              memory: "256Mi"
 
            limits:
              cpu: "500m"
              memory: "512Mi"
 
          readinessProbe:
            httpGet:
              path: /
              port: 3000
 
            periodSeconds: 10

Service:

apiVersion: v1
kind: Service
 
metadata:
  name: frontend
  namespace: kube-task
 
spec:
  selector:
    app: frontend
 
  ports:
    - port: 80
      targetPort: 3000

18. Ingress#

Now expose our application.

Imagine:

app.kubetask.com
api.kubetask.com

Ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
 
metadata:
  name: kube-task-ingress
  namespace: kube-task
 
spec:
 
  ingressClassName: nginx
 
  rules:
 
    - host: app.kubetask.com
 
      http:
 
        paths:
 
          - path: /
            pathType: Prefix
 
            backend:
              service:
                name: frontend
                port:
                  number: 80
 
    - host: api.kubetask.com
 
      http:
 
        paths:
 
          - path: /
            pathType: Prefix
 
            backend:
              service:
                name: backend
                port:
                  number: 80

Traffic:

app.kubetask.com
        │
        ▼
     Ingress
        │
        ▼
    frontend
        │
        ▼
    Next.js Pods

And:

api.kubetask.com
        │
        ▼
     Ingress
        │
        ▼
     backend
        │
        ▼
    Node.js Pods

19. 🔐 RBAC#

Create a ServiceAccount:

apiVersion: v1
kind: ServiceAccount
 
metadata:
  name: backend-sa
  namespace: kube-task

Suppose backend needs to read ConfigMaps.

Role:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
 
metadata:
  name: backend-config-reader
  namespace: kube-task
 
rules:
 
  - apiGroups: [""]
    resources:
      - configmaps
 
    verbs:
      - get
      - list
      - watch

RoleBinding:

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
 
metadata:
  name: backend-config-reader-binding
  namespace: kube-task
 
subjects:
 
  - kind: ServiceAccount
    name: backend-sa
    namespace: kube-task
 
roleRef:
 
  kind: Role
  name: backend-config-reader
  apiGroup: rbac.authorization.k8s.io

Remember:

ServiceAccount
      ↓
RoleBinding
      ↓
Role
      ↓
Permissions

20. 🛡️ NetworkPolicy#

Let's create a security architecture:

Internet
   │
   ▼
Frontend
   │
   ▼
Backend
   │
 ┌─┴─────────┐
 ▼           ▼
Redis      PostgreSQL

We don't want:

Frontend → PostgreSQL
Frontend → Redis
Random Pod → PostgreSQL

Example PostgreSQL policy:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
 
metadata:
  name: postgres-policy
  namespace: kube-task
 
spec:
 
  podSelector:
    matchLabels:
      app: postgres
 
  policyTypes:
    - Ingress
 
  ingress:
 
    - from:
 
        - podSelector:
            matchLabels:
              app: backend
 
      ports:
 
        - protocol: TCP
          port: 5432

Now:

Backend ───────────► PostgreSQL ✅
 
Frontend ──────────► PostgreSQL ❌
Random Pod ────────► PostgreSQL ❌

21. Database Migration Job#

Before deploying a new version:

Application
     │
     ▼
Database migration
     │
     ▼
New application

Kubernetes Job:

apiVersion: batch/v1
kind: Job
 
metadata:
  name: db-migration
  namespace: kube-task
 
spec:
 
  backoffLimit: 3
 
  template:
 
    spec:
 
      restartPolicy: Never
 
      containers:
 
        - name: migration
 
          image: 123456789.dkr.ecr.ap-south-1.amazonaws.com/kube-task-api:1.0.0
 
          command:
            - npm
            - run
            - migrate
 
          envFrom:
 
            - configMapRef:
                name: kube-task-config
 
            - secretRef:
                name: kube-task-secret

Run:

kubectl apply -f migration-job.yaml

Check:

kubectl get jobs

22. CronJob#

Suppose we want daily cleanup:

Every day at 2 AM
        ↓
Cleanup expired sessions
        ↓
Job
apiVersion: batch/v1
kind: CronJob
 
metadata:
  name: cleanup
  namespace: kube-task
 
spec:
 
  schedule: "0 2 * * *"
 
  concurrencyPolicy: Forbid
 
  jobTemplate:
 
    spec:
 
      template:
 
        spec:
 
          restartPolicy: Never
 
          containers:
 
            - name: cleanup
 
              image: kube-task-api:1.0.0
 
              command:
                - npm
                - run
                - cleanup

23. 📊 Monitoring#

Now production needs visibility.

Architecture:

Applications
     │
     ▼
 /metrics
     │
     ▼
Prometheus
     │
     ▼
Grafana

Example metrics:

http_requests_total
http_request_duration_seconds
nodejs_heap_size_used_bytes
process_cpu_seconds_total

For Kubernetes:

Pod CPU
Pod Memory
Pod Restarts
Deployment replicas
Node capacity
HPA status

24. 📈 Grafana Dashboard#

A useful dashboard could show:

┌─────────────────────────────────────────────┐
│              KUBE-TASK PROD                 │
├──────────────┬──────────────┬───────────────┤
│ Requests/sec │ Error Rate   │ P95 Latency   │
│    1,240     │    0.3%      │    180 ms     │
├──────────────┼──────────────┼───────────────┤
│ Backend Pods │ CPU          │ Memory        │
│     6/10     │    63%       │     71%       │
├──────────────┴──────────────┴───────────────┤
│              Request Rate Graph             │
│        ╱╲       ╱╲                          │
│   ╱╲  ╱  ╲  ╱╲ ╱  ╲                         │
└─────────────────────────────────────────────┘

Golden Signals:

Latency
Traffic
Errors
Saturation

25. 📝 Centralized Logging#

Instead of:

kubectl logs

for every Pod manually:

Pod
 │
 ▼
stdout
 │
 ▼
Node
 │
 ▼
Fluent Bit
 │
 ▼
Loki / Elasticsearch
 │
 ▼
Grafana / Kibana

Now if a Pod disappears, its logs can still remain in centralized storage depending on retention.


26. 🚀 CI/CD Pipeline#

Now connect GitHub.

Developer
    │
    ▼
Git Push
    │
    ▼
GitHub
    │
    ▼
GitHub Actions
    │
 ┌──┼───────────────┐
 │  │               │
 ▼  ▼               ▼
Test Lint      Security Scan
 │
 ▼
Docker Build
 │
 ▼
ECR

Then GitOps:

Deployment Git
      │
      ▼
   Argo CD
      │
      ▼
 Kubernetes

27. GitHub Actions#

Simplified pipeline:

name: Build
 
on:
  push:
    branches:
      - main
 
jobs:
 
  build:
 
    runs-on: ubuntu-latest
 
    steps:
 
      - name: Checkout
        uses: actions/checkout@v4
 
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 22
 
      - name: Install
        run: npm ci
 
      - name: Test
        run: npm test
 
      - name: Build Docker image
        run: |
          docker build \
            -t kube-task-api:${{ github.sha }} \
            ./backend

Then:

docker push

to ECR.


28. GitOps With Argo CD#

Deployment repository:

kube-task-config/
│
├── base/
│   ├── deployment.yaml
│   ├── service.yaml
│   └── kustomization.yaml
│
└── overlays/
    ├── dev/
    ├── staging/
    └── production/

Production overlay:

images:
 
  - name: kube-task-api
 
    newName: 123456789.dkr.ecr.ap-south-1.amazonaws.com/kube-task-api
 
    newTag: "8f31c2a"

Developer changes Git:

image: 8f31c2a

Argo sees:

Git desired state
       ≠
Cluster state

Then:

Argo CD
   ↓
Sync
   ↓
Kubernetes

29. 🔄 Complete Production Deployment Flow#

This is one of the most important diagrams in your entire Kubernetes course.

                  DEVELOPER
                      │
                      ▼
                   Git Push
                      │
                      ▼
              ┌───────────────┐
              │ GitHub Actions│
              └───────┬───────┘
                      │
            ┌─────────┼──────────┐
            ▼         ▼          ▼
          Test      Lint       Security
            │
            ▼
        Docker Build
            │
            ▼
        Container Image
            │
            ▼
           ECR
            │
            │
            ▼
     Deployment Git Repo
            │
            ▼
         Argo CD
            │
            ▼
       Kubernetes API
            │
            ▼
        Deployment
            │
            ▼
       ReplicaSet
            │
            ▼
           Pods
            │
       ┌────┴────┐
       ▼         ▼
   Readiness   Liveness
       │
       ▼
    Service
       │
       ▼
    Ingress
       │
       ▼
      User

30. 🔥 Production Traffic Flow#

When a user opens:

https://app.kubetask.com

the flow becomes:

Browser
   │
   ▼
DNS
   │
   ▼
AWS Load Balancer
   │
   ▼
Ingress Controller
   │
   ▼
Frontend Service
   │
   ▼
Next.js Pod
   │
   ▼
Backend Service
   │
   ▼
Node.js Pod
   │
   ├───────────────┐
   ▼               ▼
PostgreSQL       Redis

31. ⚡ What Happens During Traffic Spike?#

Suppose:

100 requests/sec

becomes:

10,000 requests/sec

Then:

Traffic ↑
   │
   ▼
CPU ↑
   │
   ▼
HPA
   │
   ▼
Pods 3 → 10
   │
   ▼
Scheduler

If there isn't enough node capacity:

Pods
 │
 ▼
Pending
 │
 ▼
Cluster Autoscaler
 │
 ▼
New Node
 │
 ▼
Scheduler
 │
 ▼
Pod Running

This is the complete relationship:

HPA
 │
 │ scales
 ▼
Pods
 │
 │ may require
 ▼
Cluster Autoscaler
 │
 │ scales
 ▼
Nodes

32. 💥 What Happens When a Pod Crashes?#

Suppose:

Backend Pod #2
       ↓
     Crash

Deployment/ReplicaSet notices:

Desired = 3
Current = 2

Therefore:

ReplicaSet
    ↓
Create replacement Pod

Then:

Startup Probe
      ↓
Readiness Probe
      ↓
Service adds Pod
      ↓
Traffic

That's Kubernetes reconciliation in action.


33. 💥 What Happens When a Node Dies?#

Suppose:

Node 2 💀

Pods disappear.

Kubernetes sees:

Desired Pods = 6
Available = 4

Scheduler can place replacement Pods on healthy nodes.

If the cluster needs additional capacity:

Pending Pods
     ↓
Cluster Autoscaler
     ↓
New Node
     ↓
Pods scheduled

34. 🔐 Production Security Architecture#

A stronger architecture:

                    Internet
                       │
                       ▼
                     WAF
                       │
                       ▼
                Load Balancer
                       │
                       ▼
                    Ingress
                       │
                       ▼
                  Frontend
                       │
                       ▼
                   Backend
                 /         \
                /           \
               ▼             ▼
           PostgreSQL       Redis

Security layers:

WAF
 │
 ▼
TLS
 │
 ▼
Ingress
 │
 ▼
NetworkPolicy
 │
 ▼
ServiceAccount
 │
 ▼
RBAC
 │
 ▼
Secrets
 │
 ▼
Container Security

And:

AWS IAM
     +
Kubernetes RBAC
     +
NetworkPolicy
     +
Security Groups

are different security layers.


35. ☁️ AWS EKS Production Architecture#

Now let's move from local Kubernetes to cloud.

                    Route 53
                       │
                       ▼
                 AWS Load Balancer
                       │
                       ▼
                    Ingress
                       │
          ┌────────────┴────────────┐
          ▼                         ▼
      Next.js                    Node.js
       Pods                       Pods
                                    │
                         ┌──────────┴──────────┐
                         ▼                     ▼
                       RDS                 ElastiCache
                    PostgreSQL                Redis

Around it:

                 ┌─────────────────┐
                 │       EKS       │
                 │                 │
                 │  Node Group     │
                 │  Node Group     │
                 │  Node Group     │
                 └─────────────────┘

For production, you would commonly consider managed services for critical stateful components rather than putting your primary PostgreSQL database directly in a Deployment.

For example:

EKS
 │
 ├── Next.js
 ├── Node.js
 ├── Workers
 │
 ├── RDS PostgreSQL
 └── ElastiCache Redis

36. 🧠 Your Complete Kubernetes Mental Model#

At this point, you should be able to visualize Kubernetes like this:

                     ┌───────────────┐
                     │   INGRESS     │
                     └───────┬───────┘
                             │
                             ▼
                     ┌───────────────┐
                     │   SERVICE     │
                     └───────┬───────┘
                             │
                ┌────────────┼────────────┐
                ▼            ▼            ▼
              Pod          Pod          Pod
                │            │            │
                └────────────┼────────────┘
                             │
                       Deployment
                             │
                         ReplicaSet

Configuration:

ConfigMap
   +
Secret
   ↓
Pod

Storage:

Pod
 ↓
PVC
 ↓
PV
 ↓
Storage

Scaling:

HPA
 ↓
Pods
 
Cluster Autoscaler
 ↓
Nodes

Security:

ServiceAccount
 ↓
RBAC
 
NetworkPolicy
 ↓
Network traffic

Observability:

Logs → Loki/ELK
Metrics → Prometheus
Dashboard → Grafana

Deployment:

Git
 ↓
CI/CD
 ↓
Container Registry
 ↓
Argo CD
 ↓
Kubernetes

37. 🧩 Kubernetes Concepts — Final Map#

Concept Purpose
Cluster Complete Kubernetes environment
Node Machine running workloads
Pod Smallest deployable unit
Container Application runtime
Deployment Manages stateless Pods
ReplicaSet Maintains replica count
Service Stable networking
Ingress HTTP/HTTPS routing
ConfigMap Non-sensitive configuration
Secret Sensitive configuration
Volume Storage abstraction
PVC Request for storage
StatefulSet Stateful workloads
Job One-time task
CronJob Scheduled task
HPA Scales Pods
Cluster Autoscaler Scales Nodes
RBAC Kubernetes API permissions
ServiceAccount Workload identity
NetworkPolicy Pod network restrictions
Helm Package/release management
Kustomize YAML customization
Prometheus Metrics
Grafana Visualization
Fluent Bit Log collection
Argo CD GitOps deployment

38. 🧪 Final Hands-On Project Roadmap#

Don't try to build the entire production system on day one.

Build it in stages.

Phase 1 — Local#

Next.js
   +
Node.js

Run in Kubernetes.


Phase 2#

Add:

Service
Ingress

Phase 3#

Add:

PostgreSQL
Redis

Phase 4#

Add:

ConfigMap
Secret
PVC

Phase 5#

Add:

Readiness
Liveness
Startup

Phase 6#

Add:

Resources
HPA

Phase 7#

Add:

RBAC
ServiceAccount
NetworkPolicy

Phase 8#

Add:

Jobs
CronJobs

Phase 9#

Package:

Helm

Phase 10#

Configure:

Kustomize

Phase 11#

CI/CD:

GitHub Actions
     ↓
Docker
     ↓
ECR

Phase 12#

GitOps:

Argo CD

Phase 13#

Observability:

Prometheus
Grafana
Loki/ELK

Phase 14#

Cloud:

AWS EKS

39. 🏆 Production Checklist#

Before calling an application production-ready:

Application#

  • Dockerized
  • Non-root container
  • Graceful shutdown
  • Health endpoints
  • Structured logging
  • Request IDs

Kubernetes#

  • Deployment
  • Service
  • Ingress
  • ConfigMap
  • Secrets
  • Resource requests
  • Resource limits
  • Readiness probe
  • Liveness probe
  • Startup probe
  • HPA
  • PDB
  • RBAC
  • ServiceAccount
  • NetworkPolicy

Storage#

  • PVC where required
  • Backup strategy
  • Disaster recovery
  • Object storage for uploads where appropriate

CI/CD#

  • Automated tests
  • Lint
  • Security scanning
  • Docker image scanning
  • Immutable image version
  • Deployment verification
  • Rollback strategy

GitOps#

  • Git source of truth
  • Argo CD
  • Drift detection
  • Reviewable deployment changes

Observability#

  • Metrics
  • Logs
  • Dashboards
  • Alerts
  • Golden signals
  • Error tracking

40. 🎯 Final Kubernetes Interview Questions#

You should now be able to answer these.

Beginner#

1. What is Kubernetes?

Container orchestration platform that automates deployment, scaling, networking and management of containerized workloads.

2. What is a Pod?

Smallest deployable Kubernetes unit containing one or more containers.

3. Deployment vs Pod?

Deployment manages Pods and provides rollout/replica management.

4. Why Service?

Pods are ephemeral; Service provides stable networking and service discovery.


Intermediate#

5. HPA vs Cluster Autoscaler?

HPA → Pods
CA  → Nodes

6. ConfigMap vs Secret?

ConfigMap → normal configuration
Secret    → sensitive configuration

7. Readiness vs Liveness?

Readiness → receive traffic?
Liveness  → should restart?

8. Deployment vs StatefulSet?

Deployment → stateless
StatefulSet → stateful workloads

Advanced#

9. How does Kubernetes self-heal?

Controllers continuously compare desired state with actual state and take corrective actions.

10. How does HPA work?

It observes metrics and adjusts the replica count of a scalable workload.

11. How does Cluster Autoscaler work?

It adjusts node capacity based largely on unschedulable Pods and whether nodes can be safely removed.

12. What is GitOps?

Git stores desired deployment state and a controller such as Argo CD reconciles the cluster toward that state.


Production#

13. How would you deploy a Node.js application to EKS?

A strong answer:

Git
 ↓
GitHub Actions
 ↓
Tests
 ↓
Docker build
 ↓
ECR
 ↓
Deployment configuration
 ↓
Argo CD
 ↓
EKS
 ↓
Deployment
 ↓
Pods
 ↓
Service
 ↓
Ingress
 ↓
Users

14. How would you troubleshoot a production Pod?

kubectl get pod
       ↓
kubectl describe pod
       ↓
kubectl logs
       ↓
kubectl logs --previous
       ↓
Events
       ↓
Service
       ↓
EndpointSlices
       ↓
Network/DNS
       ↓
Node/resources

15. How would you secure Kubernetes?

RBAC
+
ServiceAccounts
+
Secrets management
+
NetworkPolicies
+
Pod security
+
Non-root containers
+
Least privilege
+
Cloud IAM/workload identity

🧠 The One Diagram You Should Remember#

Warrior, if you remember only one diagram from the entire course, remember this:

                           USERS
                             │
                             ▼
                           DNS
                             │
                             ▼
                     Load Balancer
                             │
                             ▼
                         INGRESS
                             │
                    ┌────────┴────────┐
                    ▼                 ▼
                FRONTEND            BACKEND
                SERVICE             SERVICE
                    │                 │
                 ┌──┴──┐          ┌──┴──┐
                 ▼     ▼          ▼     ▼
                Pod   Pod        Pod   Pod
                                  │
                           ┌──────┴──────┐
                           ▼             ▼
                       PostgreSQL      Redis
                           │
                           ▼
                          PVC
 
          ┌─────────────────────────────────┐
          │          KUBERNETES             │
          │                                 │
          │ HPA → Pods                      │
          │ CA  → Nodes                     │
          │ RBAC → API permissions          │
          │ NetworkPolicy → Network access  │
          │ Probes → Health                 │
          │ Prometheus → Metrics            │
          │ Grafana → Dashboards            │
          │ Logs → Centralized logging      │
          └─────────────────────────────────┘
 
Git
 │
 ▼
GitHub Actions
 │
 ├── Test
 ├── Security
 └── Docker
       │
       ▼
      ECR
       │
       ▼
   Deployment Git
       │
       ▼
    Argo CD
       │
       ▼
  Kubernetes

🎓 Course Complete#

You have now covered the full path:

Kubernetes Basics
       ↓
Docker
       ↓
Architecture
       ↓
kubectl
       ↓
Pods
       ↓
Deployments
       ↓
Services
       ↓
Namespaces
       ↓
ConfigMaps / Secrets
       ↓
Storage
       ↓
Networking
       ↓
Ingress
       ↓
Resources
       ↓
Probes
       ↓
HPA
       ↓
Cluster Autoscaler
       ↓
Scheduling
       ↓
Jobs / CronJobs
       ↓
Security / RBAC
       ↓
Network Policies
       ↓
Logging
       ↓
Monitoring
       ↓
Troubleshooting
       ↓
Rollouts / Rollbacks
       ↓
Helm
       ↓
Kustomize
       ↓
Local Kubernetes
       ↓
EKS / GKE / AKS
       ↓
CI/CD
       ↓
GitOps / Argo CD
       ↓
🔥 Production Project

The next step should be implementation, not another theory chapter: take the KubeTask architecture above and build it locally from zero, command-by-command, starting with Docker → Next.js/Node.js → Kubernetes → PostgreSQL/Redis → Ingress → HPA → monitoring, and finally deploy the same architecture to EKS.

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 31 — GitOps + Argo CD 🔄Course CompletedReturn to Syllabus
Prev