Last active
February 11, 2019 20:17
-
-
Save jiang-wei/2fbdcfc6ee0e68424221e7168d3bca0d to your computer and use it in GitHub Desktop.
K8S kill sidecar containers deployment args
This file contains 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
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