Run the get pods to see the state of pods
kubectl get pods -A
kubectl describe pod bad-image-6b59c98484-8cbb4 -n k8sgpt-lab
This shows image is not existing


The deployment isn’t a file on disk — it lives inside Kubernetes so les check bad-image and save the deployment to a temp file
kubectl get deployment bad-image -n k8sgpt-lab -o yaml > /tmp/bad-image.yaml
Open the file

Change it to: image: nginx:latest

Apply the file
kubectl apply -f /tmp/bad-image.yaml
Check the pods

bad-image is fixed and Running. Three left. Let’s go through each one:

kubectl describe pod bad-image-6b59c98484-8cbb4 -n k8sgpt-lab


The deployment isn’t a file on disk — it lives inside Kubernetes so les check bad-probe and save the deployment to a temp file
kubectl get deployment bad-probe -n k8sgpt-lab -o yaml > /tmp/bad-probe.yaml
Open the file

Error is this section

Apply the file
kubectl apply -f /tmp/bad-probe.yaml
kubectl get pods -n k8sgpt-labYou should see bad-probe stop restarting and go to Running.

Ok, lets AI to fix the CrashLoopBackOff
Here we cant drill down to individual pod but result is on the namesapce
k8sgpt analyze --explain --backend localai --namespace k8sgpt-labFinding 2 — oom-app: Kubernetes container was terminated due to OutOfMemory
Finding 3 — resource-hog: 0/1 nodes are available: 1 Insufficient cpu

run -o wide to the status more clearly
kubectl get pods -n k8sgpt-lab -o wide
kubectl describe pod resource-hog-c766fc4f9-2lwbs -n k8sgpt-lab | grep -A3 Limits
kubectl describe pod resource-hog-c766fc4f9-2lwbs -n k8sgpt-lab | grep -A3 Requestsoom-app is memory limited and resource-hog pod is the CPU starved

Fix oom-app memory
kubectl set resources deployment oom-app -n k8sgpt-lab--limits=memory=200Mi --requests=memory=200Mi
Fix resource-hog CPU+memory
kubectl set resources deployment resource-hog -n k8sgpt-lab --limits=cpu=200m,memory=128Mi --requests=cpu=100m,memory=64Mi
Analyse and explain using AI
k8sgpt analyze --explain --backend localai --namespace k8sgpt-lab

