Skip to content

Commit e1924b8

Browse files
committed
Addition of configurable preStop sleep with env variable PRE_STOP_SLEEP_SECONDS
1 parent 92fcad3 commit e1924b8

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ spec:
177177
...
178178
```
179179

180-
| Variable name | Default | Description |
181-
| ------------------------------ | --------------------------------- | ------------------------------------------------------- |
182-
| ENVOY_IMAGE | `envoyproxy/envoy-alpine:v1.16.5` | Name of the Envoy Proxy image to use |
183-
| TAINT_TOLERATION_KEY | Empty, no tolerations applied | Toleration key to apply to gateway pods |
184-
| TAINT_TOLERATION_VALUE | Empty, no tolerations applied | Toleration value to apply to gateway pods |
185-
| NODE_SELECTOR_KEY | Empty, no node selector added | Node selector label key to apply to gateway pods |
186-
| NODE_SELECTOR_VALUE | Empty, no node selector added | Node selector label value to apply to gateway pods |
187-
| ROLLING_UPDATE_MAX_UNAVAILABLE | 25% | Rolling Update max unavailable to apply to gateway pods |
188-
| ROLLING_UPDATE_MAX_SURGE | 25% | Rolling Update max surge to apply to gateway pods |
180+
| Variable name | Default | Description |
181+
| ------------------------------ | --------------------------------- | ------------------------------------------------------------------------- |
182+
| ENVOY_IMAGE | `envoyproxy/envoy-alpine:v1.16.5` | Name of the Envoy Proxy image to use |
183+
| TAINT_TOLERATION_KEY | Empty, no tolerations applied | Toleration key to apply to gateway pods |
184+
| TAINT_TOLERATION_VALUE | Empty, no tolerations applied | Toleration value to apply to gateway pods |
185+
| NODE_SELECTOR_KEY | Empty, no node selector added | Node selector label key to apply to gateway pods |
186+
| NODE_SELECTOR_VALUE | Empty, no node selector added | Node selector label value to apply to gateway pods |
187+
| ROLLING_UPDATE_MAX_UNAVAILABLE | 25% | Rolling Update max unavailable to apply to gateway pods |
188+
| ROLLING_UPDATE_MAX_SURGE | 25% | Rolling Update max surge to apply to gateway pods |
189+
| PRE_STOP_SLEEP_SECONDS | 25 | Number of seconds to wait before sending shutdown signal to gateway pods. `terminationGracePeriodSeconds` will be set to this value increased by 5s |

controllers/deployment.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func deployment(es *egressv1.ExternalService, configHash string) *appsv1.Deploym
113113
maxUnavailable := intstr.Parse(maxUnavailableStr)
114114
maxSurge := intstr.Parse(maxSurgeStr)
115115

116+
preStopSleepSeconds := lookupEnvOr("PRE_STOP_SLEEP_SECONDS", "25")
117+
118+
terminationGracePeriodSecondsIntOrString := intstr.Parse(preStopSleepSeconds)
119+
116120
return &appsv1.Deployment{
117121
ObjectMeta: metav1.ObjectMeta{
118122
Name: es.Name,
@@ -152,11 +156,12 @@ func deployment(es *egressv1.ExternalService, configHash string) *appsv1.Deploym
152156
},
153157
},
154158
// Copying istio; don't try drain outbound listeners, but after going into terminating state,
155-
// wait 25 seconds for connections to naturally close before going ahead with stop.
159+
// wait 'preStopSleepSeconds' (default: 25) seconds for connections to naturally close before
160+
// going ahead with stop.
156161
Lifecycle: &corev1.Lifecycle{
157162
PreStop: &corev1.Handler{
158163
Exec: &corev1.ExecAction{
159-
Command: []string{"/bin/sleep", "25"},
164+
Command: []string{"/bin/sleep", preStopSleepSeconds},
160165
},
161166
},
162167
},
@@ -187,7 +192,7 @@ func deployment(es *egressv1.ExternalService, configHash string) *appsv1.Deploym
187192
RestartPolicy: corev1.RestartPolicyAlways,
188193
SchedulerName: corev1.DefaultSchedulerName,
189194
SecurityContext: &corev1.PodSecurityContext{},
190-
TerminationGracePeriodSeconds: proto.Int64(30),
195+
TerminationGracePeriodSeconds: proto.Int64(int64(terminationGracePeriodSecondsIntOrString.IntValue()) + 5),
191196
DNSPolicy: corev1.DNSDefault,
192197
Volumes: []corev1.Volume{
193198
{

0 commit comments

Comments
 (0)