Skip to content

Commit f686a2d

Browse files
committed
Code Review
1 parent 81f5d6a commit f686a2d

File tree

15 files changed

+88
-137
lines changed

15 files changed

+88
-137
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ type DaemonSetSpec struct {
466466
Patches []Patch `json:"patches,omitempty"`
467467
}
468468

469+
// +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))"
470+
// +kubebuilder:validation:XValidation:message="minReplicas must be less than or equal to maxReplicas",rule="self.minReplicas <= self.maxReplicas"
471+
// +kubebuilder:validation:XValidation:message="CPU utilization must be between 1 and 100",rule="!has(self.targetCPUUtilizationPercentage) || (self.targetCPUUtilizationPercentage >= 1 && self.targetCPUUtilizationPercentage <= 100)"
472+
// +kubebuilder:validation:XValidation:message="memory utilization must be between 1 and 100",rule="!has(self.targetMemoryUtilizationPercentage) || (self.targetMemoryUtilizationPercentage >= 1 && self.targetMemoryUtilizationPercentage <= 100)"
473+
//
474+
//nolint:lll
469475
type HPASpec struct {
470476
// Behavior configures the scaling behavior of the target
471477
// in both Up and Down directions (scaleUp and scaleDown fields respectively).

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spec:
1515
{{- if .Values.nginx.replicas }}
1616
replicas: {{ .Values.nginx.replicas }}
1717
{{- end }}
18+
{{- if .Values.nginx.autoscaling.enabled }}
1819
autoscaling:
1920
enabled: {{ .Values.nginx.autoscaling.enabled }}
2021
{{- if .Values.nginx.autoscaling.hpaAnnotations }}
@@ -23,8 +24,12 @@ spec:
2324
{{- end }}
2425
minReplicas: {{ .Values.nginx.autoscaling.minReplicas }}
2526
maxReplicas: {{ .Values.nginx.autoscaling.maxReplicas }}
27+
{{- if .Values.nginx.autoscaling.targetCPUUtilizationPercentage }}
2628
targetCPUUtilizationPercentage: {{ .Values.nginx.autoscaling.targetCPUUtilizationPercentage }}
29+
{{- end }}
30+
{{- if .Values.nginx.autoscaling.targetMemoryUtilizationPercentage }}
2731
targetMemoryUtilizationPercentage: {{ .Values.nginx.autoscaling.targetMemoryUtilizationPercentage }}
32+
{{- end }}
2833
{{- if .Values.nginx.autoscaling.behavior }}
2934
behavior:
3035
{{- toYaml .Values.nginx.autoscaling.behavior | nindent 10 }}
@@ -33,6 +38,7 @@ spec:
3338
autoscalingTemplate:
3439
{{- toYaml .Values.nginx.autoscalingTemplate | nindent 8 }}
3540
{{- end }}
41+
{{- end }}
3642
{{- if .Values.nginx.pod }}
3743
pod:
3844
{{- toYaml .Values.nginx.pod | nindent 8 }}

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

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -100,46 +100,12 @@
100100
"properties": {
101101
"autoscaling": {
102102
"properties": {
103-
"behavior": {
104-
"required": [],
105-
"title": "behavior",
106-
"type": "object"
107-
},
108103
"enabled": {
109-
"default": true,
104+
"default": false,
110105
"description": "Enable or disable Horizontal Pod Autoscaler",
111106
"required": [],
112107
"title": "enabled",
113108
"type": "boolean"
114-
},
115-
"hpaAnnotations": {
116-
"required": [],
117-
"title": "hpaAnnotations",
118-
"type": "object"
119-
},
120-
"maxReplicas": {
121-
"default": 11,
122-
"required": [],
123-
"title": "maxReplicas",
124-
"type": "integer"
125-
},
126-
"minReplicas": {
127-
"default": 1,
128-
"required": [],
129-
"title": "minReplicas",
130-
"type": "integer"
131-
},
132-
"targetCPUUtilizationPercentage": {
133-
"default": 50,
134-
"required": [],
135-
"title": "targetCPUUtilizationPercentage",
136-
"type": "integer"
137-
},
138-
"targetMemoryUtilizationPercentage": {
139-
"default": 50,
140-
"required": [],
141-
"title": "targetMemoryUtilizationPercentage",
142-
"type": "integer"
143109
}
144110
},
145111
"required": [],
@@ -376,6 +342,7 @@
376342
},
377343
"container": {
378344
"description": "The container configuration for the NGINX container. This is applied globally to all Gateways managed by this\ninstance of NGINX Gateway Fabric.",
345+
<<<<<<< HEAD
379346
"properties": {
380347
"hostPorts": {
381348
"description": "A list of HostPorts to expose on the host.\nThis configuration allows containers to bind to a specific port on the host node,\nenabling external network traffic to reach the container directly through the host's IP address and port.\nUse this option when you need to expose container ports on the host for direct access,\nsuch as for debugging, legacy integrations, or when NodePort/LoadBalancer services are not suitable.\nNote: Using hostPort may have security and scheduling implications, as it ties pods to specific nodes and ports.",
@@ -429,6 +396,8 @@
429396
"type": "array"
430397
}
431398
},
399+
=======
400+
>>>>>>> Code Review
432401
"required": [],
433402
"title": "container",
434403
"type": "object"
@@ -659,46 +628,12 @@
659628
},
660629
"autoscaling": {
661630
"properties": {
662-
"annotations": {
663-
"required": [],
664-
"title": "annotations",
665-
"type": "object"
666-
},
667-
"behavior": {
668-
"required": [],
669-
"title": "behavior",
670-
"type": "object"
671-
},
672631
"enabled": {
673632
"default": false,
674633
"description": "Enable or disable Horizontal Pod Autoscaler",
675634
"required": [],
676635
"title": "enabled",
677636
"type": "boolean"
678-
},
679-
"maxReplicas": {
680-
"default": 11,
681-
"required": [],
682-
"title": "maxReplicas",
683-
"type": "integer"
684-
},
685-
"minReplicas": {
686-
"default": 1,
687-
"required": [],
688-
"title": "minReplicas",
689-
"type": "integer"
690-
},
691-
"targetCPUUtilizationPercentage": {
692-
"default": 50,
693-
"required": [],
694-
"title": "targetCPUUtilizationPercentage",
695-
"type": "integer"
696-
},
697-
"targetMemoryUtilizationPercentage": {
698-
"default": 50,
699-
"required": [],
700-
"title": "targetMemoryUtilizationPercentage",
701-
"type": "integer"
702637
}
703638
},
704639
"required": [],

charts/nginx-gateway-fabric/values.yaml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ nginxGateway:
1414
# -- The name of the NGINX Gateway Fabric deployment - if not present, then by default uses release name given during installation.
1515
name: ""
1616

17-
1817
# @schema
1918
# required: true
2019
# type: string
@@ -161,12 +160,12 @@ nginxGateway:
161160
autoscaling:
162161
# Enable or disable Horizontal Pod Autoscaler
163162
enabled: false
164-
annotations: {}
165-
minReplicas: 1
166-
maxReplicas: 11
167-
targetCPUUtilizationPercentage: 50
168-
targetMemoryUtilizationPercentage: 50
169-
behavior: {}
163+
# annotations: {}
164+
# minReplicas: 1
165+
# maxReplicas: 11
166+
# targetCPUUtilizationPercentage: 50
167+
# targetMemoryUtilizationPercentage: 50
168+
# behavior: {}
170169
# scaleDown:
171170
# stabilizationWindowSeconds: 300
172171
# policies:
@@ -232,13 +231,13 @@ nginx:
232231

233232
autoscaling:
234233
# Enable or disable Horizontal Pod Autoscaler
235-
enabled: true
236-
hpaAnnotations: {}
237-
minReplicas: 1
238-
maxReplicas: 11
239-
targetCPUUtilizationPercentage: 50
240-
targetMemoryUtilizationPercentage: 50
241-
behavior: {}
234+
enabled: false
235+
# hpaAnnotations: {}
236+
# minReplicas: 1
237+
# maxReplicas: 11
238+
# targetCPUUtilizationPercentage: 50
239+
# targetMemoryUtilizationPercentage: 50
240+
# behavior: {}
242241
# scaleDown:
243242
# stabilizationWindowSeconds: 300
244243
# policies:

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4012,7 +4012,11 @@ spec:
40124012
type: array
40134013
behavior:
40144014
description: |-
4015+
<<<<<<< HEAD
40154016
Behavior configures the scaling behavior of the target
4017+
=======
4018+
behavior configures the scaling behavior of the target
4019+
>>>>>>> Code Review
40164020
in both Up and Down directions (scaleUp and scaleDown fields respectively).
40174021
If not set, the default HPAScalingRules for scale up and scale down are used.
40184022
properties:
@@ -4171,6 +4175,19 @@ spec:
41714175
enabled:
41724176
description: Enable or disable Horizontal Pod Autoscaler
41734177
type: boolean
4178+
<<<<<<< HEAD
4179+
=======
4180+
hpaAnnotations:
4181+
additionalProperties:
4182+
type: string
4183+
description: |-
4184+
Annotation for Horizontal Pod Autoscaler
4185+
Annotations is an unstructured key value map stored with a resource that may be
4186+
set by external tools to store and retrieve arbitrary metadata. They are not
4187+
queryable and should be preserved when modifying objects.
4188+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
4189+
type: object
4190+
>>>>>>> Code Review
41744191
maxReplicas:
41754192
description: Maximum number of replicas.
41764193
format: int32
@@ -4191,6 +4208,20 @@ spec:
41914208
- enabled
41924209
- maxReplicas
41934210
type: object
4211+
x-kubernetes-validations:
4212+
- message: at least one metric must be specified when autoscaling
4213+
is enabled
4214+
rule: '!self.enabled || (has(self.targetCPUUtilizationPercentage)
4215+
|| has(self.targetMemoryUtilizationPercentage) || (has(self.autoscalingTemplate)
4216+
&& size(self.autoscalingTemplate) > 0))'
4217+
- message: minReplicas must be less than or equal to maxReplicas
4218+
rule: self.minReplicas <= self.maxReplicas
4219+
- message: CPU utilization must be between 1 and 100
4220+
rule: '!has(self.targetCPUUtilizationPercentage) || (self.targetCPUUtilizationPercentage
4221+
>= 1 && self.targetCPUUtilizationPercentage <= 100)'
4222+
- message: memory utilization must be between 1 and 100
4223+
rule: '!has(self.targetMemoryUtilizationPercentage) || (self.targetMemoryUtilizationPercentage
4224+
>= 1 && self.targetMemoryUtilizationPercentage <= 100)'
41944225
container:
41954226
description: Container defines container fields for the NGINX
41964227
container.
@@ -7688,14 +7719,28 @@ spec:
76887719
automatically if required. The default NodePort range enforced by Kubernetes is 30000-32767.
76897720
properties:
76907721
listenerPort:
7722+
<<<<<<< HEAD
76917723
description: ListenerPort is the Gateway listener port
76927724
that this NodePort maps to.
7725+
=======
7726+
description: |-
7727+
ListenerPort is the Gateway listener port that this NodePort maps to.
7728+
kubebuilder:validation:Minimum=1
7729+
kubebuilder:validation:Maximum=65535
7730+
>>>>>>> Code Review
76937731
format: int32
76947732
maximum: 65535
76957733
minimum: 1
76967734
type: integer
76977735
port:
7736+
<<<<<<< HEAD
76987737
description: Port is the NodePort to expose.
7738+
=======
7739+
description: |-
7740+
Port is the NodePort to expose.
7741+
kubebuilder:validation:Minimum=1
7742+
kubebuilder:validation:Maximum=65535
7743+
>>>>>>> Code Review
76997744
format: int32
77007745
maximum: 65535
77017746
minimum: 1

deploy/azure/deploy.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,6 @@ metadata:
414414
spec:
415415
kubernetes:
416416
deployment:
417-
autoscaling:
418-
enabled: true
419-
maxReplicas: 11
420-
minReplicas: 1
421-
targetCPUUtilizationPercentage: 50
422-
targetMemoryUtilizationPercentage: 50
423417
container:
424418
image:
425419
pullPolicy: Always

deploy/crds.yaml

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

deploy/default/deploy.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,6 @@ metadata:
412412
spec:
413413
kubernetes:
414414
deployment:
415-
autoscaling:
416-
enabled: true
417-
maxReplicas: 11
418-
minReplicas: 1
419-
targetCPUUtilizationPercentage: 50
420-
targetMemoryUtilizationPercentage: 50
421415
container:
422416
image:
423417
pullPolicy: Always

deploy/experimental-nginx-plus/deploy.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,6 @@ metadata:
420420
spec:
421421
kubernetes:
422422
deployment:
423-
autoscaling:
424-
enabled: true
425-
maxReplicas: 11
426-
minReplicas: 1
427-
targetCPUUtilizationPercentage: 50
428-
targetMemoryUtilizationPercentage: 50
429423
container:
430424
image:
431425
pullPolicy: Always

deploy/experimental/deploy.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,6 @@ metadata:
417417
spec:
418418
kubernetes:
419419
deployment:
420-
autoscaling:
421-
enabled: true
422-
maxReplicas: 11
423-
minReplicas: 1
424-
targetCPUUtilizationPercentage: 50
425-
targetMemoryUtilizationPercentage: 50
426420
container:
427421
image:
428422
pullPolicy: Always

0 commit comments

Comments
 (0)