Hi, `apiVersion: apps/v1` `kind: Deployment` `metadata:` `name: space-alien` ` . . .

Zakiya Jafrin:
Hi,
apiVersion: apps/v1
kind: Deployment
metadata:
name: space-alien
spec:
replicas: 1
selector:
matchLabels:
app: space-alien
strategy: {}
template:
metadata:
labels:
app: space-alien
spec:
containers:
- image: httpd:alpine
name: httpd
resources: {}
command:
- sh
- -c
- touch /tmp/ready

~

Zakiya Jafrin:
Why this yam gives crashloopbackoff? I am confused here shouldn’t it just create a file(/tmp/ready) inside the container and behave normally? The logs are not helpful either. ANyone help me understand?

Zakiya Jafrin:
I did not tell the container to exit. Why is it exiting?

Ankit Singh:
i think container are short lived only till when the command get executed

Zakiya Jafrin:
But why, httpd is not an short lived image like busybox. Then why?

Ankit Singh:
will checkout and let u know

Alistair Mackay:
Doesn’t matter what the image was that you used. You overrode the default command which is to run httpd and wait, with your own command touch /tmp/ready which executed to completion, therefore the container exits.

Gin Ichimaru:
Indeed, if we look image “httpd:alpine” dockerfile, we can see that default command is “httpd-foreground”. @Alistair Mackay: what will be the solution ? Do we have to rewrite new dockerfile including a step for creating “/tmp/ready” ? Or is there another way to provide additional commands after default one ?

Alistair Mackay:
command overrides whatever the default entrypoint in the dockerfile was.
If you want an image that permanently overrides the default entrypoint, then yes, create a new dockerfile and build it
There is no real world scenario for a pod with a single container that runs only touch. Such a pod will always exit immediately and be seen to be crashlooping

Alistair Mackay:
If you are trying to test whether httpd is ready to serve requests, then you would use an http readiness probe to call a page being served by httpd. When that returns a 200 status, then the pod is considered ready
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes

Gin Ichimaru:
@Alistair Mackay Thanks for feedback. Without this extra command, pod is running perfectly fine. I was just wondering how to find a workaround to help @Zakiya Jafrin but I think you already answered. Thanks

Zakiya Jafrin:
Thank you soo much. I got my answer. I was actually doing practice with readiness probe and command passing. @Alistair Mackay you explained perfectly

unnivkn:
Hi @Gin Ichimaru fyr:


Gin Ichimaru:
@unnivkn thanks!