I'm planning to use the distroless base image to run container applications.
Since I'm using envoy in the k8s sidecar, when I stop the application container, I use the sleep command in preStop before safely stopping the pod.
lifecycle
preStop:
exec:
command:
- sleep
- "40
Since the distroless image does not allow the use of shells, etc., we use a multi-stage build so that we can use the sleep command.
This simple golang application.
FROM alpine:3.13 as builder
ENV GOROOT /go
FROM gcr.io/distroless/static-debian10
WORKDIR /app
COPY ./dist/app ./
COPY --from=builder /bin/sleep /bin/sleep
CMD ["./app"]
The sleep command was failing when I started the Pod in this image and had it switch to another Pod.
Exec lifecycle hook ([sleep 40]) for Container
Is it not possible to do it this way? If I'm doing this wrong, I'd like pointers.
Thanks.