Skip to content

Commit a3cc731

Browse files
committed
Code Review & HPA event handler
1 parent 3298ffe commit a3cc731

File tree

22 files changed

+733
-42
lines changed

22 files changed

+733
-42
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ type DeploymentSpec struct {
389389
// +optional
390390
Replicas *int32 `json:"replicas,omitempty"`
391391

392-
// Horizontal Pod Autoscaling.
392+
// Autoscaling defines the configuration for Horizontal Pod Autoscaling.
393393
//
394394
// +optional
395395
Autoscaling HPASpec `json:"autoscaling"`
@@ -423,9 +423,11 @@ type DaemonSetSpec struct {
423423
// +kubebuilder:validation:XValidation:message="CPU utilization must be between 1 and 100",rule="!has(self.targetCPUUtilizationPercentage) || (self.targetCPUUtilizationPercentage >= 1 && self.targetCPUUtilizationPercentage <= 100)"
424424
// +kubebuilder:validation:XValidation:message="memory utilization must be between 1 and 100",rule="!has(self.targetMemoryUtilizationPercentage) || (self.targetMemoryUtilizationPercentage >= 1 && self.targetMemoryUtilizationPercentage <= 100)"
425425
//
426+
// HPASpec is the configuration for the Horizontal Pod Autoscaling.
427+
//
426428
//nolint:lll
427429
type HPASpec struct {
428-
// behavior configures the scaling behavior of the target
430+
// Behavior configures the scaling behavior of the target
429431
// in both Up and Down directions (scaleUp and scaleDown fields respectively).
430432
// If not set, the default HPAScalingRules for scale up and scale down are used.
431433
//

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ rules:
88
- apiGroups:
99
- ""
1010
- apps
11+
{{- if or .Values.nginx.autoscaling.enabled .Values.nginxGateway.autoscaling.enabled }}
1112
- autoscaling
13+
{{- end }}
1214
resources:
1315
- secrets
1416
- configmaps
1517
- serviceaccounts
1618
- services
1719
- deployments
1820
- daemonsets
21+
{{- if or .Values.nginx.autoscaling.enabled .Values.nginxGateway.autoscaling.enabled }}
1922
- horizontalpodautoscalers
23+
{{- end }}
2024
verbs:
2125
- create
2226
- update

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{{- if and (eq .Values.nginxGateway.kind "deployment") .Values.nginxGateway.autoscaling.enabled -}}
2-
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
1+
{{- if and (eq .Values.nginxGateway.kind "deployment") .Values.nginxGateway.autoscaling.enabled (.Capabilities.APIVersions.Has "autoscaling/v2") -}}
2+
apiVersion: autoscaling/v2
33
kind: HorizontalPodAutoscaler
44
metadata:
55
{{- with .Values.nginxGateway.autoscaling.annotations }}

0 commit comments

Comments
 (0)