Issue with controller.sh in chapter 2 code
Closed this issue · 5 comments
I've just tried running the shell script controller.sh from the chapter 2 code.
The pod has an error:
> kubectl get pods
NAME READY STATUS RESTARTS AGE
sample-5ddbc9bc84-gbdpb 0/1 Error 1 4s
I'm running the shell script under a WSL2 Ubuntu terminal against a Kubernetes cluster running locally under Docker Desktop.
Changing to a more recent version of nginx fixes it.
I changed it from 1.7.9 to 1.14.2 and it works!
I chose 1.14.2 because that's the version from the example in the Kubernetes documentation:
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
Leaving it a few minutes and the error changes to CrashLoopBackOff
:
> kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
sample-5ddbc9bc84-gbdpb 0/1 CrashLoopBackOff 4 2m12s 10.1.0.33 docker-desktop <none> <none>
Here's the output from describe
:
> kubectl describe pod sample-5ddbc9bc84-gbdpb
Name: sample-5ddbc9bc84-gbdpb
Namespace: default
Priority: 0
Node: docker-desktop/192.168.65.4
Start Time: Wed, 05 May 2021 10:54:34 +1000
Labels: app=sample
pod-template-hash=5ddbc9bc84
Annotations: kubectl.kubernetes.io/restartedAt: Wed May 5 10:54:34 AEST 2021
Status: Running
IP: 10.1.0.33
IPs:
IP: 10.1.0.33
Controlled By: ReplicaSet/sample-5ddbc9bc84
Containers:
sample:
Container ID: docker://4c1bb582f3a68e447ffbc7115573b868d4d69bb309197338f137b9a32b9115a1
Image: nginx:1.7.9
Image ID: docker-pullable://nginx@sha256:e3456c851a152494c3e4ff5fcc26f240206abac0c9d794affb40e0714846c451
Port: 80/TCP
Host Port: 0/TCP
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 139
Started: Wed, 05 May 2021 10:57:31 +1000
Finished: Wed, 05 May 2021 10:57:31 +1000
Ready: False
Restart Count: 5
Environment: <none>
Mounts:
/usr/share/nginx/html from data (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-zh5tv (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
data:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: sample
Optional: false
default-token-zh5tv:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-zh5tv
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 3m12s default-scheduler Successfully assigned default/sample-5ddbc9bc84-gbdpb to docker-desktop
Normal Pulled 108s (x5 over 3m11s) kubelet Container image "nginx:1.7.9" already present on machine
Normal Created 107s (x5 over 3m10s) kubelet Created container sample
Normal Started 107s (x5 over 3m10s) kubelet Started container sample
Warning BackOff 81s (x10 over 3m9s) kubelet Back-off restarting failed container
The logs
command returns nothing:
> kubectl logs sample-5ddbc9bc84-gbdpb
As I said I got it working by updating the nginx version number, but I'd be interested to know why there is a problem with the older version.
Please let me know if you have any ideas on this.
Thanks for highlighting the version. We will update the text to reflect the version.