Skip to content

Commit aff80d8

Browse files
committed
Code Review
1 parent 29d48e3 commit aff80d8

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ type DaemonSetSpec struct {
468468

469469
// HPASpec is the configuration for the Horizontal Pod Autoscaling.
470470
//
471-
// +kubebuilder:message="at least one metric must be specified when autoscaling is enabled",rule="!self.enabled || (has(self.targetCPUUtilizationPercentage) || has(self.targetMemoryUtilizationPercentage) || (has(self.autoscalingTemplate) && size(self.autoscalingTemplate) > 0))"
472-
// +kubebuilder:message="minReplicas must be less than or equal to maxReplicas",rule="self.minReplicas <= self.maxReplicas"
473-
// +kubebuilder:message="CPU utilization must be between 1 and 100",rule="!has(self.targetCPUUtilizationPercentage) || (self.targetCPUUtilizationPercentage >= 1 && self.targetCPUUtilizationPercentage <= 100)"
474-
// +kubebuilder:message="memory utilization must be between 1 and 100",rule="!has(self.targetMemoryUtilizationPercentage) || (self.targetMemoryUtilizationPercentage >= 1 && self.targetMemoryUtilizationPercentage <= 100)"
471+
// +kubebuilder:validation:XValidation:message="at least one metric must be specified when autoscaling is enabled",rule="!self.enabled || (has(self.targetCPUUtilizationPercentage) || has(self.targetMemoryUtilizationPercentage) || (has(self.autoscalingTemplate) && size(self.autoscalingTemplate) > 0))"
472+
// +kubebuilder:validation:XValidation:message="minReplicas must be less than or equal to maxReplicas",rule="self.minReplicas <= self.maxReplicas"
473+
// +kubebuilder:validation:XValidation:message="CPU utilization must be between 1 and 100",rule="!has(self.targetCPUUtilizationPercentage) || (self.targetCPUUtilizationPercentage >= 1 && self.targetCPUUtilizationPercentage <= 100)"
474+
// +kubebuilder:validation:XValidation:message="memory utilization must be between 1 and 100",rule="!has(self.targetMemoryUtilizationPercentage) || (self.targetMemoryUtilizationPercentage >= 1 && self.targetMemoryUtilizationPercentage <= 100)"
475475
//
476476
//nolint:lll
477477
type HPASpec struct {

charts/nginx-gateway-fabric/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
269269
| `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":[]}` |
270270
| `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 | `[]` |
271271
| `nginx.container.lifecycle` | The lifecycle of the NGINX container. | object | `{}` |
272-
| `nginx.container.resources` | The resource requirements of the NGINX container. You should be set this value, If you want to use dataplane Autoscaling(HPA). | object | `{}` |
272+
| `nginx.container.resources` | The resource requirements of the NGINX container. You should set this value if you want to use dataplane Autoscaling(HPA). | object | `{}` |
273273
| `nginx.container.volumeMounts` | volumeMounts are the additional volume mounts for the NGINX container. | list | `[]` |
274274
| `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` |
275275
| `nginx.image.repository` | The NGINX image to use. | string | `"ghcr.io/nginx/nginx-gateway-fabric/nginx"` |

charts/nginx-gateway-fabric/values.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@
380380
"type": "object"
381381
},
382382
"resources": {
383-
"description": "The resource requirements of the NGINX container. You should be set this value, If you want to use dataplane Autoscaling(HPA).",
383+
"description": "The resource requirements of the NGINX container. You should set this value if you want to use dataplane Autoscaling(HPA).",
384384
"required": [],
385385
"title": "resources",
386386
"type": "object"

charts/nginx-gateway-fabric/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ nginxGateway:
184184
# - type: Pods
185185
# pods:
186186
# metric:
187-
# name: nginx_gateway_fabric_nginx_process_requests_total
187+
# name: http_requests
188188
# target:
189189
# type: AverageValue
190-
# averageValue: 10000m
190+
# averageValue: "100"
191191

192192
metrics:
193193
# -- Enable exposing metrics in the Prometheus format.
@@ -494,7 +494,7 @@ nginx:
494494
# - port: 80
495495
# containerPort: 80
496496

497-
# -- The resource requirements of the NGINX container. You should be set this value, If you want to use dataplane Autoscaling(HPA).
497+
# -- The resource requirements of the NGINX container. You should set this value if you want to use dataplane Autoscaling(HPA).
498498
resources: {}
499499

500500
# -- The lifecycle of the NGINX container.

config/crd/bases/gateway.nginx.org_nginxproxies.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,6 +4192,20 @@ spec:
41924192
- enabled
41934193
- maxReplicas
41944194
type: object
4195+
x-kubernetes-validations:
4196+
- message: at least one metric must be specified when autoscaling
4197+
is enabled
4198+
rule: '!self.enabled || (has(self.targetCPUUtilizationPercentage)
4199+
|| has(self.targetMemoryUtilizationPercentage) || (has(self.autoscalingTemplate)
4200+
&& size(self.autoscalingTemplate) > 0))'
4201+
- message: minReplicas must be less than or equal to maxReplicas
4202+
rule: self.minReplicas <= self.maxReplicas
4203+
- message: CPU utilization must be between 1 and 100
4204+
rule: '!has(self.targetCPUUtilizationPercentage) || (self.targetCPUUtilizationPercentage
4205+
>= 1 && self.targetCPUUtilizationPercentage <= 100)'
4206+
- message: memory utilization must be between 1 and 100
4207+
rule: '!has(self.targetMemoryUtilizationPercentage) || (self.targetMemoryUtilizationPercentage
4208+
>= 1 && self.targetMemoryUtilizationPercentage <= 100)'
41954209
container:
41964210
description: Container defines container fields for the NGINX
41974211
container.

deploy/crds.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4777,6 +4777,20 @@ spec:
47774777
- enabled
47784778
- maxReplicas
47794779
type: object
4780+
x-kubernetes-validations:
4781+
- message: at least one metric must be specified when autoscaling
4782+
is enabled
4783+
rule: '!self.enabled || (has(self.targetCPUUtilizationPercentage)
4784+
|| has(self.targetMemoryUtilizationPercentage) || (has(self.autoscalingTemplate)
4785+
&& size(self.autoscalingTemplate) > 0))'
4786+
- message: minReplicas must be less than or equal to maxReplicas
4787+
rule: self.minReplicas <= self.maxReplicas
4788+
- message: CPU utilization must be between 1 and 100
4789+
rule: '!has(self.targetCPUUtilizationPercentage) || (self.targetCPUUtilizationPercentage
4790+
>= 1 && self.targetCPUUtilizationPercentage <= 100)'
4791+
- message: memory utilization must be between 1 and 100
4792+
rule: '!has(self.targetMemoryUtilizationPercentage) || (self.targetMemoryUtilizationPercentage
4793+
>= 1 && self.targetMemoryUtilizationPercentage <= 100)'
47804794
container:
47814795
description: Container defines container fields for the NGINX
47824796
container.

0 commit comments

Comments
 (0)