Skip to content

Commit

Permalink
Wait for app to exit before letting the cloud proxy terminate (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
peppelan committed Nov 25, 2019
1 parent 4279a42 commit 943fd08
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ func getCloudContainer() v1.Container {
cloudSQLProxyContainer.Resources = v1.ResourceRequirements{Requests: requestResources, Limits: limitResources}
cloudSQLProxyContainer.SecurityContext = &securityContext
cloudSQLProxyContainer.VolumeMounts = append(cloudSQLProxyContainer.VolumeMounts, volumeMount)

cloudSQLProxyContainer.Lifecycle = &v1.Lifecycle{PreStop: &v1.Handler{
Exec: &v1.ExecAction{
Command: []string{"/bin/sh", "-c", "while [ $(netstat -plunt | grep tcp | grep -v envoy | grep -v cloud_sql_proxy | wc -l | xargs) -ne 0 ]; do sleep 1; done"},
},
}}
}

return cloudSQLProxyContainer
Expand Down

0 comments on commit 943fd08

Please sign in to comment.