Skip to content

Instantly share code, notes, and snippets.

@jiang-wei
Last active February 11, 2019 20:17
Show Gist options
  • Save jiang-wei/2fbdcfc6ee0e68424221e7168d3bca0d to your computer and use it in GitHub Desktop.
Save jiang-wei/2fbdcfc6ee0e68424221e7168d3bca0d to your computer and use it in GitHub Desktop.
K8S kill sidecar containers deployment args
containers:
- name: main
image: gcr.io/some/image:latest
command: ["/bin/bash", "-c"]
args:
- |
trap "touch /tmp/pod/main-terminated" EXIT
/my-batch-job/bin/main --config=/config/my-job-config.yaml
volumeMounts:
- mountPath: /tmp/pod
name: tmp-pod
- name: envoy
image: gcr.io/our-envoy-plus-bash-image:latest
command: ["/bin/bash", "-c"]
args:
- |
/usr/local/bin/envoy --config-path=/my-batch-job/etc/envoy.json &
CHILD_PID=$!
(while true; do if [[ -f "/tmp/pod/main-terminated" ]]; then kill $CHILD_PID; fi; sleep 1; done) &
wait $CHILD_PID
if [[ -f "/tmp/pod/main-terminated" ]]; then exit 0; fi
volumeMounts:
- mountPath: /tmp/pod
name: tmp-pod
readOnly: true
volumes:
- name: tmp-pod
emptyDir: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment