@@ -89,6 +89,8 @@ func (cp *CloudProxy) deploymentSpec() (v1apps.DeploymentSpec, error) {
8989 },
9090 }
9191
92+ terminationGracePeriodSeconds := int64 (120 ) // force kill pod after this time
93+
9294 return v1apps.DeploymentSpec {
9395 Replicas : & replicas ,
9496 Selector : & metav1.LabelSelector {
@@ -106,6 +108,7 @@ func (cp *CloudProxy) deploymentSpec() (v1apps.DeploymentSpec, error) {
106108 Affinity : & v1.Affinity {
107109 PodAntiAffinity : podAntiAffinity (cp .Labels ),
108110 },
111+ TerminationGracePeriodSeconds : & terminationGracePeriodSeconds ,
109112 },
110113 },
111114 }, nil
@@ -115,12 +118,14 @@ func (cp *CloudProxy) container() (v1.Container, error) {
115118 RunAsUser := int64 (2 )
116119 AllowPrivilegeEscalation := false
117120 instanceArg := fmt .Sprintf ("-instances=%s=tcp:0.0.0.0:%s" , cp .InstanceConnectionName , strconv .FormatInt (int64 (cp .Port ), 10 ))
121+ timeoutSecond := 60 // wait given seconds after SIGTERM
122+ timeoutArg := fmt .Sprintf ("-term_timeout=%ss" , strconv .FormatInt (int64 (timeoutSecond ), 10 ))
118123
119124 return v1.Container {
120125 Name : "cloudsql-proxy" ,
121126 Image : conf .Instances .Google .ProxyConfig .Image ,
122127 Command : []string {"/cloud_sql_proxy" },
123- Args : []string {instanceArg , "-credential_file=/srv/gcloud/credentials.json" },
128+ Args : []string {instanceArg , "-credential_file=/srv/gcloud/credentials.json" , timeoutArg },
124129 SecurityContext : & v1.SecurityContext {
125130 RunAsUser : & RunAsUser ,
126131 AllowPrivilegeEscalation : & AllowPrivilegeEscalation ,
0 commit comments