nigelpoulton / TheK8sBook

YAML files for use with The Kubernetes Book
804 stars 651 forks source link

initpod (nigelpoulton/web-app:1.0) CrashLoopBackOff #46

Open mahmud2011 opened 6 months ago

mahmud2011 commented 6 months ago
kubectl apply -f initpod.yml
kubectl apply -f initsvc.yml
kubectl get pods -w

Output:

initpod     0/1     Init:0/1   0          8s
initpod     0/1     PodInitializing   0          32s
initpod     0/1     Error             0          33s
kubectl logs initpod 

Output:

Defaulted container "web-ctr" out of: web-ctr, init-ctr (init)
exec /bin/sh: exec format error
kubectl describe pod initpod

Output:

Events:
  Type     Reason     Age                 From               Message
  ----     ------     ----                ----               -------
  Normal   Scheduled  24m                 default-scheduler  Successfully assigned default/initpod to minikube
  Normal   Pulled     24m                 kubelet            Container image "busybox:1.28.4" already present on machine
  Normal   Created    24m                 kubelet            Created container init-ctr
  Normal   Started    24m                 kubelet            Started container init-ctr
  Normal   Pulled     22m (x5 over 23m)   kubelet            Container image "nigelpoulton/web-app:1.0" already present on machine
  Normal   Created    22m (x5 over 23m)   kubelet            Created container web-ctr
  Normal   Started    22m (x5 over 23m)   kubelet            Started container web-ctr
  Warning  BackOff    14m (x46 over 23m)  kubelet            Back-off restarting failed container web-ctr in pod initpod_default(6a940216-af2e-43a6-a73c-257fe3d46ecf)

Works: Changing the image to nigelpoulton/k8sbook:1.0.

jlyons210 commented 1 month ago

Thank you for sharing this @mahmud2011.

I think this issue would only impact those not running on amd64 architectures. I'm running microk8s on a Raspberry Pi 5, and the nigelpoulton/k8sbook:1.0 image comes in both amd64 and arm64 architectures.

jlyons210 commented 1 month ago

@nigelpoulton - not sure if the best course of action to resolve the issue for arm64 folks would be to update the initpod.yml to reference k8sbook:1.0, or to re-publish the web-app:1.0 image as multiarch?

jlyons210 commented 1 month ago

I ran into a similar issue on a Pi 5 with k8s.gcr.io/git-sync:v3.1.6 - updating to k8s.gcr.io/git-sync/git-sync:v3.6.5 resolved the issue.

Logs from v3.1.6:

$ microk8s kubectl logs -f git-sync --container ctr-sync
INFO: detected pid 1, running init handler
I0914 21:11:27.223483      12 main.go:321]  "level"=0 "msg"="starting up"  "args"=["/git-sync"] "pid"=12
I0914 21:11:27.223556      12 main.go:574]  "level"=0 "msg"="cloning repo"  "origin"="https://github.com/jlyons210/ps-sidecar.git" "path"="/tmp/git"
E0914 21:11:27.226792      12 main.go:347]  "msg"="failed to sync repo, aborting" "error"="error running command: fork/exec /usr/bin/git: exec format error: { stdout: \"\", stderr: \"\" }"