-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
Add ability to kill sidecar container (e.g. cloud sql proxy) within job pod.
My suggestion is to add to shutdown?
method creating of some file to shared volume path, which could be a signal to kill sidecar.
def shutdown?
if term_on_empty
if queues_empty?
log_with_severity :info, "shutdown: queues are empty"
shutdown
File.new "/tmp/pod/main-terminated"
end
end
super
end
Sidecar command
command: ["/bin/sh", "-c"]
args:
- |
/cloud_sql_proxy --dir=/cloudsql -instances=ACCOUNT::REGION:: INSTANCE =tcp:5432 -credential_file=/secrets/cloudsql/credentials.json &
CHILD_PID=$!
(while true; do if [[ -f "/tmp/pod/main-terminated" ]]; then kill $CHILD_PID; echo "Killed $CHILD_PID as the main container terminated."; fi; sleep 1; done) &
wait $CHILD_PID
if [[ -f "/tmp/pod/main-terminated" ]]; then exit 0; echo "Job completed. Exiting..."; fi
volumeMounts for each containers
- mountPath: /tmp/pod
name: tmp-pod
readOnly: true
Volumes
- name: tmp-pod
emptyDir: {}
It would be cool to have some method like
def sidecar_kill
true
end
Metadata
Metadata
Assignees
Labels
No labels