Skip to content
DockerKubernetes

3. Kubernetes Deployments Services Hindi – App Expose Karein

May 30, 2026 20 min read

नमस्ते दोस्तों!

स्वागत है The Easy Master पर!

तो आपने Minikube से local Kubernetes cluster बना लिया, kubectl चलाना सीख लिया। अब next step – अपने app को Kubernetes में deploy कैसे करें और दुनिया के सामने expose कैसे करें?

आपने simple kubectl create deployment और kubectl expose चलाया होगा। Lekin production mein aise commands nahi chalte. You need declarative YAML files – जहाँ आप बताते हो “मुझे 3 replicas चाहिए, हर pod ko 1 CPU limit चाहिए, service port 80 se external traffic mile”.

Maine jab pehli baar production-grade Deployment लिखी, to mujhe laga – “इतने सारे fields: replicas, selector, template, ports, targetPort… क्या-क्या है?” Par ek ek karke jab practice ki, tab sab clear ho gaya.

इस Kubernetes deployments services Hindi article mein main aapko practical examples ke saath sikhata hoon:

✅ Deployment kya hai? – Pods ka manager, desired state maintain karta hai
✅ Deployment YAML – apiVersion, kind, metadata, spec, template, selector, replicas
✅ Scale & Rolling Updates – kubectl scale aur kubectl rollout
✅ Service kya hai? – Pods ko stable endpoint provide karna
✅ Service types – ClusterIP (internal), NodePort (external dev), LoadBalancer (cloud), ExternalName
✅ Service YAML – selector, ports, targetPort, protocol
✅ Hands-On examples – Nginx Deployment + NodePort Service + LoadBalancer
✅ Real project – FastAPI app deploy and expose

Chaliye shuru karte hain production-grade Kubernetes manifest likhna! ☸️

Table of Contents

1. Deployment – Pods Ka Manager

Deployment Kubernetes ka ek workload resource hai jo Pods aur ReplicaSets ko manage karta hai.

Simple words mein:
Aap Deployment YAML mein likhte ho – “Mujhe nginx image ke 3 pods chahiye, har pod mein 1 CPU limit rahe, rolling update ke time max 1 pod down rahe”. Deployment fir ensure karta hai ki hamesha exactly 3 pods running रहें – chahe pod fail ho ya node down ho।

Deployment एक desired state (वांछित स्थिति) declare karta hai, aur controller उस desired state को achieve और maintain करता है। Pods को directly नहीं बनाते, हमेशा Deployment या StatefulSet use करते हैं।

Why Deployment, not bare Pods?

Bare PodDeployment
Pod delete हुआ तो recreate नहीं होगाAutomatically recreates failed pods
Scaling manualreplicas field se auto scaling
Rolling updates possible nahiRolling updates, rollbacks built-in
No self-healingSelf-healing by ReplicaSet

Deployments represent a set of multiple, identical Pods with no unique identities. A Deployment runs multiple replicas of your application and automatically replaces any instances that fail or become unresponsive.

Analogy: Deployment = restaurant manager. आप manager को बताते हो “5 waiters chahiye”. Agar ek waiter बीमार हो जाए, manager automatically नया waiter लगा देता है।

Deployments create ReplicaSets, which are the lower-level controllers actually maintaining the pod count. The Deployment then manages the ReplicaSet, enabling rolling updates and rollbacks.

2. Deployment YAML – Har Field Samjhein

Chaliye ek basic Nginx Deployment ka YAML dekhte hain aur har field ko samajhte hain:

Code
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.25
        ports:
        - containerPort: 80

Line by line explanation:

FieldMeaning
apiVersion: apps/v1Kubernetes API version for Deployments (stable)
kind: DeploymentType of Kubernetes resource
metadata.nameDeployment का नाम
metadata.labelsDeployment को identify करने के लिए labels
spec.replicasKitne identical pods chahiye
spec.selector.matchLabelsDeployment किन pods को manage karega – ये labels template के labels से match होने चाहिए
spec.templatePod template – har pod ki specification
spec.template.metadata.labelsPods ke labels (selector से match hone chahiye)
spec.template.spec.containersPod ke andar kon kon se containers चलेंगे
containers.nameContainer ka naam
containers.imageContainer image (Docker Hub से pull)
containers.ports.containerPortContainer किस port पर listen कर रहा है (just documentation)

Important: spec.selector MUST match the labels in spec.template.metadata.labels. Agar mismatch hua to Deployment error dega.

Optional but useful fields:

FieldPurpose
strategy.typeRollingUpdate (default) ya Recreate
rollingUpdate.maxSurgeRolling update के दौरान desired से कितने extra pods allowed
rollingUpdate.maxUnavailableRolling update के दौरान कितने pods unavailable ho sakte hain
containers.resources.requestsMinimum CPU/memory guarantee
containers.resources.limitsMaximum CPU/memory
containers.envEnvironment variables
containers.livenessProbeCheck if container is alive
containers.readinessProbeCheck if container is ready to serve traffic

3. Hands-On #1 – Pehla Deployment Create Karein (YAML se)

Minikube cluster chalu hai maan ke ( minikube start ), ab hum apna pehla Deployment YAML se banayenge.

Step 1: Create YAML File

nginx-deployment.yaml naam se file banayein:

Code
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deploy
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.25
        ports:
        - containerPort: 80

Step 2: Apply the Deployment

Code
kubectl apply -f nginx-deployment.yaml

Step 3: Verify Deployment Status

Code
kubectl get deployments
kubectl get pods

Output:

Code
NAME            READY   UP-TO-DATE   AVAILABLE   AGE
nginx-deploy    2/2     2            2           30s

NAME                             READY   STATUS    RESTARTS   AGE
nginx-deploy-7c9796fd6d-6q2z8    1/1     Running   0          30s
nginx-deploy-7c9796fd6d-8j3s9    1/1     Running   0          30s

Step 4: See Deployment Details

Code
kubectl describe deployment nginx-deploy

Isse saari information milegi – events, replicas, pods, etc.

Step 5: Delete the Deployment (Clean up)

Code
kubectl delete -f nginx-deployment.yaml

Ya:

Code
kubectl delete deployment nginx-deploy

💡 Pro Tip: YAML files को Git में रखो – Infrastructure as Code (IaC)। kubectl apply -f से declarative management होता है। Imperative commands (kubectl create deployment) sirf learning ke liye use karo।

4. Scale Karna aur Rolling Updates

4.1 Scaling Replicas

Method 1: kubectl scale command (imperative)

Code
kubectl scale deployment nginx-deploy --replicas=5

Verify:

Code
kubectl get pods
# 5 pods running now

Method 2: Edit YAML and re-apply (declarative)
YAML mein replicas: 5 karo aur kubectl apply -f nginx-deployment.yaml चलाओ।

4.2 Rolling Update

Change image version to nginx:1.26

Code
kubectl set image deployment/nginx-deploy nginx=nginx:1.26

Ya YAML edit karo: image: nginx:1.26 and kubectl apply -f nginx-deployment.yaml.

During rolling update:

  • Old pods gradually terminate, new pods start
  • Default strategy: maxSurge=25%, maxUnavailable=25% (for 2 replicas, 1 pod replaced at a time)
  • Zero downtime update!

Check rollout status:

Code
kubectl rollout status deployment nginx-deploy

4.3 Rollback to Previous Version

Code
kubectl rollout history deployment nginx-deploy
kubectl rollout undo deployment nginx-deploy

4.4 Pause and Resume Rollout

Code
kubectl rollout pause deployment nginx-deploy
# make multiple changes (image, env, etc.)
kubectl rollout resume deployment nginx-deploy

💡 Personal Experience: Once I used kubectl set image without checking the image tag. The new image had a bug, and the rollout got stuck. Using kubectl rollout undo saved me. Always test images first in staging, and use kubectl rollout status to monitor.

5. Service – Stable Endpoint Pods Ke Liye

Pod ephemeral होते हैं – unka IP address change हो सकता है, pod delete/restart हो सकता है। Service एक stable network endpoint provide karti hai जो pods ke set को represent kare।

Service kya karta hai:

  • Pods को एक stable IP address और DNS name देती है
  • Traffic को matching pods के बीच load balance करती है
  • Service discovery enable karti है (Kubernetes DNS)

A service is a method for exposing a network application that is running as one or more Pods in your cluster. It is an abstraction which defines a logical set of Pods and a policy by which to access them.

Kyun Service zaroori hai?

ProblemSolution
Pod IP changes on restartService provides stable ClusterIP
Multiple pods (replicas)Service load balances traffic
Access from outside clusterNodePort or LoadBalancer type
Service discoveryKubernetes DNS resolves service names

Service types:

TypeAccess scopeUse case
ClusterIPOnly inside clusterInternal microservice communication
NodePortCluster node IP + static portDevelopment, external access without cloud LB
LoadBalancerCloud provider LBProduction external access (AWS, GCP, Azure)
ExternalNameMaps to external DNSAccessing external services

A ClusterIP service is the default Kubernetes service. It gives you a service inside your cluster that other apps inside your cluster can access. A NodePort service is the most primitive way to get external traffic directly to your service. A LoadBalancer service is the standard way to expose a service to the internet in a cloud environment.

For Minikube, we can use NodePort or simulate LoadBalancer with minikube tunnel。

6. Service Types – ClusterIP, NodePort, LoadBalancer, ExternalName

6.1 ClusterIP (Default)

Only reachable from within the cluster. Best for internal services – database, backend API (accessed by other pods).

Code
apiVersion: v1
kind: Service
metadata:
  name: my-backend
spec:
  type: ClusterIP
  selector:
    app: my-app
  ports:
    - protocol: TCP
      port: 8080          # Service port
      targetPort: 80      # Pod container port

6.2 NodePort

Exposes the service on each node’s IP at a static port (30000-32767). Good for local development and testing.

Code
apiVersion: v1
kind: Service
metadata:
  name: my-web
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30001      # Optional, else random

Access: http://<node-ip>:30001

6.3 LoadBalancer

Provisions a cloud load balancer (AWS ELB, GCP LB, Azure LB). External IP assign होता है। Production standard.

Code
apiVersion: v1
kind: Service
metadata:
  name: my-app
spec:
  type: LoadBalancer
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 8080

For Minikube, run minikube tunnel to get an external IP for LoadBalancer services.

6.4 ExternalName

Maps service to external DNS name (no selectors).

Code
apiVersion: v1
kind: Service
metadata:
  name: external-db
spec:
  type: ExternalName
  externalName: database.example.com

Other pods can now reach external-db internally as if it were a cluster service.

Selecting the Right Type

ScenarioService Type
Database accessed only by backend podsClusterIP
Expose API for external users in cloudLoadBalancer
Local development on MinikubeNodePort
Access third-party API inside clusterExternalName
Internal monitoring dashboard (restricted)ClusterIP + Ingress (later)

7. Service YAML – Selector, Ports, TargetPort

Let’s break down a Service YAML:

Code
apiVersion: v1
kind: Service
metadata:
  name: my-service
  labels:
    app: my-app
spec:
  type: NodePort
  selector:
    app: my-app          # Must match pod labels
    tier: backend        # Additional label matching
  ports:
  - name: http
    protocol: TCP
    port: 80             # Port that service listens on
    targetPort: 8080     # Port on pod containers
    nodePort: 30080      # Only for NodePort (30000-32767)

Important fields explained:

FieldMeaning
selectorलेबल्स जो pods को filter करती हैं – service traffic वहीं pods को भेजेगी
ports.portService का port – cluster mein doosre services इस port से access karengi
ports.targetPortPod container ka actual port (usually matches containerPort in Deployment)
ports.nodePortNodePort type mein host node ka port (if omitted, auto-assign 30000-32767)
ports.protocolTCP or UDP (default TCP)
ports.nameOptional, but useful for multi-port services

Key point: Service selector must match the labels you defined in your Pod template (spec.template.metadata.labels). Otherwise, the service will have no endpoints and traffic will go nowhere.

Check endpoints of a service:

Code
kubectl get endpoints <service-name>

This shows which pod IPs are currently behind the service.

8. Hands-On #2 – NodePort Service se App Expose Karein

We have the nginx-deploy Deployment running with 2 replicas. Let’s expose it using a NodePort service.

Step 1: Create Service YAML

nginx-service.yaml:

Code
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30080    # optional; remove for random

Step 2: Apply Service

Code
kubectl apply -f nginx-service.yaml

Step 3: Check Service

Code
kubectl get services

Output:

Code
NAME            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
nginx-service   NodePort    10.100.150.5   <none>        80:30080/TCP   5s

Step 4: Access the App

Using Minikube:

Code
minikube service nginx-service

This automatically opens the Nginx welcome page in your browser.

Or manually:

Code
minikube ip
# output: 192.168.49.2
curl http://192.168.49.2:30080

You should see the Nginx welcome page.

Step 5: Scale to See Load Balancing

Code
kubectl scale deployment nginx-deploy --replicas=3

Now hit the service multiple times – traffic will be load-balanced across the 3 pods. Check logs per pod to see distribution.

Step 6: Clean Up

Code
kubectl delete -f nginx-service.yaml
kubectl delete -f nginx-deployment.yaml

9. Hands-On #3 – LoadBalancer Service (Minikube Tunnel)

In Minikube, LoadBalancer type works via minikube tunnel – it assigns an external IP accessible from your host.

Step 1: Create LoadBalancer Service YAML

nginx-lb-service.yaml:

Code
apiVersion: v1
kind: Service
metadata:
  name: nginx-lb
spec:
  type: LoadBalancer
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

Step 2: Apply Service

Code
kubectl apply -f nginx-lb-service.yaml

Step 3: Run Minikube Tunnel (in a separate terminal)

Code
minikube tunnel

Keep this terminal running. It will request sudo password on first run.

Step 4: Get External IP

Code
kubectl get services

After tunnel is running, the EXTERNAL-IP column will show an IP (e.g., 127.0.0.1 or a local IP). For Minikube, it might show 127.0.0.1.

Step 5: Access the App

Code
curl http://127.0.0.1

Or open browser at http://127.0.0.1. You’ll see the Nginx page.

Step 6: Clean Up

Code
kubectl delete service nginx-lb
# Stop tunnel with Ctrl+C in its terminal

💡 Note: Real cloud clusters (EKS, GKE, AKS) automatically provision cloud load balancers when you create a LoadBalancer service. Minikube tunnel simulates that for local testing.

10. Selector Labels – Service Pods Ko Kaise Find Karti Hai

The magic of service-to-pod connection is through labels and selectors.

How it works:

  1. You add labels to your Pods (via Deployment template)
  2. Service defines a selector with the same label key-value pairs
  3. Kubernetes control plane watches pods with matching labels and updates service endpoints automatically

Example:

Deployment pod template labels:

Code
template:
  metadata:
    labels:
      app: my-app
      tier: backend
      version: v2

Service selector:

Code
selector:
  app: my-app
  tier: backend

The service will route traffic to all pods having both labels app: my-app AND tier: backend, regardless of their IP addresses or state.

View endpoints (actual pod IPs) behind a service:

Code
kubectl get endpoints <service-name>

This list updates automatically as pods are added/removed.

Label Tips:

  • Use meaningful label names: app, tier, environment, version
  • Labels are key-value pairs – can be used for grouping, selection, and rollouts
  • Service selector is not the same as Deployment selector (Deployment selector matches pods it manages; Service selector matches pods it routes to)

Common mistake: Forgetting to add labels to pod template, or mismatching label keys. Then service has 0 endpoints.

11. Real Project – FastAPI App + Deployment + Service

Let’s deploy a real FastAPI app with a Deployment and expose it via NodePort service.

Step 1: FastAPI App Code

Create main.py:

Code
from fastapi import FastAPI
import os

app = FastAPI()

@app.get("/")
def root():
    return {"message": "Namaste from Kubernetes! 🐳", "pod": os.getenv("HOSTNAME", "unknown")}

@app.get("/health")
def health():
    return {"status": "healthy"}

Step 2: Dockerfile

Code
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

requirements.txt:

Code
fastapi
uvicorn

Step 3: Build and Push Image (or use local with Minikube’s docker-env)

Option A – Use Minikube’s Docker daemon:

Code
eval $(minikube docker-env)
docker build -t fastapi-app:latest .

Option B – Push to Docker Hub (for real clusters).

Step 4: Create Deployment YAML (fastapi-deploy.yaml)

Code
apiVersion: apps/v1
kind: Deployment
metadata:
  name: fastapi-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: fastapi
  template:
    metadata:
      labels:
        app: fastapi
    spec:
      containers:
      - name: fastapi
        image: fastapi-app:latest
        imagePullPolicy: Never   # Because we built locally in Minikube’s docker-env
        ports:
        - containerPort: 8000
        resources:
          requests:
            memory: "128Mi"
            cpu: "100m"
          limits:
            memory: "256Mi"
            cpu: "200m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 15
          periodSeconds: 20

Step 5: Create Service YAML (fastapi-service.yaml)

Code
apiVersion: v1
kind: Service
metadata:
  name: fastapi-svc
spec:
  type: NodePort
  selector:
    app: fastapi
  ports:
    - protocol: TCP
      port: 8000
      targetPort: 8000
      nodePort: 31000

Step 6: Deploy

Code
kubectl apply -f fastapi-deploy.yaml
kubectl apply -f fastapi-service.yaml

Step 7: Access API

Code
minikube service fastapi-svc

Or manually:

Code
curl $(minikube ip):31000

Response:

Code
{"message":"Namaste from Kubernetes! 🐳","pod":"fastapi-deploy-5d7b6f8b9c-2dq4t"}

Step 8: Test Health and Scaling

Code
# Check health
curl $(minikube ip):31000/health

# Scale to 5 replicas
kubectl scale deployment fastapi-deploy --replicas=5

Step 9: Clean Up

Code
kubectl delete -f fastapi-service.yaml
kubectl delete -f fastapi-deploy.yaml

12. Common Mistakes (aur Unka Solution!)

MistakeWhy it’s wrongSolution
Deployment selector mismatch with pod template labelsDeployment will fail to create podsEnsure spec.selector.matchLabels matches spec.template.metadata.labels
Service selector not matching pod labelsService has 0 endpoints; traffic never reaches podsCheck labels using kubectl get pods --show-labels and update service selector
TargetPort wrongService sends traffic to wrong container portVerify containerPort in Deployment and set targetPort accordingly
Using imagePullPolicy: Always for local imagesKubernetes tries to pull from registry, failsUse imagePullPolicy: Never or set appropriate registry
Forgetting to specify namespaceResources created in default namespace; may not be isolatedUse -n namespace or set namespace in metadata
Using ClusterIP for external accessService not reachable from outsideChange type to NodePort or LoadBalancer
No resource requests/limitsPods can consume all node resourcesAlways set resources.requests and limits
No readiness/liveness probesKubernetes doesn’t know when pod is ready/aliveAdd readinessProbe and livenessProbe

💡 Personal Experience: I once spent hours debugging why my service wouldn’t forward traffic. The pod labels were app: myapp, but the service selector had app: my-app (hyphen). Kubernetes is case-sensitive and exact-match. Use kubectl get pods --show-labels to verify.

13. Best Practices – Production-Ready Manifests

✅ Always use YAML files, not imperative commands – Store in Git for version control and reproducibility.

✅ Set resource requests and limits – Prevents one pod from starving others.

✅ Use strategic labels – app, tier, environment, version. This helps with organization and selectors.

✅ Define liveness and readiness probes – Essential for self-healing.

✅ Use imagePullPolicy: IfNotPresent or Never for local development, Always for production (but tag properly).

✅ Tag container images with version, not latest – fastapi:v1.0.0, not latest. This enables rollbacks.

✅ Prefer LoadBalancer over NodePort in cloud environments – NodePort exposes high-numbered ports; LoadBalancer gives proper public IP and port 80/443.

✅ Use namespaces to separate environments – dev, staging, prod.

✅ Validate YAML before applying:

Bash
kubectl apply --dry-run=client -f deployment.yaml

✅ Use kubectl rollout status after updates to ensure successful rollout.

✅ Implement HorizontalPodAutoscaler (HPA) for production workloads – scales replicas based on CPU/memory metrics.

✅ Backup Deployment and Service definitions – They are your infrastructure as code.

14. Resources – Cheat Sheet & Practice Prompts

kubectl Commands for Deployments & Services

TaskCommand
Create/update from YAMLkubectl apply -f file.yaml
Delete from YAMLkubectl delete -f file.yaml
List deploymentskubectl get deployments
List serviceskubectl get services
List pods with labelskubectl get pods --show-labels
Scale deploymentkubectl scale deployment NAME --replicas=N
Update imagekubectl set image deployment/NAME CONTAINER=IMAGE
Rollout statuskubectl rollout status deployment/NAME
Rollout historykubectl rollout history deployment/NAME
Rollbackkubectl rollout undo deployment/NAME
Describe deploymentkubectl describe deployment NAME
Describe servicekubectl describe service NAME
Get endpoints of servicekubectl get endpoints NAME
Port forward to pod (debug)kubectl port-forward pod/NAME LOCAL_PORT:TARGET_PORT
Expose deployment as servicekubectl expose deployment NAME --type=NodePort --port=80 --target-port=80

Deployment YAML Skeleton

Code
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  labels:
    app: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: app
        image: my-app:1.0
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "128Mi"
            cpu: "100m"
          limits:
            memory: "256Mi"
            cpu: "200m"

Service YAML Skeleton (NodePort)

Code
apiVersion: v1
kind: Service
metadata:
  name: my-app-svc
spec:
  type: NodePort
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30080

Practice Prompts

Beginner:

  • Nginx Deployment YAML likho with 2 replicas, apply karo, pods running check karo.
  • NodePort service expose karo and access using minikube service.
  • Scale deployment to 4 replicas using kubectl scale.

Intermediate:

  • FastAPI app (simple hello) ka image banao (local Minikube env use karo). Deployment YAML likho with resource requests and liveness probe.
  • Service YAML likho (ClusterIP) and test internal access from a temporary pod (kubectl run test --rm -it --image=busybox -- wget -O- http://fastapi-svc:8000).

Advanced:

  • Rolling update perform karo – change image to v2 and watch rollout strategy.
  • Service type LoadBalancer + Minikube tunnel se external IP assign karo.
  • Canary deployment pattern: Create second Deployment with new version and route partial traffic using a Service with specific label selector (or use Istio).

15. FAQ

Q1: Deployment aur Service mein kya antar hai?

Deployment pods create aur manage karta hai (application logic). Service pods ke liye stable network endpoint provide karti hai (access). Service directly pods ko target nahi karti – wo labels ke through pods find karti hai.

Q2: Service selector mein multiple labels kaise use karein?

Service selector requires all label keys to match (AND condition). Example: selector: { app: myapp, tier: backend } – sirf wahi pods select honge jinka dono labels ho.

Q3: External access ke liye NodePort, LoadBalancer, Ingress mein kya difference hai?

  • NodePort: Har node ke specific port (30000-32767) par service expose karta hai. Simple but not suitable for production.
  • LoadBalancer: Cloud provider ka external load balancer provision karta hai. Production standard.
  • Ingress: HTTP/HTTPS routing, multiple services under same IP, SSL termination, path-based routing.

Q4: Pod delete karna hai to deployment delete karna padega?

Deployment pod ko manage karta hai. Pod directly delete karoge to deployment ek naya pod create kar dega (desired state maintain). Use kubectl delete deployment to remove the deployment and its pods.

Q5: Rolling update ke time service kaise behave karti hai?

Service update ke dauran seamlessly new pods mein traffic shift karti hai. New pods become ready, old pods terminate gradually. No downtime.

Q6: Service endpoints 0 ho rahe hain – kya check karein?

  • Check pod labels match service selector: kubectl get pods --show-labels
  • Check pods are running (kubectl get pods)
  • Check service YAML selector spelling and case
  • Verify targetPort matches pod containerPort
  • Use kubectl describe service to see events

16. Conclusion – Ab Aapki Baari!

Bahut badhiya! Aapne aaj seekh liya:

✅ Kubernetes deployments services Hindi – complete practical guide
✅ Deployment YAML – replicas, selector, template, rolling updates
✅ Scale karne aur rolling update/rollback commands
✅ Service kya hai aur types – ClusterIP, NodePort, LoadBalancer
✅ Service YAML – selector, ports, targetPort
✅ Hands-on Nginx aur FastAPI app deploy and expose
✅ Selector labels kaise kaam karte hain – service to pod matching
✅ Best practices aur common mistakes

Aap ab production-style Kubernetes manifests likh sakte ho. Deployments ensure your app runs reliably, Services ensure it can be reached.

Aapki challenge: FastAPI app (ya koi bhi simple app) ka Docker image banao, Deployment YAML likho with 3 replicas, LoadBalancer service expose karo (Minikube tunnel ke saath). Access karo aur scale karke load balancing test karo. Apna experience comment mein share karo!

Next topic kya chahiye?

  • Kubernetes Ingress – Advanced Routing aur SSL Termination?
  • ConfigMaps aur Secrets – Configuration Management in K8s?
  • Persistent Volumes – Stateful Applications in Kubernetes?

Comment mein batao!

The Easy Master ke saath Kubernetes deployments aur services seekhte raho। Happy exposing! ☸️🚀

Resources

Additional Resources

Views: 351

TheEasyMaster

Author at The Easy Master.

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *