github.com/projectcontour/contour@v1.28.2/site/content/docs/1.23/redeploy-envoy.md (about)

     1  # Redeploying Envoy
     2  
     3  The Envoy process, the data path component of Contour, at times needs to be re-deployed.
     4  This could be due to an upgrade, a change in configuration, or a node-failure forcing a redeployment.
     5  
     6  When implementing this roll out, the following steps should be taken:
     7  
     8  1. Stop Envoy from accepting new connections
     9  2. Start draining existing connections in Envoy by sending a `POST` request to `/healthcheck/fail` endpoint
    10  3. Wait for connections to drain before allowing Kubernetes to `SIGTERM` the pod
    11  
    12  ## Overview
    13  
    14  Contour implements an `envoy` sub-command named `shutdown-manager` whose job is to manage a single Envoy instances lifecycle for Kubernetes.
    15  The `shutdown-manager` runs as a new container alongside the Envoy container in the same pod.
    16  It exposes two HTTP endpoints which are used for `livenessProbe` as well as to handle the Kubernetes `preStop` event hook.
    17  
    18  - **livenessProbe**: This is used to validate the shutdown manager is still running properly. If requests to `/healthz` fail, the container will be restarted.
    19  - **preStop**: This is used to keep the Envoy container running while waiting for connections to drain. The `/shutdown` endpoint blocks until the connections are drained.
    20  
    21  ```yaml
    22   - name: shutdown-manager
    23     command:
    24     - /bin/contour
    25     args:
    26       - envoy
    27       - shutdown-manager
    28     image: ghcr.io/projectcontour/contour:main
    29     imagePullPolicy: Always
    30     lifecycle:
    31       preStop:
    32         exec:
    33           command:
    34             - /bin/contour
    35             - envoy
    36             - shutdown
    37     livenessProbe:
    38       httpGet:
    39         path: /healthz
    40         port: 8090
    41       initialDelaySeconds: 3
    42       periodSeconds: 10
    43  ```
    44  
    45  The Envoy container also has some configuration to implement the shutdown manager.
    46  First the `preStop` hook is configured to use the `/shutdown` endpoint which blocks the Envoy container from exiting.
    47  Finally, the pod's `terminationGracePeriodSeconds` is customized to extend the time in which Kubernetes will allow the pod to be in the `Terminating` state.
    48  The termination grace period defines an upper bound for long-lived sessions.
    49  If during shutdown, the connections aren't drained to the configured amount, the `terminationGracePeriodSeconds` will send a `SIGTERM` to the pod killing it.
    50  
    51  ![shutdown-manager overview][1]
    52  
    53  ### Shutdown Manager Config Options
    54  
    55  The `shutdown-manager` runs as another container in the Envoy pod.
    56  When the pod is requested to terminate, the `preStop` hook on the `shutdown-manager` executes the `contour envoy shutdown` command initiating the shutdown sequence.
    57  
    58  The shutdown manager has a single argument that can be passed to change how it behaves:
    59  
    60  | Name | Type | Default | Description |
    61  |------------|------|---------|-------------|
    62  | <nobr>serve-port</nobr> | integer | 8090 | Port to serve the http server on |
    63  | <nobr>ready-file</nobr> | string | /admin/ok | File to poll while waiting shutdown to be completed. |
    64  
    65  ### Shutdown Config Options
    66  
    67  The `shutdown` command does the work of draining connections from Envoy and polling for open connections.
    68  
    69  The shutdown command has a few arguments that can be passed to change how it behaves:
    70  
    71  | Name | Type | Default | Description |
    72  |------------|------|---------|-------------|
    73  | <nobr>check-interval</nobr> | duration | 5s | Time interval to poll Envoy for open connections. |
    74  | <nobr>check-delay</nobr> | duration | 0s | Time wait before polling Envoy for open connections. |
    75  | <nobr>drain-delay</nobr> | duration | 0s | Time wait before draining Envoy connections. |
    76  | <nobr>min-open-connections</nobr> | integer | 0 | Min number of open connections when polling Envoy. |
    77  | <nobr>admin-port (Deprecated)</nobr> | integer | 9001 | Deprecated: No longer used, Envoy admin interface runs as a unix socket.  |
    78  | <nobr>admin-address</nobr> | string | /admin/admin.sock | Path to Envoy admin unix domain socket. |
    79  | <nobr>ready-file</nobr> | string | /admin/ok | File to write when shutdown is completed. |
    80  
    81    [1]: ../img/shutdownmanager.png