Created
December 22, 2023 22:25
-
-
Save identw/39ef6d4482ec9692404b7ef3c68bd24e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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