 Okay, one other feature that was added to spring boot 2.3 is the ability to specify a graceful shutdown So the weight container shutdown that can be quite abrupt and you can have like half-baked transactions So to speak things might not be finished for processing Having a graceful shutdown gives the application the capability to get to a graceful state for Having everything done so to speak so you want to give it a couple seconds to get anything that's in flight completed rather than just Terminating it abruptly so I'm gonna show you in this video how to set that up again It's two things that we need to do one is to set up spring boot We need to configure spring boot to enable this capability and then we need to make kubernetes aware of this capability So the first thing we want to do is come in and I'm gonna look at the inventory deployment file We would need to add in another environment property and this time it's gonna be named Creatively enough this is called server shutdown and the value we want set is going to be graceful So again, if there's a some type of in-flight database transaction Or if we're reading from a queue we'll get that work done before we terminate the JVM so this sets up the spring boot configuration and then for kubernetes itself We want to go in and add in Lifecycle And we'll call this pre-stop and we're gonna execute a command and Basically, we're gonna tell it to sleep for 10 seconds So we're gonna execute a shell command and the syntax for that is gonna be sh For shell it's a little weird how you have to escape every string into a common set of strings then comma C and then sleep 10 So we have a comma list of strings here. That's a shell command Minus C for a parameter and then sleep 10 So this is going to tell kubernetes to sleep for 10 seconds as it's shutting it down and that will allow Spring to go ahead and shut things down properly. I'm gonna pause the video and apply this to the other Two deployments real quick. So let me pause this. I'll be right back So for order service and the beer service. I've also applied the same values You can see now we have the environment property server shut down graceful and the stanza and the container the container image Lifecycle pre-stop exact command sleep 10 and The last step we want to do is we're gonna come over to the command line And what we want to do is say cube apply minus F inventory deployment and We ran into an error. So let's take a closer look at that Always see what I made up per stop. So this should be Pre and I'm pretty sure copied that Very simple mistake there miss typed the pre stop not per stop. So let's come back over to the command line saying the same And I'm just gonna make sure that saved Let me pause this and take a closer look And when I returned that I saw that I did in fact miss the per stop and inventory. So double-check order is correct and Immentory beer so they're all correct. So that's working better And we want the order Deployment as well. So that by doing our apply myself the deployment not again, I was gonna tell Kubernetes go ahead and Reapply those and it will recreate those and We can see here like the inventory service that is terminating We also have a beer service terminating and we can see that New one is starting up. So by doing that apply shuts down the old one brings up a new one and Gets that ready for us. So those values have now been set and our spring boot Applications will shut down gracefully like toggle back over to intelligent just recap again The two things that we need to apply first is an environment property called server shutdown graceful that enable spring boot for that and then for kubernetes to Be sensitive to that we are telling kubernetes to before stopping it give it ten seconds to allow it to finish processing