I have a deployment template as below. but the prestop hook is never been executed at all. the idea here is set the zookeeper node offline before the pod is terminated.
I am running kubectl rollout to restart the pods. and old pod is when it terminates the prestop is not run. could someone please check whats wrong ?
Basically how its prestop executed in case of successful stop ? I need this feature because the zookeeper is involved here and the api connects to zookeeper to send the requests.
apiVersion: apps/v1
kind: Deployment
metadata:
name: abcd
labels:
app: abcd
spec:
replicas: 1
selector:
matchLabels:
app: abcd
template:
metadata:
labels:
app: abcd
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
# terminationGracePeriodSeconds: 1
containers:
- name: se
image: "xxx"
lifecycle:
preStop:
exec:
command: ["zookeepercli","--servers","zk-hs", "-c", "set", "$HOSTNAME", "offline"]
ports:
- containerPort: 2345
- name: pe-1
image: "xxx"
lifecycle:
preStop:
exec:
command: ["zookeepercli","--servers","zk-hs", "-c", "set", "$HOSTNAME", "offline"]
ports:
- containerPort: 2313