wso2 / k8s-api-operator

API Operator for Kubernetes
Apache License 2.0
115 stars 48 forks source link

Add graceful shutdown command for Integration Pods #577

Closed sajithaliyanage closed 3 years ago

sajithaliyanage commented 3 years ago

Description: $subject. We need to add the below spec to the deployment object.

lifecycle:
  preStop:
    exec:
      command:  ['sh', '-c', '${WSO2_SERVER_HOME}/bin/micro-integrator.sh stop']

This spec is important when it comes to scaling down scenarios.

Suggested Labels: type/improvement

abeykoon commented 3 years ago

The config belongs to container specification. For EI containers, this is static. There is no value making it configurable.

"Kubernetes sends the preStop event immediately before the Container is terminated. Kubernetes' management of the Container blocks until the preStop handler completes, unless the Pod's grace period expires."

_"Note: If the preStop hook needs longer to complete than the default grace period allows, you must modify terminationGracePeriodSeconds to suit this."

"If one of the Pod's containers has defined a preStop hook, the kubelet runs that hook inside of the container. If the preStop hook is still running after the grace period expires, the kubelet requests a small, one-off grace period extension of 2 seconds."_

As default value for terminationGracePeriodSeconds is 30, it is enough for any EI container to shutdown. So there is no need to make terminationGracePeriodSeconds configurable.