Skip to content

Commit 010563b

Browse files
authored
Merge branch 'main' into feat/add-OverlappingTLSConfig-cond
2 parents 5cf4c85 + 385d5be commit 010563b

File tree

37 files changed

+2098
-83
lines changed

37 files changed

+2098
-83
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
ref: ${{ inputs.tag != '' && format('refs/tags/v{0}', inputs.tag) || github.ref }}
4141

4242
- name: Fetch Cached Artifacts
43-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
43+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
4444
with:
4545
path: ${{ github.workspace }}/dist
4646
key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }}
@@ -171,7 +171,7 @@ jobs:
171171
fail-build: false
172172

173173
- name: Upload scan result to GitHub Security tab
174-
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
174+
uses: github/codeql-action/upload-sarif@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
175175
continue-on-error: true
176176
with:
177177
sarif_file: ${{ steps.scan.outputs.sarif }}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ jobs:
184184
TELEMETRY_ENDPOINT_INSECURE: "false"
185185

186186
- name: Cache Artifacts
187-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
187+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
188188
with:
189189
path: ${{ github.workspace }}/dist
190190
key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }}

.github/workflows/helm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fetch-depth: 0
2626

2727
- name: Fetch Cached Artifacts
28-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
28+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
2929
with:
3030
path: ${{ github.workspace }}/dist
3131
key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }}

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ jobs:
6060

6161
# Upload the results to GitHub's code scanning dashboard.
6262
- name: "Upload to code-scanning"
63-
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
63+
uses: github/codeql-action/upload-sarif@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
6464
with:
6565
sarif_file: results.sarif

apis/v1alpha2/nginxproxy_types.go

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package v1alpha2
22

33
import (
4+
autoscalingv2 "k8s.io/api/autoscaling/v2"
45
corev1 "k8s.io/api/core/v1"
56
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
67
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -430,21 +431,26 @@ const (
430431

431432
// Deployment is the configuration for the NGINX Deployment.
432433
type DeploymentSpec struct {
433-
// Container defines container fields for the NGINX container.
434+
// Number of desired Pods.
434435
//
435436
// +optional
436-
Container ContainerSpec `json:"container"`
437+
Replicas *int32 `json:"replicas,omitempty"`
437438

438-
// Number of desired Pods.
439+
// Autoscaling defines the configuration for Horizontal Pod Autoscaling.
439440
//
440441
// +optional
441-
Replicas *int32 `json:"replicas,omitempty"`
442+
Autoscaling *AutoscalingSpec `json:"autoscaling,omitempty"`
442443

443444
// Pod defines Pod-specific fields.
444445
//
445446
// +optional
446447
Pod PodSpec `json:"pod"`
447448

449+
// Container defines container fields for the NGINX container.
450+
//
451+
// +optional
452+
Container ContainerSpec `json:"container"`
453+
448454
// Patches are custom patches to apply to the NGINX Deployment.
449455
//
450456
// +optional
@@ -469,6 +475,53 @@ type DaemonSetSpec struct {
469475
Patches []Patch `json:"patches,omitempty"`
470476
}
471477

478+
// AutoscalingSpec is the configuration for the Horizontal Pod Autoscaling.
479+
//
480+
// +kubebuilder:validation:XValidation:message="minReplicas must be less than or equal to maxReplicas",rule="(!has(self.minReplicas)) || (self.minReplicas <= self.maxReplicas)"
481+
//
482+
//nolint:lll
483+
type AutoscalingSpec struct {
484+
// Behavior configures the scaling behavior of the target
485+
// in both Up and Down directions (scaleUp and scaleDown fields respectively).
486+
// If not set, the default HPAScalingRules for scale up and scale down are used.
487+
//
488+
// +optional
489+
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
490+
491+
// Target cpu utilization percentage of HPA.
492+
//
493+
// +optional
494+
// +kubebuilder:validation:Minimum=1
495+
// +kubebuilder:validation:Maximum=100
496+
TargetCPUUtilizationPercentage *int32 `json:"targetCPUUtilizationPercentage,omitempty"`
497+
498+
// Target memory utilization percentage of HPA.
499+
//
500+
// +optional
501+
// +kubebuilder:validation:Minimum=1
502+
// +kubebuilder:validation:Maximum=100
503+
TargetMemoryUtilizationPercentage *int32 `json:"targetMemoryUtilizationPercentage,omitempty"`
504+
505+
// Minimum number of replicas.
506+
//
507+
// +optional
508+
// +kubebuilder:validation:Minimum=1
509+
MinReplicas *int32 `json:"minReplicas,omitempty"`
510+
511+
// Metrics configures additional metrics options.
512+
//
513+
// +optional
514+
Metrics []autoscalingv2.MetricSpec `json:"metrics,omitempty"`
515+
516+
// Maximum number of replicas.
517+
//
518+
// +kubebuilder:validation:Minimum=1
519+
MaxReplicas int32 `json:"maxReplicas"`
520+
521+
// Enable or disable Horizontal Pod Autoscaler.
522+
Enable bool `json:"enable"`
523+
}
524+
472525
// PodSpec defines Pod-specific fields.
473526
type PodSpec struct {
474527
// TerminationGracePeriodSeconds is the optional duration in seconds the pod needs to terminate gracefully.

apis/v1alpha2/zz_generated.deepcopy.go

Lines changed: 49 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/nginx-gateway-fabric/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,14 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
264264
| `certGenerator.ttlSecondsAfterFinished` | How long to wait after the cert generator job has finished before it is removed by the job controller. | int | `30` |
265265
| `clusterDomain` | The DNS cluster domain of your Kubernetes cluster. | string | `"cluster.local"` |
266266
| `gateways` | A list of Gateway objects. View https://gateway-api.sigs.k8s.io/reference/spec/#gateway for full Gateway reference. | list | `[]` |
267-
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"config":{},"container":{"hostPorts":[],"lifecycle":{},"readinessProbe":{},"resources":{},"volumeMounts":[]},"debug":false,"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","nginxOneConsole":{"dataplaneKeySecretName":"","endpointHost":"agent.connect.nginx.com","endpointPort":443,"skipVerify":false},"plus":false,"pod":{},"replicas":1,"service":{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","resolver":"","secretName":"nplus-license","skipVerify":false}}` |
267+
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"autoscaling":{"enable":false},"config":{},"container":{"hostPorts":[],"lifecycle":{},"readinessProbe":{},"resources":{},"volumeMounts":[]},"debug":false,"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","nginxOneConsole":{"dataplaneKeySecretName":"","endpointHost":"agent.connect.nginx.com","endpointPort":443,"skipVerify":false},"plus":false,"pod":{},"replicas":1,"service":{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","resolver":"","secretName":"nplus-license","skipVerify":false}}` |
268+
| `nginx.autoscaling` | Autoscaling configuration for the NGINX data plane. | object | `{"enable":false}` |
269+
| `nginx.autoscaling.enable` | Enable or disable Horizontal Pod Autoscaler for the NGINX data plane. | bool | `false` |
268270
| `nginx.config` | The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{}` |
269271
| `nginx.container` | The container configuration for the NGINX container. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{"hostPorts":[],"lifecycle":{},"readinessProbe":{},"resources":{},"volumeMounts":[]}` |
270272
| `nginx.container.hostPorts` | A list of HostPorts to expose on the host. This configuration allows containers to bind to a specific port on the host node, enabling external network traffic to reach the container directly through the host's IP address and port. Use this option when you need to expose container ports on the host for direct access, such as for debugging, legacy integrations, or when NodePort/LoadBalancer services are not suitable. Note: Using hostPort may have security and scheduling implications, as it ties pods to specific nodes and ports. | list | `[]` |
271273
| `nginx.container.lifecycle` | The lifecycle of the NGINX container. | object | `{}` |
272-
| `nginx.container.resources` | The resource requirements of the NGINX container. | object | `{}` |
274+
| `nginx.container.resources` | The resource requirements of the NGINX container. You should set this value if you want to use dataplane Autoscaling(HPA). | object | `{}` |
273275
| `nginx.container.volumeMounts` | volumeMounts are the additional volume mounts for the NGINX container. | list | `[]` |
274276
| `nginx.debug` | Enable debugging for NGINX. Uses the nginx-debug binary. The NGINX error log level should be set to debug in the NginxProxy resource. | bool | `false` |
275277
| `nginx.image.repository` | The NGINX image to use. | string | `"ghcr.io/nginx/nginx-gateway-fabric/nginx"` |
@@ -283,7 +285,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
283285
| `nginx.nginxOneConsole.skipVerify` | Skip TLS verification for NGINX One Console connections. | bool | `false` |
284286
| `nginx.plus` | Is NGINX Plus image being used. | bool | `false` |
285287
| `nginx.pod` | The pod configuration for the NGINX data plane pod. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{}` |
286-
| `nginx.replicas` | The number of replicas of the NGINX Deployment. | int | `1` |
288+
| `nginx.replicas` | The number of replicas of the NGINX Deployment. This value is ignored if autoscaling.enable is true. | int | `1` |
287289
| `nginx.service` | The service configuration for the NGINX data plane. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"}` |
288290
| `nginx.service.externalTrafficPolicy` | The externalTrafficPolicy of the service. The value Local preserves the client source IP. | string | `"Local"` |
289291
| `nginx.service.loadBalancerClass` | LoadBalancerClass is the class of the load balancer implementation this Service belongs to. Requires nginx.service.type set to LoadBalancer. | string | `""` |
@@ -297,8 +299,10 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
297299
| `nginx.usage.resolver` | The nameserver used to resolve the NGINX Plus usage reporting endpoint. Used with NGINX Instance Manager. | string | `""` |
298300
| `nginx.usage.secretName` | The name of the Secret containing the JWT for NGINX Plus usage reporting. Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway). | string | `"nplus-license"` |
299301
| `nginx.usage.skipVerify` | Disable client verification of the NGINX Plus usage reporting server certificate. | bool | `false` |
300-
| `nginxGateway` | The nginxGateway section contains configuration for the NGINX Gateway Fabric control plane deployment. | object | `{"affinity":{},"config":{"logging":{"level":"info"}},"configAnnotations":{},"extraVolumeMounts":[],"extraVolumes":[],"gatewayClassAnnotations":{},"gatewayClassName":"nginx","gatewayControllerName":"gateway.nginx.org/nginx-gateway-controller","gwAPIExperimentalFeatures":{"enable":false},"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric","tag":"edge"},"kind":"deployment","labels":{},"leaderElection":{"enable":true,"lockName":""},"lifecycle":{},"metrics":{"enable":true,"port":9113,"secure":false},"name":"","nodeSelector":{},"podAnnotations":{},"productTelemetry":{"enable":true},"readinessProbe":{"enable":true,"initialDelaySeconds":3,"port":8081},"replicas":1,"resources":{},"service":{"annotations":{},"labels":{}},"serviceAccount":{"annotations":{},"imagePullSecret":"","imagePullSecrets":[],"name":""},"snippetsFilters":{"enable":false},"terminationGracePeriodSeconds":30,"tolerations":[],"topologySpreadConstraints":[]}` |
302+
| `nginxGateway` | The nginxGateway section contains configuration for the NGINX Gateway Fabric control plane deployment. | object | `{"affinity":{},"autoscaling":{"enable":false},"config":{"logging":{"level":"info"}},"configAnnotations":{},"extraVolumeMounts":[],"extraVolumes":[],"gatewayClassAnnotations":{},"gatewayClassName":"nginx","gatewayControllerName":"gateway.nginx.org/nginx-gateway-controller","gwAPIExperimentalFeatures":{"enable":false},"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric","tag":"edge"},"kind":"deployment","labels":{},"leaderElection":{"enable":true,"lockName":""},"lifecycle":{},"metrics":{"enable":true,"port":9113,"secure":false},"name":"","nodeSelector":{},"podAnnotations":{},"productTelemetry":{"enable":true},"readinessProbe":{"enable":true,"initialDelaySeconds":3,"port":8081},"replicas":1,"resources":{},"service":{"annotations":{},"labels":{}},"serviceAccount":{"annotations":{},"imagePullSecret":"","imagePullSecrets":[],"name":""},"snippetsFilters":{"enable":false},"terminationGracePeriodSeconds":30,"tolerations":[],"topologySpreadConstraints":[]}` |
301303
| `nginxGateway.affinity` | The affinity of the NGINX Gateway Fabric control plane pod. | object | `{}` |
304+
| `nginxGateway.autoscaling` | Autoscaling configuration for the NGINX Gateway Fabric control plane. | object | `{"enable":false}` |
305+
| `nginxGateway.autoscaling.enable` | Enable or disable Horizontal Pod Autoscaler for the control plane. | bool | `false` |
302306
| `nginxGateway.config.logging.level` | Log level. | string | `"info"` |
303307
| `nginxGateway.configAnnotations` | Set of custom annotations for NginxGateway objects. | object | `{}` |
304308
| `nginxGateway.extraVolumeMounts` | extraVolumeMounts are the additional volume mounts for the nginx-gateway container. | list | `[]` |
@@ -324,7 +328,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
324328
| `nginxGateway.readinessProbe.enable` | Enable the /readyz endpoint on the control plane. | bool | `true` |
325329
| `nginxGateway.readinessProbe.initialDelaySeconds` | The number of seconds after the Pod has started before the readiness probes are initiated. | int | `3` |
326330
| `nginxGateway.readinessProbe.port` | Port in which the readiness endpoint is exposed. | int | `8081` |
327-
| `nginxGateway.replicas` | The number of replicas of the NGINX Gateway Fabric Deployment. | int | `1` |
331+
| `nginxGateway.replicas` | The number of replicas of the NGINX Gateway Fabric Deployment. This value is ignored if autoscaling.enable is true. | int | `1` |
328332
| `nginxGateway.resources` | The resource requests and/or limits of the nginx-gateway container. | object | `{}` |
329333
| `nginxGateway.service` | The service configuration for the NGINX Gateway Fabric control plane. | object | `{"annotations":{},"labels":{}}` |
330334
| `nginxGateway.service.annotations` | The annotations of the NGINX Gateway Fabric control plane service. | object | `{}` |

charts/nginx-gateway-fabric/templates/clusterrole.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ rules:
88
- apiGroups:
99
- ""
1010
- apps
11+
- autoscaling
1112
resources:
1213
- secrets
1314
- configmaps
1415
- serviceaccounts
1516
- services
1617
- deployments
1718
- daemonsets
19+
- horizontalpodautoscalers
1820
verbs:
1921
- create
2022
- update
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{{- if and (eq .Values.nginxGateway.kind "deployment") .Values.nginxGateway.autoscaling.enable -}}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
{{- with .Values.nginxGateway.autoscaling.annotations }}
6+
annotations: {{ toYaml . | nindent 4 }}
7+
{{- end }}
8+
labels:
9+
{{- include "nginx-gateway.labels" . | nindent 4 }}
10+
{{- with .Values.nginxGateway.labels }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
name: {{ include "nginx-gateway.fullname" . }}
14+
namespace: {{ .Release.Namespace }}
15+
spec:
16+
scaleTargetRef:
17+
apiVersion: apps/v1
18+
kind: Deployment
19+
name: {{ include "nginx-gateway.fullname" . }}
20+
{{- if .Values.nginxGateway.autoscaling.minReplicas }}
21+
minReplicas: {{ .Values.nginxGateway.autoscaling.minReplicas }}
22+
{{- end }}
23+
maxReplicas: {{ .Values.nginxGateway.autoscaling.maxReplicas }}
24+
metrics:
25+
{{- with .Values.nginxGateway.autoscaling.targetMemoryUtilizationPercentage }}
26+
- type: Resource
27+
resource:
28+
name: memory
29+
target:
30+
type: Utilization
31+
averageUtilization: {{ . }}
32+
{{- end }}
33+
{{- with .Values.nginxGateway.autoscaling.targetCPUUtilizationPercentage }}
34+
- type: Resource
35+
resource:
36+
name: cpu
37+
target:
38+
type: Utilization
39+
averageUtilization: {{ . }}
40+
{{- end }}
41+
{{- with .Values.nginxGateway.autoscaling.metrics }}
42+
{{- toYaml . | nindent 4 }}
43+
{{- end }}
44+
{{- with .Values.nginxGateway.autoscaling.behavior }}
45+
behavior:
46+
{{- toYaml . | nindent 4 }}
47+
{{- end }}
48+
{{- end }}

0 commit comments

Comments
 (0)