1️⃣ Labels & Selectors in Kubernetes (Detailed Explanation) ⇒

🔹 Labels in Kubernetes

Labels in Kubernetes are key-value pairs assigned to objects like Pods, Nodes, and Services. They provide an efficient way to organize, manage, and filter resources within a cluster.

Key Features of Labels:

📌 Example of Labels in a Pod Configuration (Declarative Method):

Create a file pod5.yml and define a Pod with labels:

# Example of Labels in a Pod
kind: Pod
apiVersion: v1
metadata:
  name: delhipod
  labels:
    env: development
    class: pods
    love: devops
spec:
  containers:
    - name: c00
      image: ubuntu
      command: ["/bin/bash", "-c", "while true; do echo Hello-Bhupinder; sleep 5 ; done"]

🛠 Applying the Pod Configuration:

kubectl apply -f pod5.yml   # Deploy the pod with labels
kubectl get pods --show-labels  # Display the labels associated with the pod

🔹 Adding Labels to an Existing Pod (Imperative Method)