Skip to content

Commit f3e0bb0

Browse files
committed
Merge pull request kubernetes#15706 from jszczepkowski/hpa-beta-util
HorizontalPodAutoscaler and Scale subresource APIs graduated to beta.
2 parents 4b98358 + df732f0 commit f3e0bb0

19 files changed

+614
-587
lines changed

api/swagger-spec/v1beta1.json

+39-37
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@
20762076
"models": {
20772077
"v1beta1.HorizontalPodAutoscalerList": {
20782078
"id": "v1beta1.HorizontalPodAutoscalerList",
2079-
"description": "HorizontalPodAutoscalerList is a list of HorizontalPodAutoscalers.",
2079+
"description": "list of horizontal pod autoscaler objects.",
20802080
"required": [
20812081
"items"
20822082
],
@@ -2098,7 +2098,7 @@
20982098
"items": {
20992099
"$ref": "v1beta1.HorizontalPodAutoscaler"
21002100
},
2101-
"description": "Items is the list of HorizontalPodAutoscalers."
2101+
"description": "list of horizontal pod autoscaler objects."
21022102
}
21032103
}
21042104
},
@@ -2118,7 +2118,7 @@
21182118
},
21192119
"v1beta1.HorizontalPodAutoscaler": {
21202120
"id": "v1beta1.HorizontalPodAutoscaler",
2121-
"description": "HorizontalPodAutoscaler represents the configuration of a horizontal pod autoscaler.",
2121+
"description": "configuration of a horizontal pod autoscaler.",
21222122
"properties": {
21232123
"kind": {
21242124
"type": "string",
@@ -2134,11 +2134,11 @@
21342134
},
21352135
"spec": {
21362136
"$ref": "v1beta1.HorizontalPodAutoscalerSpec",
2137-
"description": "Spec defines the behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status."
2137+
"description": "behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status."
21382138
},
21392139
"status": {
21402140
"$ref": "v1beta1.HorizontalPodAutoscalerStatus",
2141-
"description": "Status represents the current information about the autoscaler."
2141+
"description": "current information about the autoscaler."
21422142
}
21432143
}
21442144
},
@@ -2200,31 +2200,29 @@
22002200
},
22012201
"v1beta1.HorizontalPodAutoscalerSpec": {
22022202
"id": "v1beta1.HorizontalPodAutoscalerSpec",
2203-
"description": "HorizontalPodAutoscalerSpec is the specification of a horizontal pod autoscaler.",
2203+
"description": "specification of a horizontal pod autoscaler.",
22042204
"required": [
22052205
"scaleRef",
2206-
"minReplicas",
2207-
"maxReplicas",
2208-
"target"
2206+
"maxReplicas"
22092207
],
22102208
"properties": {
22112209
"scaleRef": {
22122210
"$ref": "v1beta1.SubresourceReference",
2213-
"description": "ScaleRef is a reference to Scale subresource. HorizontalPodAutoscaler will learn the current resource consumption from its status, and will set the desired number of pods by modyfying its spec."
2211+
"description": "reference to Scale subresource; horizontal pod autoscaler will learn the current resource consumption from its status, and will set the desired number of pods by modifying its spec."
22142212
},
22152213
"minReplicas": {
22162214
"type": "integer",
22172215
"format": "int32",
2218-
"description": "MinReplicas is the lower limit for the number of pods that can be set by the autoscaler."
2216+
"description": "lower limit for the number of pods that can be set by the autoscaler, default 1."
22192217
},
22202218
"maxReplicas": {
22212219
"type": "integer",
22222220
"format": "int32",
2223-
"description": "MaxReplicas is the upper limit for the number of pods that can be set by the autoscaler. It cannot be smaller than MinReplicas."
2221+
"description": "upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas."
22242222
},
2225-
"target": {
2226-
"$ref": "v1beta1.ResourceConsumption",
2227-
"description": "Target is the target average consumption of the given resource that the autoscaler will try to maintain by adjusting the desired number of pods. Currently two types of resources are supported: \"cpu\" and \"memory\"."
2223+
"cpuUtilization": {
2224+
"$ref": "v1beta1.CPUTargetUtilization",
2225+
"description": "target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified it defaults to the target CPU utilization at 80% of the requested resources."
22282226
}
22292227
}
22302228
},
@@ -2254,46 +2252,50 @@
22542252
}
22552253
}
22562254
},
2257-
"v1beta1.ResourceConsumption": {
2258-
"id": "v1beta1.ResourceConsumption",
2259-
"description": "ResourceConsumption is an object for specifying average resource consumption of a particular resource.",
2255+
"v1beta1.CPUTargetUtilization": {
2256+
"id": "v1beta1.CPUTargetUtilization",
2257+
"required": [
2258+
"targetPercentage"
2259+
],
22602260
"properties": {
2261-
"resource": {
2262-
"type": "string",
2263-
"description": "Resource specifies either the name of the target resource when present in the spec, or the name of the observed resource when present in the status."
2264-
},
2265-
"quantity": {
2266-
"type": "string",
2267-
"description": "Quantity specifies either the target average consumption of the resource when present in the spec, or the observed average consumption when present in the status."
2261+
"targetPercentage": {
2262+
"type": "integer",
2263+
"format": "int32",
2264+
"description": "fraction of the requested CPU that should be utilized/used, e.g. 70 means that 70% of the requested CPU should be in use."
22682265
}
22692266
}
22702267
},
22712268
"v1beta1.HorizontalPodAutoscalerStatus": {
22722269
"id": "v1beta1.HorizontalPodAutoscalerStatus",
2273-
"description": "HorizontalPodAutoscalerStatus contains the current status of a horizontal pod autoscaler",
2270+
"description": "current status of a horizontal pod autoscaler",
22742271
"required": [
22752272
"currentReplicas",
2276-
"desiredReplicas",
2277-
"currentConsumption"
2273+
"desiredReplicas"
22782274
],
22792275
"properties": {
2276+
"observedGeneration": {
2277+
"type": "integer",
2278+
"format": "int64",
2279+
"description": "most recent generation observed by this autoscaler."
2280+
},
2281+
"lastScaleTime": {
2282+
"type": "string",
2283+
"description": "last time the HorizontalPodAutoscaler scaled the number of pods; used by the autoscaler to control how often the number of pods is changed."
2284+
},
22802285
"currentReplicas": {
22812286
"type": "integer",
22822287
"format": "int32",
2283-
"description": "CurrentReplicas is the number of replicas of pods managed by this autoscaler."
2288+
"description": "current number of replicas of pods managed by this autoscaler."
22842289
},
22852290
"desiredReplicas": {
22862291
"type": "integer",
22872292
"format": "int32",
2288-
"description": "DesiredReplicas is the desired number of replicas of pods managed by this autoscaler."
2293+
"description": "desired number of replicas of pods managed by this autoscaler."
22892294
},
2290-
"currentConsumption": {
2291-
"$ref": "v1beta1.ResourceConsumption",
2292-
"description": "CurrentConsumption is the current average consumption of the given resource that the autoscaler will try to maintain by adjusting the desired number of pods. Two types of resources are supported: \"cpu\" and \"memory\"."
2293-
},
2294-
"lastScaleTimestamp": {
2295-
"type": "string",
2296-
"description": "LastScaleTimestamp is the last time the HorizontalPodAutoscaler scaled the number of pods. This is used by the autoscaler to controll how often the number of pods is changed."
2295+
"currentCPUUtilizationPercentage": {
2296+
"type": "integer",
2297+
"format": "int32",
2298+
"description": "current average CPU utilization over all pods, represented as a percentage of requested CPU, e.g. 70 means that an average pod is using now 70% of its requested CPU."
22972299
}
22982300
}
22992301
},

pkg/api/testing/fuzzer.go

+6
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
368368
// string, which will cause tests failure.
369369
s.APIGroup = "something"
370370
},
371+
func(s *extensions.HorizontalPodAutoscalerSpec, c fuzz.Continue) {
372+
c.FuzzNoCustom(s) // fuzz self without calling this function again
373+
minReplicas := c.Rand.Int()
374+
s.MinReplicas = &minReplicas
375+
s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(c.RandUint64())}
376+
},
371377
)
372378
return f
373379
}

pkg/apis/extensions/deep_copy_generated.go

+36-30
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,11 @@ func deepCopy_extensions_APIVersion(in APIVersion, out *APIVersion, c *conversio
848848
return nil
849849
}
850850

851+
func deepCopy_extensions_CPUTargetUtilization(in CPUTargetUtilization, out *CPUTargetUtilization, c *conversion.Cloner) error {
852+
out.TargetPercentage = in.TargetPercentage
853+
return nil
854+
}
855+
851856
func deepCopy_extensions_ClusterAutoscaler(in ClusterAutoscaler, out *ClusterAutoscaler, c *conversion.Cloner) error {
852857
if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
853858
return err
@@ -1099,40 +1104,49 @@ func deepCopy_extensions_HorizontalPodAutoscalerList(in HorizontalPodAutoscalerL
10991104
}
11001105

11011106
func deepCopy_extensions_HorizontalPodAutoscalerSpec(in HorizontalPodAutoscalerSpec, out *HorizontalPodAutoscalerSpec, c *conversion.Cloner) error {
1102-
if in.ScaleRef != nil {
1103-
out.ScaleRef = new(SubresourceReference)
1104-
if err := deepCopy_extensions_SubresourceReference(*in.ScaleRef, out.ScaleRef, c); err != nil {
1105-
return err
1106-
}
1107+
if err := deepCopy_extensions_SubresourceReference(in.ScaleRef, &out.ScaleRef, c); err != nil {
1108+
return err
1109+
}
1110+
if in.MinReplicas != nil {
1111+
out.MinReplicas = new(int)
1112+
*out.MinReplicas = *in.MinReplicas
11071113
} else {
1108-
out.ScaleRef = nil
1114+
out.MinReplicas = nil
11091115
}
1110-
out.MinReplicas = in.MinReplicas
11111116
out.MaxReplicas = in.MaxReplicas
1112-
if err := deepCopy_extensions_ResourceConsumption(in.Target, &out.Target, c); err != nil {
1113-
return err
1117+
if in.CPUUtilization != nil {
1118+
out.CPUUtilization = new(CPUTargetUtilization)
1119+
if err := deepCopy_extensions_CPUTargetUtilization(*in.CPUUtilization, out.CPUUtilization, c); err != nil {
1120+
return err
1121+
}
1122+
} else {
1123+
out.CPUUtilization = nil
11141124
}
11151125
return nil
11161126
}
11171127

11181128
func deepCopy_extensions_HorizontalPodAutoscalerStatus(in HorizontalPodAutoscalerStatus, out *HorizontalPodAutoscalerStatus, c *conversion.Cloner) error {
1119-
out.CurrentReplicas = in.CurrentReplicas
1120-
out.DesiredReplicas = in.DesiredReplicas
1121-
if in.CurrentConsumption != nil {
1122-
out.CurrentConsumption = new(ResourceConsumption)
1123-
if err := deepCopy_extensions_ResourceConsumption(*in.CurrentConsumption, out.CurrentConsumption, c); err != nil {
1124-
return err
1125-
}
1129+
if in.ObservedGeneration != nil {
1130+
out.ObservedGeneration = new(int64)
1131+
*out.ObservedGeneration = *in.ObservedGeneration
11261132
} else {
1127-
out.CurrentConsumption = nil
1133+
out.ObservedGeneration = nil
11281134
}
1129-
if in.LastScaleTimestamp != nil {
1130-
out.LastScaleTimestamp = new(unversioned.Time)
1131-
if err := deepCopy_unversioned_Time(*in.LastScaleTimestamp, out.LastScaleTimestamp, c); err != nil {
1135+
if in.LastScaleTime != nil {
1136+
out.LastScaleTime = new(unversioned.Time)
1137+
if err := deepCopy_unversioned_Time(*in.LastScaleTime, out.LastScaleTime, c); err != nil {
11321138
return err
11331139
}
11341140
} else {
1135-
out.LastScaleTimestamp = nil
1141+
out.LastScaleTime = nil
1142+
}
1143+
out.CurrentReplicas = in.CurrentReplicas
1144+
out.DesiredReplicas = in.DesiredReplicas
1145+
if in.CurrentCPUUtilizationPercentage != nil {
1146+
out.CurrentCPUUtilizationPercentage = new(int)
1147+
*out.CurrentCPUUtilizationPercentage = *in.CurrentCPUUtilizationPercentage
1148+
} else {
1149+
out.CurrentCPUUtilizationPercentage = nil
11361150
}
11371151
return nil
11381152
}
@@ -1389,14 +1403,6 @@ func deepCopy_extensions_ReplicationControllerDummy(in ReplicationControllerDumm
13891403
return nil
13901404
}
13911405

1392-
func deepCopy_extensions_ResourceConsumption(in ResourceConsumption, out *ResourceConsumption, c *conversion.Cloner) error {
1393-
out.Resource = in.Resource
1394-
if err := deepCopy_resource_Quantity(in.Quantity, &out.Quantity, c); err != nil {
1395-
return err
1396-
}
1397-
return nil
1398-
}
1399-
14001406
func deepCopy_extensions_RollingUpdateDeployment(in RollingUpdateDeployment, out *RollingUpdateDeployment, c *conversion.Cloner) error {
14011407
if err := deepCopy_util_IntOrString(in.MaxUnavailable, &out.MaxUnavailable, c); err != nil {
14021408
return err
@@ -1586,6 +1592,7 @@ func init() {
15861592
deepCopy_unversioned_Time,
15871593
deepCopy_unversioned_TypeMeta,
15881594
deepCopy_extensions_APIVersion,
1595+
deepCopy_extensions_CPUTargetUtilization,
15891596
deepCopy_extensions_ClusterAutoscaler,
15901597
deepCopy_extensions_ClusterAutoscalerList,
15911598
deepCopy_extensions_ClusterAutoscalerSpec,
@@ -1620,7 +1627,6 @@ func init() {
16201627
deepCopy_extensions_PodSelector,
16211628
deepCopy_extensions_PodSelectorRequirement,
16221629
deepCopy_extensions_ReplicationControllerDummy,
1623-
deepCopy_extensions_ResourceConsumption,
16241630
deepCopy_extensions_RollingUpdateDeployment,
16251631
deepCopy_extensions_Scale,
16261632
deepCopy_extensions_ScaleSpec,

0 commit comments

Comments
 (0)