Skip to content

Instantly share code, notes, and snippets.

@wuestkamp
Created February 21, 2020 22:00
Show Gist options
  • Save wuestkamp/9d505da5ecf73435655f13fb1a59c307 to your computer and use it in GitHub Desktop.
Save wuestkamp/9d505da5ecf73435655f13fb1a59c307 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Pod
metadata:
name: runner
namespace: tmp
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: share
emptyDir: {}
containers:
- name: sidecar
command: ["python", "-c", "import time;time.sleep(9999)"]
image: python:3.5
lifecycle:
preStop:
exec:
command: ["sh", "-c", "while ! [ -f /tmp/share/kill_sidecar ]; do sleep 1; done; kill -2 1"]
volumeMounts:
- mountPath: /tmp/share
name: share
- command:
- sh
- -c
- >
touch /tmp/messaging &&
while ! [ -f /tmp/kill_me ];
do
cat /tmp/messaging;
rm /tmp/messaging && touch /tmp/messaging;
sleep 1;
done;
touch /tmp/share/kill_sidecar
image: bash
name: runner
lifecycle:
postStart:
exec:
command: ["sh", "-c", "echo postStart >> /tmp/messaging"]
preStop:
exec:
command: ["sh", "-c", "echo preStop >> /tmp/messaging && sleep 10 && touch /tmp/kill_me"]
volumeMounts:
- mountPath: /tmp/share
name: share
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment