vikas mahajan:
what is wrong in this command -> kubectl run busybox --image=busybox – /bin/sh -c “date”. container is crashing
chris resnik:
–restart=Never is missing
chris resnik:
not sure if the quotes around date are required
vikas mahajan:
Okay, will add restart=Never … tried without quotes as well
chris resnik:
if you run kubectl describe pod busybox
chris resnik:
what do the messages say?
vikas mahajan:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: busybox
name: busybox
spec:
containers:
- args:
- /bin/sh
- -c
- date
image: busybox
name: busybox
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
vikas mahajan:
kubectl run busybox --image=busybox --restart=Never --dry-run=client -o yaml – /bin/sh -c “date” > busybox.yaml
vikas mahajan:
controlplane $ kubectl get pods
NAME READY STATUS RESTARTS AGE
busybox 0/1 Completed 0 70s
vikas mahajan:
date
State: Terminated
Reason: Completed
vikas mahajan:
Events:
Type Reason Age From Message
Normal Scheduled 2m24s default-scheduler Successfully assigned default/busybox to node01
Normal Pulling 2m24s kubelet, node01 Pulling image “busybox”
Normal Pulled 2m22s kubelet, node01 Successfully pulled image “busybox” in 2.017157503s
Normal Created 2m21s kubelet, node01 Created container busybox
Normal Started 2m21s kubelet, node01 Started container busybox
vikas mahajan:
This container is not coming in running state
chris resnik:
looks all okay to me
chris resnik:
is this on katakoda ?
chris resnik:
well, actually…. it completed
chris resnik:
what it does…. it runs the date command, then shuts down
chris resnik:
if you want to keep it running, you need to a sleep command or something that lasts longer than just a second
chris resnik:
pls note you were talking about crashing first, then not coming in running state but it looks like the container / pod completes successfully
chris resnik:
crashing and not coming in running might have complete different reasons….
e.g. crashing e.g. invalid image
not coming in running stage…. might be a readiness probe that is not met
vikas mahajan:
will be running this now