https://drive.google.com/file/d/1egvAeNLA0xnF15gRdJm4SYII1XIr68m8/view?usp=sharing


🔍 Issue 1: Service Selector Mismatch (tshoot-deployment.yaml)

❌ The Problem

# Deployment labels
template:
  metadata:
    labels:
      app: nginx        # ← Pods have "app: nginx"

# Service selector
spec:
  selector:
    app: ngimx          # ← TYPO! Should be "nginx"

🚨 Result:

🔧 Diagnosis Steps (k3s)

# 1. Deploy the broken YAML
kubectl apply -f tshoot-deployment.yaml

# 2. Check Service Endpoints
kubectl get endpoints nginx-deployment-service
# NAME                        ENDPOINTS   AGE
# nginx-deployment-service    <none>      10s  ← NO PODS!

# 3. Verify Pod labels
kubectl get pods --show-labels
# Labels: app=nginx

# 4. Verify Service selector
kubectl get svc nginx-deployment-service -o yaml | grep -A 2 selector
# selector:
#   app: ngimx  ← TYPO!

# 5. Test connectivity (will hang/time out)
kubectl run debug --image=curlimages/curl -it --rm -- sh
# curl <http://nginx-deployment-service>  ← hangs

✅ Fix

# Correct the Service selector
spec:
  selector:
    app: nginx   # ← Fixed typo

💡 Pro Tip: Always use kubectl get endpoints <service> to verify Pod linkage.


🔍 Issue 2: Incomplete Service Definition (tshoot-deployment-svc.yaml)

❌ The Problem

apiVersion: apps/v1
kind: Deployment
meta
  name: nginx-deployment
  # ... (valid Deployment)
---
# ❌ NO SERVICE DEFINED IN YAML!
# Only a comment: "expose this deployment with a service..."

🚨 Result:

🔧 Diagnosis Steps (k3s)

# 1. Apply the YAML (only creates Deployment)
kubectl apply -f tshoot-deployment-svc.yaml

# 2. Check for Services
kubectl get svc
# No service named "my-nginx-web-svc"!

# 3. Try to access (fails)
kubectl run debug --image=curlimages/curl -it --rm -- sh
# curl <http://my-nginx-web-svc>  ← "Could not resolve host"

✅ Fix Options

Option A: Create Service via CLI (as comment suggests)