0

I have a question with kubernetes when deploying a new version.

My yaml configuration of Kubernetes has the RollingUpdate strategy. The problem comes when it comes to changing versions this way. If I have a php-fpm that is performing an action, does that action get lost? In case it is just changing that pod to the new version.

My main question is if kubernetes with this strategy takes into consideration if the pod is being used and if so, if it waits until he finishes what it has to do and changes it.

Thanks!

A.A.
  • 3
  • 2
Sermanes
  • 113
  • 1
  • 5
  • As per this [K8s document](https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods) about how generally pods are terminated, you can use PreStop container hooks as indicated in this [document](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks) with a desired grace period. – Fady Oct 06 '18 at 02:03
  • What does php-fpm do when it gets a SIGTERM? There is your answer. – Michael Hampton Oct 06 '18 at 12:37
  • @MichaelHampton It's what the container does before it kills the pod. – Sermanes Oct 06 '18 at 15:53

1 Answers1

0

To expand on what @Fady said above, for those that still may be curious.

By calling the PreStop container hook you can close all loose ends before the container is terminated. From the documentation "PreStop: This hook is called immediately before a container is terminated." [1]

The PreStop hook can execute a specific command(s) or executes an HTTP request against an endpoint on the container. Additionally, the standard grace period is 30 seconds. You can, however, pass a custom time by appending --grace-period=<seconds>. [2]

[1] https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

[2] https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods