Skip to content

Commit 178326a

Browse files
committed
Fix Pipeline err
1 parent 3d2b56c commit 178326a

File tree

4 files changed

+48
-53
lines changed

4 files changed

+48
-53
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -419,22 +419,17 @@ type DaemonSetSpec struct {
419419
}
420420

421421
type HPASpec struct {
422-
// Enable or disable Horizontal Pod Autoscaler
423-
Enabled bool `json:"enabled"`
424-
425-
// Annotation for Horizontal Pod Autoscaler
426-
// Annotations is an unstructured key value map stored with a resource that may be
427-
// set by external tools to store and retrieve arbitrary metadata. They are not
428-
// queryable and should be preserved when modifying objects.
429-
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
422+
// behavior configures the scaling behavior of the target
423+
// in both Up and Down directions (scaleUp and scaleDown fields respectively).
424+
// If not set, the default HPAScalingRules for scale up and scale down are used.
425+
//
430426
// +optional
431-
HPAAnnotations map[string]string `json:"hpaAnnotations,omitempty"`
432-
433-
// Minimun of replicas.
434-
MinReplicas int32 `json:"minReplicas"`
427+
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
435428

436-
// Minimun of replicas.
437-
MaxReplicas int32 `json:"maxReplicas"`
429+
// AutoscalingTemplate configures the additional scaling option.
430+
//
431+
// +optional
432+
AutoscalingTemplate *[]autoscalingv2.MetricSpec `json:"autoscalingTemplate,omitempty"`
438433

439434
// Target cpu utilization percentage of HPA.
440435
//
@@ -446,17 +441,22 @@ type HPASpec struct {
446441
// +optional
447442
TargetMemoryUtilizationPercentage *int32 `json:"targetMemoryUtilizationPercentage,omitempty"`
448443

449-
// behavior configures the scaling behavior of the target
450-
// in both Up and Down directions (scaleUp and scaleDown fields respectively).
451-
// If not set, the default HPAScalingRules for scale up and scale down are used.
452-
//
444+
// Annotation for Horizontal Pod Autoscaler
445+
// Annotations is an unstructured key value map stored with a resource that may be
446+
// set by external tools to store and retrieve arbitrary metadata. They are not
447+
// queryable and should be preserved when modifying objects.
448+
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
453449
// +optional
454-
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
450+
HPAAnnotations map[string]string `json:"hpaAnnotations,omitempty"`
455451

456-
// AutoscalingTemplate configures the addtional scaling option.
457-
//
458-
// +optional
459-
AutoscalingTemplate *[]autoscalingv2.MetricSpec `json:"autoscalingTemplate,omitempty"`
452+
// Minimun of replicas.
453+
MinReplicas int32 `json:"minReplicas"`
454+
455+
// Minimun of replicas.
456+
MaxReplicas int32 `json:"maxReplicas"`
457+
458+
// Enable or disable Horizontal Pod Autoscaler
459+
Enabled bool `json:"enabled"`
460460
}
461461

462462
// PodSpec defines Pod-specific fields.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@
829829
"type": "object"
830830
},
831831
"metrics": {
832+
"description": "Custom or additional autoscaling metrics\nref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-custom-metrics\n- type: Pods\n pods:\n metric:\n name: nginx_gateway_fabric_nginx_process_requests_total\n target:\n type: AverageValue\n averageValue: 10000m",
832833
"properties": {
833834
"enable": {
834835
"default": true,

charts/nginx-gateway-fabric/values.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ nginxGateway:
187187
# target:
188188
# type: AverageValue
189189
# averageValue: 10000m
190-
190+
191191
metrics:
192192
# -- Enable exposing metrics in the Prometheus format.
193193
enable: true
@@ -464,9 +464,7 @@ nginx:
464464
# instance of NGINX Gateway Fabric.
465465
container:
466466
# -- The resource requirements of the NGINX container. You should be set this value, If you want to use dataplane Autoscaling(HPA).
467-
resources: {}
468-
469-
467+
resources: {}
470468
# -- The lifecycle of the NGINX container.
471469
# lifecycle: {}
472470

@@ -563,7 +561,6 @@ certGenerator:
563561

564562
# -- A list of Gateway objects. View https://gateway-api.sigs.k8s.io/reference/spec/#gateway for full Gateway reference.
565563
gateways: []
566-
567564
# Example gateway object:
568565
# name: nginx-gateway
569566
# namespace: default

internal/controller/provisioner/objects.go

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (p *NginxProvisioner) buildNginxResourceObjects(
168168
hpaAnnotations := make(map[string]string)
169169
if nProxyCfg.Kubernetes.Deployment.Autoscaling.HPAAnnotations != nil {
170170
for key, value := range nProxyCfg.Kubernetes.Deployment.Autoscaling.HPAAnnotations {
171-
hpaAnnotations[string(key)] = string(value)
171+
hpaAnnotations[key] = value
172172
}
173173
}
174174

@@ -919,7 +919,6 @@ func (p *NginxProvisioner) buildImage(nProxyCfg *graph.EffectiveNginxProxy) (str
919919
func getMetricTargetByType(
920920
target autoscalingv2.MetricTarget,
921921
) autoscalingv2.MetricTarget {
922-
923922
switch target.Type {
924923
case autoscalingv2.UtilizationMetricType:
925924
return autoscalingv2.MetricTarget{
@@ -941,7 +940,6 @@ func getMetricTargetByType(
941940
default:
942941
return autoscalingv2.MetricTarget{}
943942
}
944-
945943
}
946944

947945
func buildNginxDeploymentHPA(
@@ -981,59 +979,58 @@ func buildNginxDeploymentHPA(
981979
}
982980

983981
if autoscalingTemplate != nil {
984-
for _, addtionalAutoscaling := range *autoscalingTemplate {
985-
986-
switch addtionalAutoscaling.Type {
982+
for _, additionalAutoscaling := range *autoscalingTemplate {
983+
switch additionalAutoscaling.Type {
987984
case autoscalingv2.ResourceMetricSourceType:
988985
metrics = append(metrics, autoscalingv2.MetricSpec{
989-
Type: addtionalAutoscaling.Type,
986+
Type: additionalAutoscaling.Type,
990987
Resource: &autoscalingv2.ResourceMetricSource{
991-
Name: addtionalAutoscaling.Resource.Name,
992-
Target: getMetricTargetByType(addtionalAutoscaling.Resource.Target),
988+
Name: additionalAutoscaling.Resource.Name,
989+
Target: getMetricTargetByType(additionalAutoscaling.Resource.Target),
993990
},
994991
})
995992

996993
case autoscalingv2.PodsMetricSourceType:
997994
metrics = append(metrics, autoscalingv2.MetricSpec{
998-
Type: addtionalAutoscaling.Type,
995+
Type: additionalAutoscaling.Type,
999996
Pods: &autoscalingv2.PodsMetricSource{
1000-
Metric: addtionalAutoscaling.Pods.Metric,
1001-
Target: getMetricTargetByType(addtionalAutoscaling.Pods.Target),
997+
Metric: additionalAutoscaling.Pods.Metric,
998+
Target: getMetricTargetByType(additionalAutoscaling.Pods.Target),
1002999
},
10031000
})
10041001

10051002
case autoscalingv2.ContainerResourceMetricSourceType:
10061003
metrics = append(metrics, autoscalingv2.MetricSpec{
1007-
Type: addtionalAutoscaling.Type,
1004+
Type: additionalAutoscaling.Type,
10081005
ContainerResource: &autoscalingv2.ContainerResourceMetricSource{
1009-
Name: addtionalAutoscaling.ContainerResource.Name,
1010-
Target: getMetricTargetByType(addtionalAutoscaling.ContainerResource.Target),
1011-
Container: addtionalAutoscaling.ContainerResource.Container,
1006+
Name: additionalAutoscaling.ContainerResource.Name,
1007+
Target: getMetricTargetByType(additionalAutoscaling.ContainerResource.Target),
1008+
Container: additionalAutoscaling.ContainerResource.Container,
10121009
},
10131010
})
10141011

10151012
case autoscalingv2.ObjectMetricSourceType:
10161013
metrics = append(metrics, autoscalingv2.MetricSpec{
1017-
Type: addtionalAutoscaling.Type,
1014+
Type: additionalAutoscaling.Type,
10181015
Object: &autoscalingv2.ObjectMetricSource{
1019-
DescribedObject: addtionalAutoscaling.Object.DescribedObject,
1020-
Target: getMetricTargetByType(addtionalAutoscaling.Object.Target),
1016+
DescribedObject: additionalAutoscaling.Object.DescribedObject,
1017+
Target: getMetricTargetByType(additionalAutoscaling.Object.Target),
10211018
Metric: autoscalingv2.MetricIdentifier{
1022-
Name: addtionalAutoscaling.Object.Metric.Name,
1023-
Selector: addtionalAutoscaling.Object.Metric.Selector,
1019+
Name: additionalAutoscaling.Object.Metric.Name,
1020+
Selector: additionalAutoscaling.Object.Metric.Selector,
10241021
},
10251022
},
10261023
})
10271024

10281025
case autoscalingv2.ExternalMetricSourceType:
10291026
metrics = append(metrics, autoscalingv2.MetricSpec{
1030-
Type: addtionalAutoscaling.Type,
1027+
Type: additionalAutoscaling.Type,
10311028
External: &autoscalingv2.ExternalMetricSource{
10321029
Metric: autoscalingv2.MetricIdentifier{
1033-
Name: addtionalAutoscaling.External.Metric.Name,
1034-
Selector: addtionalAutoscaling.External.Metric.Selector,
1030+
Name: additionalAutoscaling.External.Metric.Name,
1031+
Selector: additionalAutoscaling.External.Metric.Selector,
10351032
},
1036-
Target: getMetricTargetByType(addtionalAutoscaling.External.Target),
1033+
Target: getMetricTargetByType(additionalAutoscaling.External.Target),
10371034
},
10381035
})
10391036
}

0 commit comments

Comments
 (0)