spring-guides / top-spring-on-kubernetes

Spring on Kubernetes :: Topic guide to Spring and Kubernetes
18 stars 14 forks source link

Remove prestop configuration from deployment.yaml #8

Open scottfrederick opened 1 month ago

scottfrederick commented 1 month ago

The following should be removed from the example deployment.yaml file:

          lifecycle:
            preStop:
              exec:
                command: ["sh", "-c", "sleep 10"]

The preStop is not necessary since Spring Boot apps handle SIGTERM notifications and gracefully shut down.

In addition, Docker images for applications are often built with distroless base images that do not include a shell, so commands like the sh -c sleep 10 recommended here will not work. The ./mvnw spring-boot:build-image command suggested in this guide will use a base image that does not include a shell starting with Spring Boot 3.4.

robertmcnees commented 1 month ago

Thanks, @scottfrederick. Great catch. I have a pending PR #7 on this guide that touches a lot of files. I made an additional commit there that removes the preStop instructions.

PR #7 is waiting on a review from @ryanjbaxter but please feel free to also have a look.

scottfrederick commented 1 month ago

The credit goes to @anthonydahanne for finding this and bringing it to our attention. Thanks @robertmcnees for the cleanup PR, I'll take a look.