Posts

Kubectl Commands for Pod, ReplicaSet and Deployment

🚀 Kubernetes Pod, ReplicaSet & Deployment – Commands Cheat Sheet (with comments) 🟢 POD Commands kubectl run nginx --image=nginx # Create a simple pod quickly (imperative way) kubectl run nginx --image=nginx --dry-run=client -o yaml > pod.yaml # Generate pod YAML without creating it kubectl apply -f pod.yaml # Create pod from YAML kubectl get pods # List all pods kubectl get pods -o wide # Show pods with node + IP info kubectl describe pod nginx # Detailed info + events (best for troubleshooting) kubectl logs nginx # Show container logs kubectl logs -f nginx # Stream logs live (follow mode) kubectl exec -it nginx -- bash # Enter inside container shell kubectl delete pod nginx # Delete pod 🟡 REPLICASET Commands kubectl apply -f rs.yaml # Create ReplicaSet from YAML kubectl get rs # List ReplicaSets kubectl describe rs myrs # Detailed ReplicaSet info kubectl scale rs myrs --replicas=5 # Increase/decrease number of pods kubectl get pods -l app=myapp # Show pods created by this Re...

YAML Skeleton (VERY IMPORTANT)

 ðŸš€ Step 1 – First Understand the YAML Skeleton (VERY IMPORTANT) Almost EVERY Kubernetes YAML looks like this: apiVersion: kind: metadata: spec: 🧠 Golden Memory Rule 👉 AKMS A → apiVersion K → kind M → metadata S → spec If you remember ONLY this → you can reconstruct everything. 🔹 What goes under each section? ✅ 1️⃣ apiVersion → "Which API group/version?" Tells Kubernetes which version of resource API to use Common values Resource apiVersion Pod v1 Service v1 ReplicaSet apps/v1 Deployment apps/v1 StatefulSet apps/v1 🧠 Memory Tip 👉 Core = v1 👉 Controllers = apps/v1 ✅ 2️⃣ kind → "What are we creating?" Defines object type Examples: kind: Pod kind: ReplicaSet kind: Deployment kind: Service 🧠 Memory Tip 👉 Just the resource name ✅ 3️⃣ metadata → "Information ABOUT object" Used for: name labels namespace annotations Example metadata: name: myapp labels: app: paytm 🧠 Memory Tip ...

ReplicaSet & Deployment

 ðŸ“Œ Kubernetes ReplicaSet & Deployment 🔹 What is a ReplicaSet? A ReplicaSet (RS) is a Kubernetes controller that ensures a specified number of identical Pods are running at all times. If a Pod: Crashes Is deleted Node goes down ➡️ ReplicaSet automatically creates a new Pod to maintain the desired count. 🔹 Why ReplicaSet is Used ReplicaSet is used to: Maintain high availability Ensure fault tolerance Automatically heal Pods Run multiple replicas of the same application 🔹 How ReplicaSet Works User defines desired number of replicas ReplicaSet uses labels & selectors It continuously compares: Desired state vs Actual state If mismatch occurs → it creates or deletes Pods 🔹 ReplicaSet Key Concepts 1️⃣ Replicas Number of Pod copies to run Defined in spec.replicas 2️⃣ Pod Template Blueprint for Pods All Pods are identical Defined under spec.template 3️⃣ Labels & Selectors RS identifies Pods u...
 ðŸ“˜ Kubernetes Notes – Labels, ReplicaSet & Deployment 🔹 LABELS Labels are key-value pairs attached to Kubernetes objects like: Pods ReplicaSets Deployments Services Nodes They are mainly used for: Identification Grouping Selection Management Features Can be added during creation or runtime Multiple labels per object allowed ReplicaSet/Service manages Pods only using labels Example kubectl run pod-1 --image=nginx --labels= "env=dev,app=swiggy" kubectl get pods --show-labels Extra useful commands kubectl label pod pod-1 tier=frontend kubectl label pod pod-1 tier- kubectl get pods -l env =dev 🔹 SELECTORS Selectors filter Pods using labels. Used by: ReplicaSet Deployment Service Types 1️⃣ Equality-based app=paytm env !=prod 2️⃣ Set-based env in (dev, test ) env notin (prod) Example kubectl get pods -l app=paytm 🔹 REPLICASET (RS) ReplicaSet ensures desired number of Pods are always running . ...

Linux File Management Commands Cheat Sheet

Linux File Management Commands Cheat Sheet   # ---------- CREATE FILES ---------- touch file.txt              # create an empty file > file.txt                  # create or overwrite file instantly echo "hello" > file.txt     # create file and write text echo "hello" >> file.txt    # append text to file cat > file.txt              # create file and type content manually (Ctrl+D to save) nano file.txt               # create/edit file using nano editor vim file.txt                # create/edit file using vim editor gedit file.txt              # create/edit file using GUI editor # ---------- VIEW FILES ---------- cat file.txt                # display entire file content less ...

Docker Swarm Explained: Complete Guide to Container Orchestration for Beginners

 Docker Swarm – Complete Beginner Friendly Guide 📌 What is Docker Swarm? Docker Swarm is Docker’s native container orchestration tool . It helps you: ✅ Manage multiple containers ✅ Run containers across multiple servers ✅ Distribute workloads automatically ✅ Scale applications easily ✅ Provide high availability In simple words: 👉 Swarm = Managing containers across many machines like one system 🧠 Basic Concept Instead of running containers on just one server , Docker Swarm lets you create a: 🔹 Cluster (Swarm) A group of servers working together. Inside the cluster, we have: 🟢 Manager Node Controls the cluster Schedules containers Assigns tasks Manages worker nodes Gives join tokens 🔵 Worker Node Executes containers Runs tasks given by manager Maintains the containers ⚙️ Requirements Before creating a swarm: ✅ Docker Engine must be installed ✅ Docker service must be running ✅ Port 2377 must be open (Swarm communication port) ...