I've a deployment whose app makes a lock on a file, and crash if there's any existing lock. How can I ask Kubernetes to remove the old pod before spinning up the new one ?
I know you usually want the opposite, spinning up the new, and only when it's ready remove the old, to avoid downtime. For this case I don't care, it's typesense in a developments environments, we're using the SaaS for staging & production.
Thanks for any help !
Easiest way to achieve that is to set the upgrade strategy to Recreate
.
apiVersion: apps/v1
kind: Deployment
metadata:
[...]
spec:
selector:
[...]
strategy:
type: Recreate
template:
[...]
From docs:
All existing Pods are killed before new ones are created when .spec.strategy.type==Recreate.