Skip to content

Instantly share code, notes, and snippets.

@identw
Created December 22, 2023 22:25
Show Gist options
  • Save identw/39ef6d4482ec9692404b7ef3c68bd24e to your computer and use it in GitHub Desktop.
Save identw/39ef6d4482ec9692404b7ef3c68bd24e to your computer and use it in GitHub Desktop.
apiVersion: apps/v1
kind: Deployment
metadata:
name: pre-stop
labels:
app: pre-stop
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: pre-stop
template:
metadata:
labels:
app: pre-stop
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: tmp
emptyDir: {}
containers:
- name: pre-stop
resources:
requests:
cpu: 20m
memory: 10Mi
limits:
cpu: 20m
memory: 10Mi
image: docker.io/alpine:3.18.4
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- |
_term() {
cat /tmp/lifehook_logs
echo "`date +%F' '%H:%M:%S`: Caught SIGTERM signal"
exit 0
}
trap _term SIGTERM
echo "`date +%F' '%H:%M:%S`: Start app"
while true;
do
sleep 1
done
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- |
echo "`date +%F' '%H:%M:%S`: start preStop" > /tmp/lifehook_logs
sleep 10
volumeMounts:
- name: tmp
mountPath: /tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment