Back Deployment With Kubernets in AWS 27 Mar, 2026

Git Hub Link for details: 

https://github.com/sunnysavita10/ecomm-prod-assistant

Check out this 5 files:

1. ecomm-prod-assistant/.github/workflows /infra.yml

2. ecomm-prod-assistant/.github/workflows /deploy.yml

3. k8/deployment.yaml

4. k8/service.yaml

5. ecomm-prod-assistant /infra/eks-with-ecr.yaml


How these 5 files are interconnected with each other 

Perfect question — this is exactly where most beginners get confused.
I’ll explain this in a simple story + flow + memory trick so you never forget it.


🧠 Think of It Like Building & Running a Restaurant

You have 5 files → they act like different roles in opening & running a restaurant


🧩 1. Who Does What (Simple Roles)

⚙️ 1. infra/eks-with-ecr.yaml

👉 "Blueprint of your infrastructure"

  • Defines:

    • EKS Cluster (Kubernetes)

    • ECR (Docker image storage)

  • Written in CloudFormation / IaC

📌 Think:
👉 "What resources should exist in AWS?"


🚀 2. .github/workflows/infra.yml

👉 "Builder of infrastructure"

  • Runs the above file

  • Creates:

    • EKS cluster

    • ECR repo

📌 Think:
👉 "Execute the blueprint"


🐳 3. .github/workflows/deploy.yml

👉 "Chef + Delivery system"

  • Builds Docker image

  • Pushes to ECR

  • Connects to EKS

  • Applies Kubernetes files

📌 Think:
👉 "Take my app and deploy it"


📦 4. k8/deployment.yaml

👉 "How your app runs"

  • Number of replicas

  • Container image

  • CPU/memory

  • Ports

📌 Think:
👉 "How should my app behave inside Kubernetes?"


🌐 5. k8/service.yaml

👉 "How users access your app"

  • Exposes app to internet

  • Creates LoadBalancer

📌 Think:
👉 "How will users reach my app?"


🔥 FULL FLOW (Step-by-Step)

🟢 STEP 1: Infrastructure Creation

👉 You manually trigger:

infra.yml

What happens:

  1. GitHub Action runs

  2. It reads:

    infra/eks-with-ecr.yaml
    
  3. AWS creates:

    • EKS Cluster

    • ECR Repository

✅ Now your platform is ready


🟡 STEP 2: Deployment Trigger

👉 You push code to GitHub

git push origin main

This triggers:

deploy.yml

🔵 STEP 3: Build & Push Image

Inside deploy.yml:

docker build → docker push (ECR)

📌 Result:
👉 Your app image is now inside ECR


🟣 STEP 4: Connect to Kubernetes (EKS)

aws eks update-kubeconfig

📌 Now GitHub Actions can talk to your cluster


🟠 STEP 5: Apply Kubernetes Files

kubectl apply -f k8/deployment.yaml
kubectl apply -f k8/service.yaml

What happens internally:

🧩 deployment.yaml

  • Pulls image from ECR

  • Creates Pods (your app running)

🌐 service.yaml

  • Creates LoadBalancer

  • Gives public URL


🎯 FINAL RESULT

User → LoadBalancer → Service → Pods → Container (Your App)

🎉 Your app is LIVE


🔁 How They Are Connected (One Line Each)

FileConnected ToPurpose
infra.ymleks-with-ecr.yamlCreates infra
deploy.ymlECR + EKS + k8 filesDeploys app
deployment.yamlECR imageRuns app
service.yamldeploymentExposes app
eks-with-ecr.yamlAWSDefines infra

🧠 MEMORY TRICK (VERY IMPORTANT)

Use this:

👉 "CREATE → BUILD → DEPLOY → EXPOSE"

1. CREATE

👉 infra.yml + eks-with-ecr.yaml
➡️ Creates AWS infra


2. BUILD

👉 deploy.yml
➡️ Builds Docker image


3. DEPLOY

👉 deployment.yaml
➡️ Runs app in Kubernetes


4. EXPOSE

👉 service.yaml
➡️ Makes app public


🧠 Super Simple Analogy (1 Line)

👉
Infra builds the playground → Deploy puts your app → K8 runs it → Service shows it to world


⚠️ Important Understanding (Most People Miss This)

  • infra.yml runs rarely (once)

  • deploy.yml runs every code change

  • k8 files are instructions for Kubernetes

  • ECR is bridge between build & deploy