CKA Service & Troubleshooting Quick Reference

Create a Service (Fast Way)

kubectl expose deployment nginx \
  --name=nginx-svc \
  --port=80 \
  --target-port=80

Service YAML

apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  type: ClusterIP
  selector:
    app: nginx
  ports:
  - port: 80
    targetPort: 80

Remember:

spec:
  type
  selector
  ports

Troubleshooting Workflow

Problem First Command
Pod Pending kubectl describe pod <pod>
CrashLoopBackOff kubectl logs <pod>
ImagePullBackOff kubectl describe pod <pod>
Service Not Working kubectl get endpoints <svc>
PVC Pending kubectl describe pvc <pvc>
Network Issue kubectl get networkpolicy -A

ImagePullBackOff Cheat Sheet

Error Likely Cause
manifest unknown Bad tag
repository not found Bad image name
unauthorized Missing imagePullSecret
no such host Bad registry
FailedToRetrieveImagePullSecret Secret does not exist

Service Troubleshooting

If:

kubectl get endpoints nginx-svc

<none>

Think:

Selector mismatch

Check:

kubectl describe svc nginx-svc
kubectl get pods --show-labels

CKA Golden Rule

Pod Problem?
↓
kubectl describe pod

Container Problem?
↓
kubectl logs

Service Problem?
↓
kubectl get endpoints

Storage Problem?
↓
kubectl describe pvc

Network Problem?
↓
kubectl get networkpolicy

✅ CKA Troubleshooting Lab Checklist

Goal: Break every item intentionally and fix it without looking at notes.

⭐ Highest Priority Labs

Pods


Expected: ImagePullBackOff
Clue: manifest unknown
kubectl describe pod


Expected: repository not found

Expected:
FailedToRetrieveImagePullSecret

command: ["false"]
Practice:
kubectl logs pod
kubectl logs pod --previous

resources:
  requests:
    memory: 500Gi
Expected:
Insufficient memory

Expected:
node(s) had taint
Fix:
tolerations:

Services

Pod Label:
app: nginx

Service Selector:
app: web
Expected:
kubectl get endpoints service-name

<none>
Practice:
kubectl describe svc service-name
kubectl get pods --show-labels

Service:
targetPort: 8080

Container:
containerPort: 80
Expected:
Endpoints exist
Traffic fails

Deployments

image: nginx:999
Practice:
kubectl describe deployment
kubectl get rs
kubectl get pods
Follow:
Deployment
↓
ReplicaSet
↓
Pod

kubectl scale deployment nginx --replicas=5

Storage

Practice:
kubectl get pvc
kubectl describe pvc

Example:
PV:
ReadWriteOnce

PVC:
ReadOnlyMany

Example:
PV:
fast

PVC:
slow

Networking

Practice:
kubectl get networkpolicy -A
kubectl describe networkpolicy

Practice:
kubectl exec -it pod -- sh
wget
curl

Create:
kubectl run dns-test --image=busybox --restart=Never -it -- sh
Test:
nslookup kubernetes.default

Nodes

Practice:
kubectl get nodes
kubectl describe node
Node commands:
sudo systemctl status kubelet
sudo systemctl restart kubelet

kubectl drain node1 --ignore-daemonsets
kubectl uncordon node1

Commands To Know Cold

kubectl describe pod

kubectl logs
kubectl logs --previous

kubectl get endpoints

kubectl describe pvc

kubectl get networkpolicy -A

kubectl describe node

kubectl get pods -o wide

kubectl get pods --show-labels

kubectl get rs

kubectl describe deployment

10 Errors You Should Instantly Recognize

ImagePullBackOff
→ kubectl describe pod

CrashLoopBackOff
→ kubectl logs

manifest unknown
→ bad tag

repository not found
→ bad image

unauthorized
→ imagePullSecret

FailedToRetrieveImagePullSecret
→ secret missing

Insufficient memory
→ scheduling issue

node(s) had taint
→ toleration needed

endpoints 
→ selector mismatch

PVC Pending
→ PV / AccessMode / StorageClass issue

🏆 CKA Golden Rule

Pod Problem?
↓
kubectl describe pod

Container Problem?
↓
kubectl logs

Service Problem?
↓
kubectl get endpoints

Storage Problem?
↓
kubectl describe pvc

Network Problem?
↓
kubectl get networkpolicy -A

Node Problem?
↓
kubectl describe node