https://drive.google.com/file/d/1rt8QiHNs37SyGVv0Jddhjb-QY9P6gH6u/view?usp=sharing

πŸ” YAML Breakdown

apiVersion: v1
kind: Pod
metadata: 
  name: nnappone
  namespace: learning
  labels:
    app: nnappone
spec:
  nodeName: nodeone.example.com   # ← HARD assignment to this node
  containers:
    - name: crackone-app
      image: nginx
      resources:
        requests:
          memory: "300Mi"
        limits:
          memory: "500Mi"

πŸ”‘ Key Field: spec.nodeName: nodeone.example.com

β†’ Bypasses the Kubernetes scheduler entirely!

β†’ Pod is forced onto this node β€” no checks for resources, taints, or capacity.


πŸ“Œ How nodeName Works

Behavior Explanation
Scheduler Bypassed Normally, scheduler picks best node. Here, you decide.
No Validation Kubernetes won’t check if node exists, has resources, or is ready.
If node is down/unavailable Pod stays in Pending forever (no retry on other nodes).
Use Case Rare! Only for debugging, single-node clusters, or very special workloads.

⚠️ Why Avoid in Production?

βœ… Better Alternatives:


πŸ§ͺ Lab: Deploy Pod to Specific Node

πŸ’‘ Note: You likely don’t have a node named nodeone.example.com β€” so this Pod will fail to schedule. That’s expected! We’ll fix it.

πŸ”§ Step 1: See What Nodes You Have

kubectl get nodes
# Example output:
# NAME           STATUS   ROLES           AGE   VERSION
# minikube       Ready    control-plane   10m   v1.28.0
# minikube-m02   Ready    <none>          10m   v1.28.0

πŸ“ Pick an actual node name (e.g., minikube).

πŸ”§ Step 2: Edit YAML to Use Real Node Name

# pod-for-specific-node.yml (updated)
spec:
  nodeName: minikube   # ← Replace with YOUR node name
  containers:
    - name: crackone-app
      image: nginx
      resources:
        requests:
          memory: "300Mi"
        limits:
          memory: "500Mi"

πŸ”§ Step 3: Run the Lab

# 1. Create namespace
kubectl create namespace learning

# 2. Apply Pod
kubectl apply -f pod-for-specific-node.yml

# 3. Check status
kubectl get pods -n learning -o wide

# βœ… Expected:
# NAME       READY   STATUS    NODE       ...
# nnappone   1/1     Running   minikube   ...

# 4. Verify it’s on the right node
kubectl describe pod nnappone -n learning | grep "Node:"

# 5. Clean up
kubectl delete pod nnappone -n learning
kubectl delete namespace learning