Skip to content

Commit 943fd08

Browse files
authored
Wait for app to exit before letting the cloud proxy terminate (#6)
1 parent 4279a42 commit 943fd08

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ func getCloudContainer() v1.Container {
171171
cloudSQLProxyContainer.Resources = v1.ResourceRequirements{Requests: requestResources, Limits: limitResources}
172172
cloudSQLProxyContainer.SecurityContext = &securityContext
173173
cloudSQLProxyContainer.VolumeMounts = append(cloudSQLProxyContainer.VolumeMounts, volumeMount)
174+
175+
cloudSQLProxyContainer.Lifecycle = &v1.Lifecycle{PreStop: &v1.Handler{
176+
Exec: &v1.ExecAction{
177+
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"},
178+
},
179+
}}
174180
}
175181

176182
return cloudSQLProxyContainer

0 commit comments

Comments
 (0)