When I am in local, with minikube, I checked that each time I rebuild my app, and roll it out with :
kubectl rollout restart deployment/api-local -n influx
The container lasts 30 sec to be terminated. I have no problem for production matters, but in local dev, I end losing a lot of time waiting, as I can rebuild my app 100 times maybe ( = losing 50 minutes a day ).
Is there some trick to shorten this terminating time ? I understand this would not be part of k8s best practices, but it would make sense to me.
Set the terminationGracePeriodSeconds
in the deployment/pod configuration. Per the reference docs, it is:
...Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.
Example:
spec:
replicas: 1
selector:
...
template:
spec:
terminationGracePeriodSeconds: 0
containers:
...
Also, from here:
The kubectl delete command supports the --grace-period= option which allows a user to override the default and specify their own value. The value 0 force deletes the Pod. You must specify an additional flag --force along with --grace-period=0 in order to perform force deletions.
Example (specify the namespace, if needed):
kubectl delete pod <pod-name> --now
...or
kubectl delete pod <pod-name> --grace-period=0 --force