Skip to content

Commit 4956a0c

Browse files
committed
Merge branch 'main' into waf/refactor
2 parents 94550d2 + 9521432 commit 4956a0c

File tree

23 files changed

+686
-107
lines changed

23 files changed

+686
-107
lines changed

content/includes/nic/compatibility-tables/nic-nap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ The following table shows compatibility between NGINX Ingress Controller (NIC) a
33
{{< bootstrap-table "table table-striped table-responsive" >}}
44
| NIC Version | NAP-WAF Version | Config Manager | Enforcer |
55
| ------------------- | --------------- | -------------- | -------- |
6-
| {{< nic-version >}} | 34+5.332 | 5.6.0 | 5.6.0 |
6+
| {{< nic-version >}} | 35+5.498 | 5.8.0 | 5.8.0 |
77
| 4.0.1 | 33+5.264 | 5.5.0 | 5.5.0 |
88
| 3.7.2 | 32+5.1 | 5.3.0 | 5.3.0 |
99
| 3.6.2 | 32+5.48 | 5.2.0 | 5.2.0 |

content/ngf/how-to/data-plane-configuration.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,3 +375,128 @@ To view the full list of configuration options, see the `NginxProxy spec` in the
375375

376376
---
377377

378+
### Patch data plane Service, Deployment, and DaemonSet
379+
380+
NGINX Gateway Fabric supports advanced customization of the data plane Service, Deployment, and DaemonSet objects using patches in the `NginxProxy` resource. This allows you to apply Kubernetes-style patches to these resources, enabling custom labels, annotations, or other modifications that are not directly exposed via the NginxProxy spec.
381+
382+
#### Supported Patch Types
383+
384+
You can specify one or more patches for each of the following resources:
385+
386+
- `spec.kubernetes.service.patches`
387+
- `spec.kubernetes.deployment.patches`
388+
- `spec.kubernetes.daemonSet.patches`
389+
390+
Each patch has two fields:
391+
392+
- `type`: The patch type. Supported values are:
393+
- `StrategicMerge` (default): Strategic merge patch (Kubernetes default for most resources)
394+
- `Merge`: JSON merge patch (RFC 7386)
395+
- `JSONPatch`: JSON patch (RFC 6902)
396+
- `value`: The patch data. For `StrategicMerge` and `Merge`, this should be a JSON object. For `JSONPatch`, this should be a JSON array of patch operations.
397+
398+
Patches are applied in the order they appear in the array. Later patches can override fields set by earlier patches.
399+
400+
#### Example: Configure Service with session affinity
401+
402+
```yaml
403+
apiVersion: gateway.nginx.org/v1alpha2
404+
kind: NginxProxy
405+
metadata:
406+
name: ngf-proxy-patch-service
407+
spec:
408+
kubernetes:
409+
service:
410+
patches:
411+
- type: StrategicMerge
412+
value:
413+
spec:
414+
sessionAffinity: ClientIP
415+
sessionAffinityConfig:
416+
clientIP:
417+
timeoutSeconds: 300
418+
```
419+
420+
#### Example: Configure Deployment with custom strategy
421+
422+
```yaml
423+
apiVersion: gateway.nginx.org/v1alpha2
424+
kind: NginxProxy
425+
metadata:
426+
name: ngf-proxy-patch-deployment
427+
spec:
428+
kubernetes:
429+
deployment:
430+
patches:
431+
- type: Merge
432+
value:
433+
spec:
434+
strategy:
435+
type: RollingUpdate
436+
rollingUpdate:
437+
maxUnavailable: 0
438+
maxSurge: 2
439+
```
440+
441+
#### Example: Use JSONPatch to configure DaemonSet host networking and priority
442+
443+
```yaml
444+
apiVersion: gateway.nginx.org/v1alpha2
445+
kind: NginxProxy
446+
metadata:
447+
name: ngf-proxy-patch-daemonset
448+
spec:
449+
kubernetes:
450+
daemonSet:
451+
patches:
452+
- type: JSONPatch
453+
value:
454+
- op: add
455+
path: /spec/template/spec/hostNetwork
456+
value: true
457+
- op: add
458+
path: /spec/template/spec/dnsPolicy
459+
value: "ClusterFirstWithHostNet"
460+
- op: add
461+
path: /spec/template/spec/priorityClassName
462+
value: "system-node-critical"
463+
```
464+
465+
#### Example: Multiple patches, later patch overrides earlier
466+
467+
```yaml
468+
apiVersion: gateway.nginx.org/v1alpha2
469+
kind: NginxProxy
470+
metadata:
471+
name: ngf-proxy-multi-patch
472+
spec:
473+
kubernetes:
474+
service:
475+
patches:
476+
- type: StrategicMerge
477+
value:
478+
spec:
479+
sessionAffinity: ClientIP
480+
publishNotReadyAddresses: false
481+
- type: StrategicMerge
482+
value:
483+
spec:
484+
sessionAffinity: None
485+
publishNotReadyAddresses: true
486+
```
487+
488+
In this example, the final Service will have `sessionAffinity: None` and `publishNotReadyAddresses: true` because the second patch overrides the values from the first patch.
489+
490+
{{< note >}}
491+
**Which patch type should I use?**
492+
493+
- **StrategicMerge** is the default and most user-friendly for Kubernetes-native resources like Deployments and Services. It understands lists and merges fields intelligently (e.g., merging containers by name). Use this for most use cases.
494+
- **Merge** (JSON Merge Patch) is simpler and works well for basic object merges, but does not handle lists or complex merging. Use this if you want to replace entire fields or for non-Kubernetes-native resources.
495+
- **JSONPatch** is the most powerful and flexible, allowing you to add, remove, or replace specific fields using RFC 6902 operations. Use this for advanced or fine-grained changes, but it is more verbose and error-prone.
496+
497+
If unsure, start with StrategicMerge. Use JSONPatch only if you need to surgically modify fields that cannot be addressed by the other patch types.
498+
499+
Patches are applied after all other NginxProxy configuration is rendered. Invalid patches will result in a validation error and will not be applied.
500+
{{< /note >}}
501+
502+
---

content/ngf/how-to/scaling.md

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,64 @@ It provides guidance on how to scale each plane effectively, and when you should
1616

1717
The data plane is the NGINX deployment that handles user traffic to backend applications. Every Gateway object created provisions its own NGINX deployment and configuration.
1818

19-
You have two options for scaling the data plane:
19+
You have multiple options for scaling the data plane:
2020

21+
- Increasing the number of [worker connections](https://nginx.org/en/docs/ngx_core_module.html#worker_connections) for an existing deployment
2122
- Increasing the number of replicas for an existing deployment
2223
- Creating a new Gateway for a new data plane
2324

24-
#### When to increase replicas or create a new Gateway
25+
#### When to increase worker connections, replicas, or create a new Gateway
2526

26-
Understanding when to increase replicas or create a new Gateway is key to managing traffic effectively.
27+
Understanding when to increase worker connections, replicas, or create a new Gateway is key to managing traffic effectively.
2728

28-
Increasing data plane replicas is ideal when you need to handle more traffic without changing the configuration.
29+
Increasing worker connections or replicas is ideal when you need to handle more traffic without changing the overall routing configuration. Setting the worker connections field allows a single NGINX data plane instance to handle more connections without needing to scale the replicas. However, scaling the replicas can be beneficial to reduce single points of failure.
2930

30-
For example, if you're routing traffic to `api.example.com` and notice an increase in load, you can scale the replicas from 1 to 5 to better distribute the traffic and reduce latency.
31+
Scaling replicas can be done manually or automatically using a [Horizontal Pod Autoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) (HPA).
3132

32-
All replicas will share the same configuration from the Gateway used to set up the data plane, simplifying configuration management.
33+
To update worker connections (default: 1024), replicas, or enable autoscaling, you can edit the `NginxProxy` resource:
3334

34-
There are two ways to modify the number of replicas for an NGINX deployment:
35+
```shell
36+
kubectl edit nginxproxies.gateway.nginx.org ngf-proxy-config -n nginx-gateway
37+
```
3538

36-
First, at the time of installation you can modify the field `nginx.replicas` in the `values.yaml` or add the `--set nginx.replicas=` flag to the `helm install` command:
39+
{{< call-out "note" >}}
3740

38-
```shell
39-
helm install ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric --create-namespace -n nginx-gateway --set nginx.replicas=5
41+
The NginxProxy resource in this example lives in the control plane namespace (default: `nginx-gateway`) and applies to the GatewayClass, but you can also define one per Gateway. See the [Data plane configuration]({{< ref "/ngf/how-to/data-plane-configuration.md" >}}) document for more information.
42+
43+
{{< /call-out >}}
44+
45+
- Worker connections is set using the `workerConnections` field:
46+
47+
```yaml
48+
spec:
49+
workerConnections: 4096
4050
```
4151
42-
Secondly, you can update the `NginxProxy` resource while NGINX is running to modify the `kubernetes.deployment.replicas` field and scale the data plane deployment dynamically:
52+
- Replicas are set using the `kubernetes.deployment.replicas` field:
4353

44-
```shell
45-
kubectl edit nginxproxies.gateway.nginx.org ngf-proxy-config -n nginx-gateway
54+
```yaml
55+
spec:
56+
kubernetes:
57+
deployment:
58+
replicas: 3
59+
```
60+
61+
- Autoscaling can be enabled using the `kubernetes.deployment.autoscaling` field. The default `replicas` value will be used until the Horizontal Pod Autoscaler is running.
62+
63+
```yaml
64+
spec:
65+
kubernetes:
66+
deployment:
67+
autoscaling:
68+
enable: true
69+
maxReplicas: 10
4670
```
4771

48-
The alternate way to scale the data plane is by creating a new Gateway. This is beneficial when you need distinct configurations, isolation, or separate policies.
72+
See the `NginxProxy` section of the [API reference]({{< ref "/ngf/reference/api.md" >}}) for the full specification.
73+
74+
All of these fields are also available at installation time by setting them in the [helm values](https://github.com/nginx/nginx-gateway-fabric/blob/main/charts/nginx-gateway-fabric/values.yaml).
75+
76+
An alternate way to scale the data plane is by creating a new Gateway. This is beneficial when you need distinct configurations, isolation, or separate policies.
4977

5078
For example, if you're routing traffic to a new domain `admin.example.com` and require a different TLS certificate, stricter rate limits, or separate authentication policies, creating a new Gateway could be a good approach.
5179

@@ -60,7 +88,9 @@ Scaling the control plane can be beneficial in the following scenarios:
6088
1. _Higher availability_ - When a control plane pod crashes, runs out of memory, or goes down during an upgrade, it can interrupt configuration delivery. By scaling to multiple replicas, another pod can quickly step in and take over, keeping things running smoothly with minimal downtime.
6189
1. _Faster configuration distribution_ - As the number of connected NGINX instances grows, a single control plane pod may become a bottleneck in handling connections or streaming configuration updates. Scaling the control plane improves concurrency and responsiveness when delivering configuration over gRPC.
6290

63-
To scale the control plane, use the `kubectl scale` command on the control plane deployment to increase or decrease the number of replicas. For example, the following command scales the control plane deployment to 3 replicas:
91+
To automatically scale the control plane, you can create a [Horizontal Pod Autoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) (HPA) in the control plane namespace (default: `nginx-gateway`). At installation time, the [NGINX Gateway Fabric helm chart](https://github.com/nginx/nginx-gateway-fabric/blob/main/charts/nginx-gateway-fabric/values.yaml) allows you to set the HPA configuration in the `nginxGateway.autoscaling` section, which will provision an HPA for you. If NGINX Gateway Fabric is already running, then you can manually define the HPA and deploy it.
92+
93+
To manually scale the control plane, use the `kubectl scale` command on the control plane deployment to increase or decrease the number of replicas. For example, the following command scales the control plane deployment to 3 replicas:
6494

6595
```shell
6696
kubectl scale deployment -n nginx-gateway ngf-nginx-gateway-fabric --replicas 3

content/ngf/install/upgrade-version.md

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ It covers the necessary steps for minor versions as well as major versions (such
1313

1414
Many of the nuances in upgrade paths relate to how custom resource definitions (CRDs) are managed.
1515

16-
{{< call-out "tip" >}}
1716

18-
To avoid interruptions, review the [Delay pod termination for zero downtime upgrades](#configure-delayed-pod-termination-for-zero-downtime-upgrades) section.
17+
## Minor NGINX Gateway Fabric upgrades
1918

19+
{{< call-out "important" >}}
20+
Upgrading from v2.0.x to v2.1 requires the NGINX Gateway Fabric control plane to be uninstalled and then reinstalled to avoid any downtime to user traffic. CRDs do not need to be removed. The NGINX data plane deployment is not affected by this process, and traffic should still flow uninterrupted. The steps are described below.
2021
{{< /call-out >}}
2122

22-
23-
## Minor NGINX Gateway Fabric upgrades
24-
2523
{{< call-out "important" >}} NGINX Plus users need a JWT secret before upgrading from version 1.4.0 to 1.5.x.
2624

2725
Follow the steps in [Set up the JWT]({{< ref "/ngf/install/nginx-plus.md#set-up-the-jwt" >}}) to create the Secret.
@@ -72,14 +70,23 @@ Warning: kubectl apply should be used on resource created by either kubectl crea
7270

7371
{{% tab name="Helm" %}}
7472

75-
{{< call-out "important" >}} If you are using NGINX Plus and have a different Secret name than the default `nplus-license` name, specify the Secret name by setting `--set nginx.usage.secretName=<secret-name>` when running `helm upgrade`. {{< /call-out >}}
73+
{{< call-out "important" >}} If you are using NGINX Plus and have a different Secret name than the default `nplus-license` name, specify the Secret name by setting `--set nginx.usage.secretName=<secret-name>` when running `helm install` or `helm upgrade`. {{< /call-out >}}
7674

7775
To upgrade the release with Helm, you can use the OCI registry, or download the chart and upgrade from the source.
7876

7977
If needed, replace `ngf` with your chosen release name.
8078

8179
**Upgrade from the OCI registry**
8280

81+
To avoid downtime when upgrading from v2.0.x to v2.1, run the following commands. Be sure to include your previous installation flags and values if necessary. This will not affect user traffic, as the NGINX data plane deployment won't be removed as part of this process.
82+
83+
```shell
84+
helm uninstall ngf -n nginx-gateway
85+
helm install ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric -n nginx-gateway
86+
```
87+
88+
Otherwise, for all other version upgrades:
89+
8390
```shell
8491
helm upgrade ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric -n nginx-gateway
8592
```
@@ -88,7 +95,14 @@ helm upgrade ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric -n nginx-gatewa
8895

8996
{{< include "/ngf/installation/helm/pulling-the-chart.md" >}}
9097

91-
To upgrade, run the following command:
98+
To avoid downtime when upgrading from v2.0.x to v2.1, run the following. Be sure to include your previous installation flags and values if necessary. This will not affect user traffic, as the NGINX data plane deployment won't be removed as part of this process.
99+
100+
```shell
101+
helm uninstall ngf -n nginx-gateway
102+
helm install ngf . -n nginx-gateway
103+
```
104+
105+
Otherwise, for all other version upgrades:
92106

93107
```shell
94108
helm upgrade ngf . -n nginx-gateway
@@ -98,7 +112,9 @@ helm upgrade ngf . -n nginx-gateway
98112

99113
{{% tab name="Manifests" %}}
100114

101-
Select the deployment manifest that matches your current deployment from options available in the [Deploy NGINX Gateway Fabric]({{< ref "/ngf/install/manifests.md#deploy-nginx-gateway-fabric-1">}}) section and apply it.
115+
Select the deployment manifest that matches your current deployment from options available in the [Deploy NGINX Gateway Fabric]({{< ref "/ngf/install/manifests.md#deploy-nginx-gateway-fabric-1">}}) section.
116+
117+
To avoid downtime when upgrading from v2.0.x to v2.1, delete the previous NGINX Gateway Fabric control plane deployment in the `nginx-gateway` namespace, using `kubectl delete deployment`. Then `kubectl apply` the updated manifest file. This will not affect user traffic, as the NGINX data plane deployment won't be removed as part of this process.
102118

103119
{{% /tab %}}
104120

@@ -259,50 +275,3 @@ To upgrade from NGINX Open Source to NGINX Plus, update the Helm command to incl
259275
```shell
260276
helm upgrade ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric --set nginx.image.repository=private-registry.nginx.com/nginx-gateway-fabric/nginx-plus --set nginx.plus=true --set nginx.imagePullSecret=nginx-plus-registry-secret -n nginx-gateway
261277
```
262-
263-
## Delay pod termination for zero downtime upgrades {#configure-delayed-pod-termination-for-zero-downtime-upgrades}
264-
265-
{{< include "/ngf/installation/delay-pod-termination/delay-pod-termination-overview.md" >}}
266-
267-
Follow these steps to configure delayed pod termination:
268-
269-
1. Open the `values.yaml` for editing.
270-
271-
1. **Add delayed shutdown hooks**:
272-
273-
- In the `values.yaml` file, add `lifecycle: preStop` hooks to both the `nginx` and `nginx-gateway` container definitions. These hooks instruct the containers to delay their shutdown process, allowing time for connections to close gracefully. Update the `sleep` value to what works for your environment.
274-
275-
```yaml
276-
nginxGateway:
277-
<...>
278-
lifecycle:
279-
preStop:
280-
exec:
281-
command:
282-
- /usr/bin/gateway
283-
- sleep
284-
- --duration=40s # This flag is optional, the default is 30s
285-
286-
nginx:
287-
<...>
288-
lifecycle:
289-
preStop:
290-
exec:
291-
command:
292-
- /bin/sleep
293-
- "40"
294-
```
295-
296-
1. **Set the termination grace period**:
297-
298-
- {{< include "/ngf/installation/delay-pod-termination/termination-grace-period.md">}}
299-
300-
1. Save the changes.
301-
302-
{{< call-out "note" >}}
303-
For additional information on configuring and understanding the behavior of containers and pods during their lifecycle, refer to the following Kubernetes documentation:
304-
305-
- [Container Lifecycle Hooks](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks)
306-
- [Pod Lifecycle](https://kubernetes.io/docs/concepts/workloads/Pods/Pod-lifecycle/#Pod-termination)
307-
308-
{{< /call-out>}}

content/ngf/overview/gateway-api-compatibility.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ See the [controller]({{< ref "/ngf/reference/cli-help.md#controller">}}) command
136136
- `ResolvedRefs/True/ResolvedRefs`
137137
- `ResolvedRefs/False/InvalidCertificateRef`
138138
- `ResolvedRefs/False/InvalidRouteKinds`
139+
- `ResolvedRefs/False/RefNotPermitted`
139140
- `Conflicted/True/ProtocolConflict`
140141
- `Conflicted/True/HostnameConflict`
141142
- `Conflicted/False/NoConflicts`
143+
- `OverlappingTLSConfig/True/OverlappingHostnames`
142144

143145
### HTTPRoute
144146

@@ -167,7 +169,7 @@ See the [controller]({{< ref "/ngf/reference/cli-help.md#controller">}}) command
167169
- `requestHeaderModifier`: Supported. If multiple filters are configured, NGINX Gateway Fabric will choose the first and ignore the rest.
168170
- `urlRewrite`: Supported. If multiple filters are configured, NGINX Gateway Fabric will choose the first and ignore the rest. Incompatible with `requestRedirect`.
169171
- `responseHeaderModifier`: Supported. If multiple filters are configured, NGINX Gateway Fabric will choose the first and ignore the rest.
170-
- `requestMirror`: Supported. Multiple mirrors can be specified.
172+
- `requestMirror`: Supported. Multiple mirrors can be specified. Percent and fraction-based mirroring are supported.
171173
- `extensionRef`: Supported for SnippetsFilters.
172174
- `backendRefs`: Partially supported. Backend ref `filters` are not supported.
173175
- `status`
@@ -189,6 +191,7 @@ See the [controller]({{< ref "/ngf/reference/cli-help.md#controller">}}) command
189191
- `ResolvedRefs/False/BackendNotFound`
190192
- `ResolvedRefs/False/UnsupportedValue`: Custom reason for when one of the HTTPRoute rules has a backendRef with an unsupported value.
191193
- `ResolvedRefs/False/InvalidIPFamily`: Custom reason for when one of the HTTPRoute rules has a backendRef that has an invalid IPFamily.
194+
- `ResolvedRefs/False/UnsupportedProtocol`
192195
- `PartiallyInvalid/True/UnsupportedValue`
193196

194197
### GRPCRoute

0 commit comments

Comments
 (0)