|
2 | 2 |
|
3 | 3 | This guide walks you through how to install NGINX Gateway Fabric on a generic Kubernetes cluster.
|
4 | 4 |
|
| 5 | +- [Installation](#installation) |
| 6 | + - [Prerequisites](#prerequisites) |
| 7 | + - [Deploy NGINX Gateway Fabric using Helm](#deploy-nginx-gateway-fabric-using-helm) |
| 8 | + - [Deploy NGINX Gateway Fabric from Manifests](#deploy-nginx-gateway-fabric-from-manifests) |
| 9 | + - [Expose NGINX Gateway Fabric](#expose-nginx-gateway-fabric) |
| 10 | + - [Create a NodePort Service](#create-a-nodeport-service) |
| 11 | + - [Create a LoadBalancer Service](#create-a-loadbalancer-service) |
| 12 | + - [Upgrading NGINX Gateway Fabric](#upgrading-nginx-gateway-fabric) |
| 13 | + - [Upgrade NGINX Gateway Fabric from Manifests](#upgrade-nginx-gateway-fabric-from-manifests) |
| 14 | + - [Upgrade NGINX Gateway Fabric using Helm](#upgrade-nginx-gateway-fabric-using-helm) |
| 15 | + - [Configure Delayed Termination for Zero Downtime Upgrades](#configure-delayed-termination-for-zero-downtime-upgrades) |
| 16 | + - [Configure Delayed Termination Using Manifests](#configure-delayed-termination-using-manifests) |
| 17 | + - [Configure Delayed Termination Using Helm](#configure-delayed-termination-using-helm) |
| 18 | + - [Uninstalling NGINX Gateway Fabric](#uninstalling-nginx-gateway-fabric) |
| 19 | + - [Uninstall NGINX Gateway Fabric from Manifests](#uninstall-nginx-gateway-fabric-from-manifests) |
| 20 | + - [Uninstall NGINX Gateway Fabric using Helm](#uninstall-nginx-gateway-fabric-using-helm) |
| 21 | + |
5 | 22 | ## Prerequisites
|
6 | 23 |
|
7 | 24 | - [kubectl](https://kubernetes.io/docs/tasks/tools/)
|
@@ -131,6 +148,10 @@ Create a Service with type `LoadBalancer` using the appropriate manifest for you
|
131 | 148 |
|
132 | 149 | ## Upgrading NGINX Gateway Fabric
|
133 | 150 |
|
| 151 | +> **Note** |
| 152 | +> See [below](#configure-delayed-termination-for-zero-downtime-upgrades) for instructions on how to configure delayed |
| 153 | +> termination if required for zero downtime upgrades in your environment. |
| 154 | +
|
134 | 155 | ### Upgrade NGINX Gateway Fabric from Manifests
|
135 | 156 |
|
136 | 157 | 1. Upgrade the Gateway Resources
|
@@ -168,6 +189,60 @@ Create a Service with type `LoadBalancer` using the appropriate manifest for you
|
168 | 189 | To upgrade NGINX Gateway Fabric when the deployment method is Helm, please follow the instructions
|
169 | 190 | [here](/deploy/helm-chart/README.md#upgrading-the-chart).
|
170 | 191 |
|
| 192 | +### Configure Delayed Termination for Zero Downtime Upgrades |
| 193 | + |
| 194 | +To achieve zero downtime upgrades (meaning clients will not see any interruption in traffic while a rolling upgrade is |
| 195 | +being performed on NGF), you may need to configure delayed termination on the NGF Pod, depending on your environment. |
| 196 | + |
| 197 | +> **Note** |
| 198 | +> When proxying Websocket or any long-lived connections, NGINX will not terminate until that connection is closed |
| 199 | +> by either the client or the backend. This means that unless all those connections are closed by clients/backends |
| 200 | +> before or during an upgrade, NGINX will not terminate, which means Kubernetes will kill NGINX. As a result, the |
| 201 | +> clients will see the connections abruptly closed and thus experience downtime. |
| 202 | + |
| 203 | +#### Configure Delayed Termination Using Manifests |
| 204 | + |
| 205 | +Edit the `deploy/manifests/nginx-gateway.yaml` to include the following: |
| 206 | + |
| 207 | +1. Add `lifecycle` prestop hooks to both the nginx and the nginx-gateway container definitions: |
| 208 | + |
| 209 | + ```yaml |
| 210 | + <...> |
| 211 | + name: nginx-gateway |
| 212 | + <...> |
| 213 | + lifecycle: |
| 214 | + preStop: |
| 215 | + exec: |
| 216 | + command: |
| 217 | + - /usr/bin/gateway |
| 218 | + - sleep |
| 219 | + - --duration=40s # This flag is optional, the default is 30s |
| 220 | + <...> |
| 221 | + name: nginx |
| 222 | + <...> |
| 223 | + lifecycle: |
| 224 | + preStop: |
| 225 | + exec: |
| 226 | + command: |
| 227 | + - /bin/sleep |
| 228 | + - "40" |
| 229 | + <...> |
| 230 | + ``` |
| 231 | + |
| 232 | +2. Ensure the `terminationGracePeriodSeconds` matches or exceeds the `sleep` value from the `preStopHook` (the default |
| 233 | + is 30). This is to ensure Kubernetes does not terminate the Pod before the `preStopHook` is complete. |
| 234 | + |
| 235 | +> **Note** |
| 236 | +> More information on container lifecycle hooks can be found |
| 237 | +> [here](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks) and a detailed |
| 238 | +> description of Pod termination behavior can be found in |
| 239 | +> [Termination of Pods](https://kubernetes.io/docs/concepts/workloads/Pods/Pod-lifecycle/#Pod-termination). |
| 240 | + |
| 241 | +#### Configure Delayed Termination Using Helm |
| 242 | + |
| 243 | +To configure delayed termination on the NGF Pod when the deployment method is Helm, please follow the instructions |
| 244 | +[here](/deploy/helm-chart/README.md#configure-delayed-termination-for-zero-downtime-upgrades). |
| 245 | + |
171 | 246 | ## Uninstalling NGINX Gateway Fabric
|
172 | 247 |
|
173 | 248 | ### Uninstall NGINX Gateway Fabric from Manifests
|
|
0 commit comments