|
| 1 | +--- |
| 2 | +title: "Graceful Shutdown and Hitless Upgrades" |
| 3 | +--- |
| 4 | + |
| 5 | +Envoy Gateway enables zero-downtime deployments through graceful connection draining during pod termination. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +The shutdown manager sidecar coordinates graceful connection draining during pod termination, providing: |
| 10 | + |
| 11 | +- Zero-downtime rolling updates |
| 12 | +- Configurable drain timeouts |
| 13 | +- Automatic health check failure to remove pods from load balancer rotation |
| 14 | + |
| 15 | +### Shutdown Process |
| 16 | + |
| 17 | +1. Kubernetes sends SIGTERM to the pod |
| 18 | +2. Shutdown manager fails health checks via `/healthcheck/fail` |
| 19 | + - This causes Kubernetes readiness probes to fail |
| 20 | + - External load balancers and services stop routing new traffic to the pod |
| 21 | + - Existing connections continue to be served while draining |
| 22 | +3. Connection monitoring begins, polling `server.total_connections` |
| 23 | +4. Process exits when connections reach zero or drain timeout is exceeded |
| 24 | + |
| 25 | +## Configuration |
| 26 | + |
| 27 | +Graceful shutdown behavior includes default values that can be overridden using the EnvoyProxy resource. The EnvoyProxy resource can be referenced in two ways: |
| 28 | +1. **Gateway-level**: Referenced from a Gateway via `infrastructure.parametersRef` |
| 29 | +2. **GatewayClass-level**: Referenced from a GatewayClass via `parametersRef` |
| 30 | + |
| 31 | +**Default Values:** |
| 32 | +- `drainTimeout`: 60 seconds - Maximum time for connection draining |
| 33 | +- `minDrainDuration`: 10 seconds - Minimum wait before allowing exit |
| 34 | + |
| 35 | +{{< tabpane text=true >}} |
| 36 | +{{% tab header="Gateway-Level Configuration" %}} |
| 37 | + |
| 38 | +```yaml |
| 39 | +apiVersion: gateway.networking.k8s.io/v1 |
| 40 | +kind: Gateway |
| 41 | +metadata: |
| 42 | + name: eg |
| 43 | +spec: |
| 44 | + gatewayClassName: eg |
| 45 | + infrastructure: |
| 46 | + parametersRef: |
| 47 | + group: gateway.envoyproxy.io |
| 48 | + kind: EnvoyProxy |
| 49 | + name: graceful-shutdown-config |
| 50 | + listeners: |
| 51 | + - name: http |
| 52 | + port: 80 |
| 53 | + protocol: HTTP |
| 54 | +--- |
| 55 | +apiVersion: gateway.envoyproxy.io/v1alpha1 |
| 56 | +kind: EnvoyProxy |
| 57 | +metadata: |
| 58 | + name: graceful-shutdown-config |
| 59 | +spec: |
| 60 | + shutdown: |
| 61 | + drainTimeout: "90s" # Override default 60s |
| 62 | + minDrainDuration: "15s" # Override default 10s |
| 63 | +``` |
| 64 | +
|
| 65 | +{{% /tab %}} |
| 66 | +{{% tab header="GatewayClass-Level Configuration" %}} |
| 67 | +
|
| 68 | +```yaml |
| 69 | +apiVersion: gateway.networking.k8s.io/v1 |
| 70 | +kind: GatewayClass |
| 71 | +metadata: |
| 72 | + name: eg |
| 73 | +spec: |
| 74 | + controllerName: gateway.envoyproxy.io/gatewayclass-controller |
| 75 | + parametersRef: |
| 76 | + group: gateway.envoyproxy.io |
| 77 | + kind: EnvoyProxy |
| 78 | + name: graceful-shutdown-config |
| 79 | +--- |
| 80 | +apiVersion: gateway.envoyproxy.io/v1alpha1 |
| 81 | +kind: EnvoyProxy |
| 82 | +metadata: |
| 83 | + name: graceful-shutdown-config |
| 84 | +spec: |
| 85 | + shutdown: |
| 86 | + drainTimeout: "90s" # Override default 60s |
| 87 | + minDrainDuration: "15s" # Override default 10s |
| 88 | +``` |
| 89 | +
|
| 90 | +{{% /tab %}} |
| 91 | +{{< /tabpane >}} |
0 commit comments