Unverified Commit fdb57071 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #64097 from damemi/hpa-metrics-specificity

Automatic merge from submit-queue (batch tested with PRs 67894, 64097). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. HPA metrics specificity improvements **What this PR does / why we need it**: Improves available specificity for HPA metrics by adding metric selector fields for metrics of Pods and Objects. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Implements this KEP: https://github.com/kubernetes/community/pull/2055 **Special notes for your reviewer**: Need to add/update tests? **Release note**: ```release-note Introduces autoscaling/v2beta2 and custom_metrics/v1beta2, which implement metric selectors for Object and Pods metrics, as well as allowing AverageValue targets on Objects, similar to External metrics. ``` /assign @DirectXMan12
parents d0f42e24 dd7e81a8
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1600,6 +1600,56 @@ ...@@ -1600,6 +1600,56 @@
"targetValue": { "targetValue": {
"type": "string", "type": "string",
"description": "targetValue is the target value of the metric (as a quantity)." "description": "targetValue is the target value of the metric (as a quantity)."
},
"selector": {
"$ref": "v1.LabelSelector",
"description": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics."
},
"averageValue": {
"type": "string",
"description": "averageValue is the target value of the average of the metric across all relevant pods (as a quantity)"
}
}
},
"v1.LabelSelector": {
"id": "v1.LabelSelector",
"description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.",
"properties": {
"matchLabels": {
"type": "object",
"description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed."
},
"matchExpressions": {
"type": "array",
"items": {
"$ref": "v1.LabelSelectorRequirement"
},
"description": "matchExpressions is a list of label selector requirements. The requirements are ANDed."
}
}
},
"v1.LabelSelectorRequirement": {
"id": "v1.LabelSelectorRequirement",
"description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.",
"required": [
"key",
"operator"
],
"properties": {
"key": {
"type": "string",
"description": "key is the label key that the selector applies to."
},
"operator": {
"type": "string",
"description": "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist."
},
"values": {
"type": "array",
"items": {
"type": "string"
},
"description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch."
} }
} }
}, },
...@@ -1618,6 +1668,10 @@ ...@@ -1618,6 +1668,10 @@
"targetAverageValue": { "targetAverageValue": {
"type": "string", "type": "string",
"description": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)" "description": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)"
},
"selector": {
"$ref": "v1.LabelSelector",
"description": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics."
} }
} }
}, },
...@@ -1668,48 +1722,6 @@ ...@@ -1668,48 +1722,6 @@
} }
} }
}, },
"v1.LabelSelector": {
"id": "v1.LabelSelector",
"description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.",
"properties": {
"matchLabels": {
"type": "object",
"description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed."
},
"matchExpressions": {
"type": "array",
"items": {
"$ref": "v1.LabelSelectorRequirement"
},
"description": "matchExpressions is a list of label selector requirements. The requirements are ANDed."
}
}
},
"v1.LabelSelectorRequirement": {
"id": "v1.LabelSelectorRequirement",
"description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.",
"required": [
"key",
"operator"
],
"properties": {
"key": {
"type": "string",
"description": "key is the label key that the selector applies to."
},
"operator": {
"type": "string",
"description": "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist."
},
"values": {
"type": "array",
"items": {
"type": "string"
},
"description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch."
}
}
},
"v2beta1.HorizontalPodAutoscalerStatus": { "v2beta1.HorizontalPodAutoscalerStatus": {
"id": "v2beta1.HorizontalPodAutoscalerStatus", "id": "v2beta1.HorizontalPodAutoscalerStatus",
"description": "HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.", "description": "HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.",
...@@ -1804,6 +1816,14 @@ ...@@ -1804,6 +1816,14 @@
"currentValue": { "currentValue": {
"type": "string", "type": "string",
"description": "currentValue is the current value of the metric (as a quantity)." "description": "currentValue is the current value of the metric (as a quantity)."
},
"selector": {
"$ref": "v1.LabelSelector",
"description": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics."
},
"averageValue": {
"type": "string",
"description": "averageValue is the current value of the average of the metric across all relevant pods (as a quantity)"
} }
} }
}, },
...@@ -1822,6 +1842,10 @@ ...@@ -1822,6 +1842,10 @@
"currentAverageValue": { "currentAverageValue": {
"type": "string", "type": "string",
"description": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)" "description": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)"
},
"selector": {
"$ref": "v1.LabelSelector",
"description": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics."
} }
} }
}, },
......
...@@ -54,6 +54,10 @@ ...@@ -54,6 +54,10 @@
"description": "API at /apis/autoscaling/v2beta1" "description": "API at /apis/autoscaling/v2beta1"
}, },
{ {
"path": "/apis/autoscaling/v2beta2",
"description": "API at /apis/autoscaling/v2beta2"
},
{
"path": "/apis/autoscaling", "path": "/apis/autoscaling",
"description": "get information of a group" "description": "get information of a group"
}, },
......
...@@ -249,6 +249,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{ ...@@ -249,6 +249,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{
{Group: "authorization.k8s.io", Version: "v1beta1"}: {group: 17600, version: 9}, {Group: "authorization.k8s.io", Version: "v1beta1"}: {group: 17600, version: 9},
{Group: "autoscaling", Version: "v1"}: {group: 17500, version: 15}, {Group: "autoscaling", Version: "v1"}: {group: 17500, version: 15},
{Group: "autoscaling", Version: "v2beta1"}: {group: 17500, version: 9}, {Group: "autoscaling", Version: "v2beta1"}: {group: 17500, version: 9},
{Group: "autoscaling", Version: "v2beta2"}: {group: 17500, version: 1},
{Group: "batch", Version: "v1"}: {group: 17400, version: 15}, {Group: "batch", Version: "v1"}: {group: 17400, version: 15},
{Group: "batch", Version: "v1beta1"}: {group: 17400, version: 9}, {Group: "batch", Version: "v1beta1"}: {group: 17400, version: 9},
{Group: "batch", Version: "v2alpha1"}: {group: 17400, version: 9}, {Group: "batch", Version: "v2alpha1"}: {group: 17400, version: 9},
......
...@@ -1034,6 +1034,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; } ...@@ -1034,6 +1034,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_labelselector">v1.LabelSelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -1306,6 +1313,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; } ...@@ -1306,6 +1313,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_labelselector">v1.LabelSelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -2012,6 +2026,20 @@ Examples:<br> ...@@ -2012,6 +2026,20 @@ Examples:<br>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_labelselector">v1.LabelSelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">averageValue</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">averageValue is the target value of the average of the metric across all relevant pods (as a quantity)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -2122,6 +2150,20 @@ Examples:<br> ...@@ -2122,6 +2150,20 @@ Examples:<br>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_labelselector">v1.LabelSelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">averageValue</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">averageValue is the current value of the average of the metric across all relevant pods (as a quantity)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -46,6 +46,7 @@ pkg/apis/authorization/validation ...@@ -46,6 +46,7 @@ pkg/apis/authorization/validation
pkg/apis/autoscaling pkg/apis/autoscaling
pkg/apis/autoscaling/v1 pkg/apis/autoscaling/v1
pkg/apis/autoscaling/v2beta1 pkg/apis/autoscaling/v2beta1
pkg/apis/autoscaling/v2beta2
pkg/apis/autoscaling/validation pkg/apis/autoscaling/validation
pkg/apis/batch pkg/apis/batch
pkg/apis/batch/v1 pkg/apis/batch/v1
...@@ -461,6 +462,7 @@ staging/src/k8s.io/api/authorization/v1 ...@@ -461,6 +462,7 @@ staging/src/k8s.io/api/authorization/v1
staging/src/k8s.io/api/authorization/v1beta1 staging/src/k8s.io/api/authorization/v1beta1
staging/src/k8s.io/api/autoscaling/v1 staging/src/k8s.io/api/autoscaling/v1
staging/src/k8s.io/api/autoscaling/v2beta1 staging/src/k8s.io/api/autoscaling/v2beta1
staging/src/k8s.io/api/autoscaling/v2beta2
staging/src/k8s.io/api/batch/v1 staging/src/k8s.io/api/batch/v1
staging/src/k8s.io/api/batch/v1beta1 staging/src/k8s.io/api/batch/v1beta1
staging/src/k8s.io/api/batch/v2alpha1 staging/src/k8s.io/api/batch/v2alpha1
...@@ -705,6 +707,7 @@ staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice ...@@ -705,6 +707,7 @@ staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice
staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd
staging/src/k8s.io/metrics/pkg/apis/custom_metrics staging/src/k8s.io/metrics/pkg/apis/custom_metrics
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1 staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta2
staging/src/k8s.io/metrics/pkg/apis/external_metrics staging/src/k8s.io/metrics/pkg/apis/external_metrics
staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1 staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1
staging/src/k8s.io/metrics/pkg/apis/metrics staging/src/k8s.io/metrics/pkg/apis/metrics
...@@ -712,6 +715,7 @@ staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1 ...@@ -712,6 +715,7 @@ staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1
staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1 staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1
staging/src/k8s.io/metrics/pkg/client/custom_metrics staging/src/k8s.io/metrics/pkg/client/custom_metrics
staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake
staging/src/k8s.io/metrics/pkg/client/custom_metrics/scheme
staging/src/k8s.io/metrics/pkg/client/external_metrics staging/src/k8s.io/metrics/pkg/client/external_metrics
staging/src/k8s.io/metrics/pkg/client/external_metrics/fake staging/src/k8s.io/metrics/pkg/client/external_metrics/fake
staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder
......
...@@ -68,6 +68,7 @@ authorization.k8s.io/v1 \ ...@@ -68,6 +68,7 @@ authorization.k8s.io/v1 \
authorization.k8s.io/v1beta1 \ authorization.k8s.io/v1beta1 \
autoscaling/v1 \ autoscaling/v1 \
autoscaling/v2beta1 \ autoscaling/v2beta1 \
autoscaling/v2beta2 \
batch/v1 \ batch/v1 \
batch/v1beta1 \ batch/v1beta1 \
batch/v2alpha1 \ batch/v2alpha1 \
......
...@@ -52,6 +52,7 @@ PACKAGES=( ...@@ -52,6 +52,7 @@ PACKAGES=(
k8s.io/api/autoscaling/v1 k8s.io/api/autoscaling/v1
k8s.io/api/authorization/v1 k8s.io/api/authorization/v1
k8s.io/api/autoscaling/v2beta1 k8s.io/api/autoscaling/v2beta1
k8s.io/api/autoscaling/v2beta2
k8s.io/api/authorization/v1beta1 k8s.io/api/authorization/v1beta1
k8s.io/api/batch/v1 k8s.io/api/batch/v1
k8s.io/api/batch/v1beta1 k8s.io/api/batch/v1beta1
...@@ -81,6 +82,7 @@ PACKAGES=( ...@@ -81,6 +82,7 @@ PACKAGES=(
k8s.io/metrics/pkg/apis/metrics/v1alpha1 k8s.io/metrics/pkg/apis/metrics/v1alpha1
k8s.io/metrics/pkg/apis/metrics/v1beta1 k8s.io/metrics/pkg/apis/metrics/v1beta1
k8s.io/metrics/pkg/apis/custom_metrics/v1beta1 k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
k8s.io/metrics/pkg/apis/custom_metrics/v1beta2
k8s.io/metrics/pkg/apis/external_metrics/v1beta1 k8s.io/metrics/pkg/apis/external_metrics/v1beta1
k8s.io/apiserver/pkg/apis/audit/v1alpha1 k8s.io/apiserver/pkg/apis/audit/v1alpha1
k8s.io/apiserver/pkg/apis/audit/v1beta1 k8s.io/apiserver/pkg/apis/audit/v1beta1
......
...@@ -39,6 +39,7 @@ filegroup( ...@@ -39,6 +39,7 @@ filegroup(
"//pkg/apis/autoscaling/install:all-srcs", "//pkg/apis/autoscaling/install:all-srcs",
"//pkg/apis/autoscaling/v1:all-srcs", "//pkg/apis/autoscaling/v1:all-srcs",
"//pkg/apis/autoscaling/v2beta1:all-srcs", "//pkg/apis/autoscaling/v2beta1:all-srcs",
"//pkg/apis/autoscaling/v2beta2:all-srcs",
"//pkg/apis/autoscaling/validation:all-srcs", "//pkg/apis/autoscaling/validation:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
......
...@@ -52,19 +52,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { ...@@ -52,19 +52,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
} }
targetUtilization := int32(c.RandUint64()) targetUtilization := int32(c.RandUint64())
averageValue := randomQuantity()
s.Metrics = []autoscaling.MetricSpec{ s.Metrics = []autoscaling.MetricSpec{
{ {
Type: autoscaling.PodsMetricSourceType, Type: autoscaling.PodsMetricSourceType,
Pods: &autoscaling.PodsMetricSource{ Pods: &autoscaling.PodsMetricSource{
MetricName: c.RandString(), Metric: autoscaling.MetricIdentifier{
TargetAverageValue: randomQuantity(), Name: c.RandString(),
},
Target: autoscaling.MetricTarget{
Type: autoscaling.AverageValueMetricType,
AverageValue: &averageValue,
},
}, },
}, },
{ {
Type: autoscaling.ResourceMetricSourceType, Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{ Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU, Name: api.ResourceCPU,
TargetAverageUtilization: &targetUtilization, Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType,
AverageUtilization: &targetUtilization,
},
}, },
}, },
} }
...@@ -78,20 +87,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { ...@@ -78,20 +87,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
_ = q.String() _ = q.String()
return q return q
} }
averageValue := randomQuantity()
currentUtilization := int32(c.RandUint64()) currentUtilization := int32(c.RandUint64())
s.CurrentMetrics = []autoscaling.MetricStatus{ s.CurrentMetrics = []autoscaling.MetricStatus{
{ {
Type: autoscaling.PodsMetricSourceType, Type: autoscaling.PodsMetricSourceType,
Pods: &autoscaling.PodsMetricStatus{ Pods: &autoscaling.PodsMetricStatus{
MetricName: c.RandString(), Metric: autoscaling.MetricIdentifier{
CurrentAverageValue: randomQuantity(), Name: c.RandString(),
},
Current: autoscaling.MetricValueStatus{
AverageValue: &averageValue,
},
}, },
}, },
{ {
Type: autoscaling.ResourceMetricSourceType, Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricStatus{ Resource: &autoscaling.ResourceMetricStatus{
Name: api.ResourceCPU, Name: api.ResourceCPU,
CurrentAverageUtilization: &currentUtilization, Current: autoscaling.MetricValueStatus{
AverageUtilization: &currentUtilization,
AverageValue: &averageValue,
},
}, },
}, },
} }
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = ["install.go"], srcs = ["install.go"],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/install", importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/install",
visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/api/legacyscheme:go_default_library", "//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/autoscaling:go_default_library", "//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/autoscaling/v1:go_default_library", "//pkg/apis/autoscaling/v1:go_default_library",
"//pkg/apis/autoscaling/v2beta1:go_default_library", "//pkg/apis/autoscaling/v2beta1:go_default_library",
"//pkg/apis/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
], ],
...@@ -30,4 +27,5 @@ filegroup( ...@@ -30,4 +27,5 @@ filegroup(
name = "all-srcs", name = "all-srcs",
srcs = [":package-srcs"], srcs = [":package-srcs"],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/autoscaling/v1" "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1" "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1"
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
) )
func init() { func init() {
...@@ -34,7 +35,8 @@ func init() { ...@@ -34,7 +35,8 @@ func init() {
// Install registers the API group and adds types to a scheme // Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) { func Install(scheme *runtime.Scheme) {
utilruntime.Must(autoscaling.AddToScheme(scheme)) utilruntime.Must(autoscaling.AddToScheme(scheme))
utilruntime.Must(v2beta2.AddToScheme(scheme))
utilruntime.Must(v2beta1.AddToScheme(scheme)) utilruntime.Must(v2beta1.AddToScheme(scheme))
utilruntime.Must(v1.AddToScheme(scheme)) utilruntime.Must(v1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion)) utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion, v2beta2.SchemeGroupVersion))
} }
...@@ -154,13 +154,9 @@ type MetricSpec struct { ...@@ -154,13 +154,9 @@ type MetricSpec struct {
// ObjectMetricSource indicates how to scale on a metric describing a // ObjectMetricSource indicates how to scale on a metric describing a
// kubernetes object (for example, hits-per-second on an Ingress object). // kubernetes object (for example, hits-per-second on an Ingress object).
type ObjectMetricSource struct { type ObjectMetricSource struct {
// Target is the described Kubernetes object. DescribedObject CrossVersionObjectReference
Target CrossVersionObjectReference Target MetricTarget
Metric MetricIdentifier
// MetricName is the name of the metric in question.
MetricName string
// TargetValue is the target value of the metric (as a quantity).
TargetValue resource.Quantity
} }
// PodsMetricSource indicates how to scale on a metric describing each pod in // PodsMetricSource indicates how to scale on a metric describing each pod in
...@@ -168,11 +164,10 @@ type ObjectMetricSource struct { ...@@ -168,11 +164,10 @@ type ObjectMetricSource struct {
// The values will be averaged together before being compared to the target // The values will be averaged together before being compared to the target
// value. // value.
type PodsMetricSource struct { type PodsMetricSource struct {
// MetricName is the name of the metric in question // metric identifies the target metric by name and selector
MetricName string Metric MetricIdentifier
// TargetAverageValue is the target value of the average of the // target specifies the target value for the given metric
// metric across all relevant pods (as a quantity) Target MetricTarget
TargetAverageValue resource.Quantity
} }
// ResourceMetricSource indicates how to scale on a resource metric known to // ResourceMetricSource indicates how to scale on a resource metric known to
...@@ -185,38 +180,57 @@ type PodsMetricSource struct { ...@@ -185,38 +180,57 @@ type PodsMetricSource struct {
type ResourceMetricSource struct { type ResourceMetricSource struct {
// Name is the name of the resource in question. // Name is the name of the resource in question.
Name api.ResourceName Name api.ResourceName
// TargetAverageUtilization is the target value of the average of the // Target specifies the target value for the given metric
// resource metric across all relevant pods, represented as a percentage of Target MetricTarget
// the requested value of the resource for the pods.
// +optional
TargetAverageUtilization *int32
// TargetAverageValue is the target value of the average of the
// resource metric across all relevant pods, as a raw value (instead of as
// a percentage of the request), similar to the "pods" metric source type.
// +optional
TargetAverageValue *resource.Quantity
} }
// ExternalMetricSource indicates how to scale on a metric not associated with // ExternalMetricSource indicates how to scale on a metric not associated with
// any Kubernetes object (for example length of queue in cloud // any Kubernetes object (for example length of queue in cloud
// messaging service, or QPS from loadbalancer running outside of cluster). // messaging service, or QPS from loadbalancer running outside of cluster).
type ExternalMetricSource struct { type ExternalMetricSource struct {
// metricName is the name of the metric in question. // Metric identifies the target metric by name and selector
MetricName string Metric MetricIdentifier
// MetricSelector is used to identify a specific time series // Target specifies the target value for the given metric
// within a given metric. Target MetricTarget
// +optional }
MetricSelector *metav1.LabelSelector
// TargetValue is the target value of the metric (as a quantity). // MetricIdentifier defines the name and optionally selector for a metric
// Mutually exclusive with TargetAverageValue. type MetricIdentifier struct {
// +optional // Name is the name of the given metric
TargetValue *resource.Quantity Name string
// TargetAverageValue is the target per-pod value of global metric (as a quantity). // Selector is the selector for the given metric
// Mutually exclusive with TargetValue. // it is the string-encoded form of a standard kubernetes label selector
// +optional // +optional
TargetAverageValue *resource.Quantity Selector *metav1.LabelSelector
} }
// MetricTarget defines the target value, average value, or average utilization of a specific metric
type MetricTarget struct {
// Type represents whether the metric type is Utilization, Value, or AverageValue
Type MetricTargetType
// Value is the target value of the metric (as a quantity).
Value *resource.Quantity
// TargetAverageValue is the target value of the average of the
// metric across all relevant pods (as a quantity)
AverageValue *resource.Quantity
// AverageUtilization is the target value of the average of the
// resource metric across all relevant pods, represented as a percentage of
// the requested value of the resource for the pods.
// Currently only valid for Resource metric source type
AverageUtilization *int32
}
// MetricTargetType specifies the type of metric being targeted, and should be either
// "Value", "AverageValue", or "Utilization"
type MetricTargetType string
var (
UtilizationMetricType MetricTargetType = "Utilization"
ValueMetricType MetricTargetType = "Value"
AverageValueMetricType MetricTargetType = "AverageValue"
)
// HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler. // HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
type HorizontalPodAutoscalerStatus struct { type HorizontalPodAutoscalerStatus struct {
// ObservedGeneration is the most recent generation observed by this autoscaler. // ObservedGeneration is the most recent generation observed by this autoscaler.
...@@ -237,6 +251,7 @@ type HorizontalPodAutoscalerStatus struct { ...@@ -237,6 +251,7 @@ type HorizontalPodAutoscalerStatus struct {
DesiredReplicas int32 DesiredReplicas int32
// CurrentMetrics is the last read state of the metrics used by this autoscaler. // CurrentMetrics is the last read state of the metrics used by this autoscaler.
// +optional
CurrentMetrics []MetricStatus CurrentMetrics []MetricStatus
// Conditions is the set of conditions required for this autoscaler to scale its target, // Conditions is the set of conditions required for this autoscaler to scale its target,
...@@ -327,23 +342,17 @@ type MetricStatus struct { ...@@ -327,23 +342,17 @@ type MetricStatus struct {
// ObjectMetricStatus indicates the current value of a metric describing a // ObjectMetricStatus indicates the current value of a metric describing a
// kubernetes object (for example, hits-per-second on an Ingress object). // kubernetes object (for example, hits-per-second on an Ingress object).
type ObjectMetricStatus struct { type ObjectMetricStatus struct {
// Target is the described Kubernetes object. Metric MetricIdentifier
Target CrossVersionObjectReference Current MetricValueStatus
// MetricName is the name of the metric in question. DescribedObject CrossVersionObjectReference
MetricName string
// CurrentValue is the current value of the metric (as a quantity).
CurrentValue resource.Quantity
} }
// PodsMetricStatus indicates the current value of a metric describing each pod in // PodsMetricStatus indicates the current value of a metric describing each pod in
// the current scale target (for example, transactions-processed-per-second). // the current scale target (for example, transactions-processed-per-second).
type PodsMetricStatus struct { type PodsMetricStatus struct {
// MetricName is the name of the metric in question Metric MetricIdentifier
MetricName string Current MetricValueStatus
// CurrentAverageValue is the current value of the average of the
// metric across all relevant pods (as a quantity)
CurrentAverageValue resource.Quantity
} }
// ResourceMetricStatus indicates the current value of a resource metric known to // ResourceMetricStatus indicates the current value of a resource metric known to
...@@ -353,36 +362,21 @@ type PodsMetricStatus struct { ...@@ -353,36 +362,21 @@ type PodsMetricStatus struct {
// normal per-pod metrics using the "pods" source. // normal per-pod metrics using the "pods" source.
type ResourceMetricStatus struct { type ResourceMetricStatus struct {
// Name is the name of the resource in question. // Name is the name of the resource in question.
Name api.ResourceName Name api.ResourceName
// CurrentAverageUtilization is the current value of the average of the Current MetricValueStatus
// resource metric across all relevant pods, represented as a percentage of
// the requested value of the resource for the pods. It will only be
// present if `targetAverageValue` was set in the corresponding metric
// specification.
// +optional
CurrentAverageUtilization *int32
// CurrentAverageValue is the current value of the average of the
// resource metric across all relevant pods, as a raw value (instead of as
// a percentage of the request), similar to the "pods" metric source type.
// It will always be set, regardless of the corresponding metric specification.
CurrentAverageValue resource.Quantity
} }
// ExternalMetricStatus indicates the current value of a global metric // ExternalMetricStatus indicates the current value of a global metric
// not associated with any Kubernetes object. // not associated with any Kubernetes object.
type ExternalMetricStatus struct { type ExternalMetricStatus struct {
// MetricName is the name of a metric used for autoscaling in Metric MetricIdentifier
// metric system. Current MetricValueStatus
MetricName string }
// MetricSelector is used to identify a specific time series
// within a given metric. type MetricValueStatus struct {
// +optional Value *resource.Quantity
MetricSelector *metav1.LabelSelector AverageValue *resource.Quantity
// CurrentValue is the current value of the metric (as a quantity) AverageUtilization *int32
CurrentValue resource.Quantity
// CurrentAverageValue is the current value of metric averaged over autoscaled pods.
// +optional
CurrentAverageValue *resource.Quantity
} }
// +genclient // +genclient
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -17,12 +11,12 @@ go_library( ...@@ -17,12 +11,12 @@ go_library(
"zz_generated.defaults.go", "zz_generated.defaults.go",
], ],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v1", importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v1",
visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/apis/autoscaling:go_default_library", "//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/core:go_default_library", "//pkg/apis/core:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
...@@ -55,4 +49,5 @@ filegroup( ...@@ -55,4 +49,5 @@ filegroup(
name = "all-srcs", name = "all-srcs",
srcs = [":package-srcs"], srcs = [":package-srcs"],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"conversion.go",
"defaults.go", "defaults.go",
"doc.go", "doc.go",
"register.go", "register.go",
...@@ -16,12 +11,12 @@ go_library( ...@@ -16,12 +11,12 @@ go_library(
"zz_generated.defaults.go", "zz_generated.defaults.go",
], ],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1", importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1",
visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/apis/autoscaling:go_default_library", "//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/core:go_default_library", "//pkg/apis/core:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
...@@ -29,19 +24,6 @@ go_library( ...@@ -29,19 +24,6 @@ go_library(
], ],
) )
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
go_test( go_test(
name = "go_default_test", name = "go_default_test",
srcs = ["defaults_test.go"], srcs = ["defaults_test.go"],
...@@ -58,3 +40,17 @@ go_test( ...@@ -58,3 +40,17 @@ go_test(
"//vendor/k8s.io/utils/pointer:go_default_library", "//vendor/k8s.io/utils/pointer:go_default_library",
], ],
) )
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
...@@ -41,5 +41,5 @@ func init() { ...@@ -41,5 +41,5 @@ func init() {
// We only register manually written functions here. The registration of the // We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation // generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing. // makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addDefaultingFuncs) localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
} }
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"defaults.go",
"doc.go",
"register.go",
"zz_generated.conversion.go",
"zz_generated.defaults.go",
],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/autoscaling:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2beta2
import (
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/apis/autoscaling"
)
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}
func SetDefaults_HorizontalPodAutoscaler(obj *autoscalingv2beta2.HorizontalPodAutoscaler) {
if obj.Spec.MinReplicas == nil {
minReplicas := int32(1)
obj.Spec.MinReplicas = &minReplicas
}
if len(obj.Spec.Metrics) == 0 {
utilizationDefaultVal := int32(autoscaling.DefaultCPUUtilization)
obj.Spec.Metrics = []autoscalingv2beta2.MetricSpec{
{
Type: autoscalingv2beta2.ResourceMetricSourceType,
Resource: &autoscalingv2beta2.ResourceMetricSource{
Name: v1.ResourceCPU,
Target: autoscalingv2beta2.MetricTarget{
Type: autoscalingv2beta2.UtilizationMetricType,
AverageUtilization: &utilizationDefaultVal,
},
},
},
}
}
}
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/autoscaling
// +k8s:defaulter-gen=TypeMeta
package v2beta2 // import "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2beta2
import (
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const GroupName = "autoscaling"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta2"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
localSchemeBuilder = &autoscalingv2beta2.SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addDefaultingFuncs)
}
// +build !ignore_autogenerated
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by conversion-gen. DO NOT EDIT.
package v2beta2
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
func init() {
localSchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(s *runtime.Scheme) error {
return nil
}
// +build !ignore_autogenerated
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by defaulter-gen. DO NOT EDIT.
package v2beta2
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
return nil
}
...@@ -178,14 +178,16 @@ func validateMetricSpec(spec autoscaling.MetricSpec, fldPath *field.Path) field. ...@@ -178,14 +178,16 @@ func validateMetricSpec(spec autoscaling.MetricSpec, fldPath *field.Path) field.
func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Path) field.ErrorList { func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{} allErrs := field.ErrorList{}
allErrs = append(allErrs, ValidateCrossVersionObjectReference(src.Target, fldPath.Child("target"))...) allErrs = append(allErrs, ValidateCrossVersionObjectReference(src.DescribedObject, fldPath.Child("describedObject"))...)
allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
if len(src.MetricName) == 0 { if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name")) allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else {
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
} }
if src.TargetValue.Sign() != 1 { if src.Target.Value == nil && src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("targetValue"), "must specify a positive target value")) allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value or averageValue"))
} }
return allErrs return allErrs
...@@ -194,28 +196,19 @@ func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Pa ...@@ -194,28 +196,19 @@ func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Pa
func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *field.Path) field.ErrorList { func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{} allErrs := field.ErrorList{}
if len(src.MetricName) == 0 { allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name")) if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else { } else {
for _, msg := range pathvalidation.IsValidPathSegmentName(src.MetricName) { allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
allErrs = append(allErrs, field.Invalid(fldPath.Child("metricName"), src.MetricName, msg))
}
}
if src.TargetValue == nil && src.TargetAverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("targetValue"), "must set either a target value for metric or a per-pod target"))
}
if src.TargetValue != nil && src.TargetAverageValue != nil {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("targetValue"), "may not set both a target value for metric and a per-pod target"))
} }
if src.TargetAverageValue != nil && src.TargetAverageValue.Sign() != 1 { if src.Target.Value == nil && src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageValue"), src.TargetAverageValue, "must be positive")) allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value for metric or a per-pod target"))
} }
if src.TargetValue != nil && src.TargetValue.Sign() != 1 { if src.Target.Value != nil && src.Target.AverageValue != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetValue"), src.TargetValue, "must be positive")) allErrs = append(allErrs, field.Forbidden(fldPath.Child("target").Child("value"), "may not set both a target value for metric and a per-pod target"))
} }
return allErrs return allErrs
...@@ -224,12 +217,15 @@ func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *fiel ...@@ -224,12 +217,15 @@ func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *fiel
func validatePodsSource(src *autoscaling.PodsMetricSource, fldPath *field.Path) field.ErrorList { func validatePodsSource(src *autoscaling.PodsMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{} allErrs := field.ErrorList{}
if len(src.MetricName) == 0 { allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name")) if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else {
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
} }
if src.TargetAverageValue.Sign() != 1 { if src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("targetAverageValue"), "must specify a positive target value")) allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must specify a positive target averageValue"))
} }
return allErrs return allErrs
...@@ -241,22 +237,60 @@ func validateResourceSource(src *autoscaling.ResourceMetricSource, fldPath *fiel ...@@ -241,22 +237,60 @@ func validateResourceSource(src *autoscaling.ResourceMetricSource, fldPath *fiel
if len(src.Name) == 0 { if len(src.Name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a resource name")) allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a resource name"))
} }
if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else {
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
}
if src.TargetAverageUtilization == nil && src.TargetAverageValue == nil { if src.Target.AverageUtilization == nil && src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("targetAverageUtilization"), "must set either a target raw value or a target utilization")) allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageUtilization"), "must set either a target raw value or a target utilization"))
} }
if src.TargetAverageUtilization != nil && *src.TargetAverageUtilization < 1 { if src.Target.AverageUtilization != nil && src.Target.AverageValue != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageUtilization"), src.TargetAverageUtilization, "must be greater than 0")) allErrs = append(allErrs, field.Forbidden(fldPath.Child("target").Child("averageValue"), "may not set both a target raw value and a target utilization"))
} }
if src.TargetAverageUtilization != nil && src.TargetAverageValue != nil { return allErrs
allErrs = append(allErrs, field.Forbidden(fldPath.Child("targetAverageValue"), "may not set both a target raw value and a target utilization")) }
func validateMetricTarget(mt autoscaling.MetricTarget, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(mt.Type) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("type"), "must specify a metric target type"))
} }
if src.TargetAverageValue != nil && src.TargetAverageValue.Sign() != 1 { if mt.Type != autoscaling.UtilizationMetricType &&
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageValue"), src.TargetAverageValue, "must be positive")) mt.Type != autoscaling.ValueMetricType &&
mt.Type != autoscaling.AverageValueMetricType {
allErrs = append(allErrs, field.Invalid(fldPath.Child("type"), mt.Type, "must be either Utilization, Value, or AverageValue"))
} }
if mt.Value != nil && mt.Value.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("value"), mt.Value, "must be positive"))
}
if mt.AverageValue != nil && mt.AverageValue.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("averageValue"), mt.AverageValue, "must be positive"))
}
if mt.AverageUtilization != nil && *mt.AverageUtilization < 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("averageUtilization"), mt.AverageUtilization, "must be greater than 0"))
}
return allErrs
}
func validateMetricIdentifier(id autoscaling.MetricIdentifier, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(id.Name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a metric name"))
} else {
for _, msg := range pathvalidation.IsValidPathSegmentName(id.Name) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), id.Name, msg))
}
}
return allErrs return allErrs
} }
...@@ -44,21 +44,8 @@ func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference { ...@@ -44,21 +44,8 @@ func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExternalMetricSource) DeepCopyInto(out *ExternalMetricSource) { func (in *ExternalMetricSource) DeepCopyInto(out *ExternalMetricSource) {
*out = *in *out = *in
if in.MetricSelector != nil { in.Metric.DeepCopyInto(&out.Metric)
in, out := &in.MetricSelector, &out.MetricSelector in.Target.DeepCopyInto(&out.Target)
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.TargetValue != nil {
in, out := &in.TargetValue, &out.TargetValue
x := (*in).DeepCopy()
*out = &x
}
if in.TargetAverageValue != nil {
in, out := &in.TargetAverageValue, &out.TargetAverageValue
x := (*in).DeepCopy()
*out = &x
}
return return
} }
...@@ -75,17 +62,8 @@ func (in *ExternalMetricSource) DeepCopy() *ExternalMetricSource { ...@@ -75,17 +62,8 @@ func (in *ExternalMetricSource) DeepCopy() *ExternalMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExternalMetricStatus) DeepCopyInto(out *ExternalMetricStatus) { func (in *ExternalMetricStatus) DeepCopyInto(out *ExternalMetricStatus) {
*out = *in *out = *in
if in.MetricSelector != nil { in.Metric.DeepCopyInto(&out.Metric)
in, out := &in.MetricSelector, &out.MetricSelector in.Current.DeepCopyInto(&out.Current)
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
out.CurrentValue = in.CurrentValue.DeepCopy()
if in.CurrentAverageValue != nil {
in, out := &in.CurrentAverageValue, &out.CurrentAverageValue
x := (*in).DeepCopy()
*out = &x
}
return return
} }
...@@ -246,6 +224,27 @@ func (in *HorizontalPodAutoscalerStatus) DeepCopy() *HorizontalPodAutoscalerStat ...@@ -246,6 +224,27 @@ func (in *HorizontalPodAutoscalerStatus) DeepCopy() *HorizontalPodAutoscalerStat
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricIdentifier) DeepCopyInto(out *MetricIdentifier) {
*out = *in
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricIdentifier.
func (in *MetricIdentifier) DeepCopy() *MetricIdentifier {
if in == nil {
return nil
}
out := new(MetricIdentifier)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricSpec) DeepCopyInto(out *MetricSpec) { func (in *MetricSpec) DeepCopyInto(out *MetricSpec) {
*out = *in *out = *in
if in.Object != nil { if in.Object != nil {
...@@ -318,10 +317,73 @@ func (in *MetricStatus) DeepCopy() *MetricStatus { ...@@ -318,10 +317,73 @@ func (in *MetricStatus) DeepCopy() *MetricStatus {
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricTarget) DeepCopyInto(out *MetricTarget) {
*out = *in
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
if in.AverageUtilization != nil {
in, out := &in.AverageUtilization, &out.AverageUtilization
*out = new(int32)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTarget.
func (in *MetricTarget) DeepCopy() *MetricTarget {
if in == nil {
return nil
}
out := new(MetricTarget)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricValueStatus) DeepCopyInto(out *MetricValueStatus) {
*out = *in
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
if in.AverageUtilization != nil {
in, out := &in.AverageUtilization, &out.AverageUtilization
*out = new(int32)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricValueStatus.
func (in *MetricValueStatus) DeepCopy() *MetricValueStatus {
if in == nil {
return nil
}
out := new(MetricValueStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) { func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) {
*out = *in *out = *in
out.Target = in.Target out.DescribedObject = in.DescribedObject
out.TargetValue = in.TargetValue.DeepCopy() in.Target.DeepCopyInto(&out.Target)
in.Metric.DeepCopyInto(&out.Metric)
return return
} }
...@@ -338,8 +400,9 @@ func (in *ObjectMetricSource) DeepCopy() *ObjectMetricSource { ...@@ -338,8 +400,9 @@ func (in *ObjectMetricSource) DeepCopy() *ObjectMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) { func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) {
*out = *in *out = *in
out.Target = in.Target in.Metric.DeepCopyInto(&out.Metric)
out.CurrentValue = in.CurrentValue.DeepCopy() in.Current.DeepCopyInto(&out.Current)
out.DescribedObject = in.DescribedObject
return return
} }
...@@ -356,7 +419,8 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus { ...@@ -356,7 +419,8 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) { func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) {
*out = *in *out = *in
out.TargetAverageValue = in.TargetAverageValue.DeepCopy() in.Metric.DeepCopyInto(&out.Metric)
in.Target.DeepCopyInto(&out.Target)
return return
} }
...@@ -373,7 +437,8 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource { ...@@ -373,7 +437,8 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) { func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) {
*out = *in *out = *in
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy() in.Metric.DeepCopyInto(&out.Metric)
in.Current.DeepCopyInto(&out.Current)
return return
} }
...@@ -390,16 +455,7 @@ func (in *PodsMetricStatus) DeepCopy() *PodsMetricStatus { ...@@ -390,16 +455,7 @@ func (in *PodsMetricStatus) DeepCopy() *PodsMetricStatus {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceMetricSource) DeepCopyInto(out *ResourceMetricSource) { func (in *ResourceMetricSource) DeepCopyInto(out *ResourceMetricSource) {
*out = *in *out = *in
if in.TargetAverageUtilization != nil { in.Target.DeepCopyInto(&out.Target)
in, out := &in.TargetAverageUtilization, &out.TargetAverageUtilization
*out = new(int32)
**out = **in
}
if in.TargetAverageValue != nil {
in, out := &in.TargetAverageValue, &out.TargetAverageValue
x := (*in).DeepCopy()
*out = &x
}
return return
} }
...@@ -416,12 +472,7 @@ func (in *ResourceMetricSource) DeepCopy() *ResourceMetricSource { ...@@ -416,12 +472,7 @@ func (in *ResourceMetricSource) DeepCopy() *ResourceMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceMetricStatus) DeepCopyInto(out *ResourceMetricStatus) { func (in *ResourceMetricStatus) DeepCopyInto(out *ResourceMetricStatus) {
*out = *in *out = *in
if in.CurrentAverageUtilization != nil { in.Current.DeepCopyInto(&out.Current)
in, out := &in.CurrentAverageUtilization, &out.CurrentAverageUtilization
*out = new(int32)
**out = **in
}
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
return return
} }
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -15,13 +9,14 @@ go_library( ...@@ -15,13 +9,14 @@ go_library(
"replica_calculator.go", "replica_calculator.go",
], ],
importpath = "k8s.io/kubernetes/pkg/controller/podautoscaler", importpath = "k8s.io/kubernetes/pkg/controller/podautoscaler",
visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/api/legacyscheme:go_default_library", "//pkg/api/legacyscheme:go_default_library",
"//pkg/api/v1/pod:go_default_library", "//pkg/api/v1/pod:go_default_library",
"//pkg/controller:go_default_library", "//pkg/controller:go_default_library",
"//pkg/controller/podautoscaler/metrics:go_default_library", "//pkg/controller/podautoscaler/metrics:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
...@@ -66,6 +61,7 @@ go_test( ...@@ -66,6 +61,7 @@ go_test(
"//pkg/controller/podautoscaler/metrics:go_default_library", "//pkg/controller/podautoscaler/metrics:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta/testrestmapper:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/meta/testrestmapper:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
...@@ -80,7 +76,7 @@ go_test( ...@@ -80,7 +76,7 @@ go_test(
"//staging/src/k8s.io/client-go/rest:go_default_library", "//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/client-go/scale/fake:go_default_library", "//staging/src/k8s.io/client-go/scale/fake:go_default_library",
"//staging/src/k8s.io/client-go/testing:go_default_library", "//staging/src/k8s.io/client-go/testing:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta2:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1:go_default_library",
...@@ -107,4 +103,5 @@ filegroup( ...@@ -107,4 +103,5 @@ filegroup(
"//pkg/controller/podautoscaler/metrics:all-srcs", "//pkg/controller/podautoscaler/metrics:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -210,7 +210,7 @@ func (tc *legacyReplicaCalcTestCase) runTest(t *testing.T) { ...@@ -210,7 +210,7 @@ func (tc *legacyReplicaCalcTestCase) runTest(t *testing.T) {
assert.True(t, tc.timestamp.Equal(outTimestamp), "timestamp should be as expected") assert.True(t, tc.timestamp.Equal(outTimestamp), "timestamp should be as expected")
} else { } else {
outReplicas, outUtilization, outTimestamp, err := replicaCalc.GetMetricReplicas(tc.currentReplicas, tc.metric.targetUtilization, tc.metric.name, testNamespace, selector) outReplicas, outUtilization, outTimestamp, err := replicaCalc.GetMetricReplicas(tc.currentReplicas, tc.metric.targetUtilization, tc.metric.name, testNamespace, selector, nil)
if tc.expectedError != nil { if tc.expectedError != nil {
require.Error(t, err, "there should be an error calculating the replica count") require.Error(t, err, "there should be an error calculating the replica count")
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -15,15 +9,16 @@ go_library( ...@@ -15,15 +9,16 @@ go_library(
"utilization.go", "utilization.go",
], ],
importpath = "k8s.io/kubernetes/pkg/controller/podautoscaler/metrics", importpath = "k8s.io/kubernetes/pkg/controller/podautoscaler/metrics",
visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta2:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/client/custom_metrics:go_default_library", "//staging/src/k8s.io/metrics/pkg/client/custom_metrics:go_default_library",
...@@ -44,7 +39,7 @@ go_test( ...@@ -44,7 +39,7 @@ go_test(
deps = [ deps = [
"//pkg/api/legacyscheme:go_default_library", "//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/extensions/install:go_default_library", "//pkg/apis/extensions/install:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta/testrestmapper:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/meta/testrestmapper:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
...@@ -55,7 +50,7 @@ go_test( ...@@ -55,7 +50,7 @@ go_test(
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library", "//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/client-go/testing:go_default_library", "//staging/src/k8s.io/client-go/testing:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta2:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1:go_default_library",
...@@ -78,4 +73,5 @@ filegroup( ...@@ -78,4 +73,5 @@ filegroup(
name = "all-srcs", name = "all-srcs",
srcs = [":package-srcs"], srcs = [":package-srcs"],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -19,7 +19,7 @@ package metrics ...@@ -19,7 +19,7 @@ package metrics
import ( import (
"time" "time"
autoscaling "k8s.io/api/autoscaling/v2beta1" autoscaling "k8s.io/api/autoscaling/v2beta2"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
) )
...@@ -37,11 +37,11 @@ type MetricsClient interface { ...@@ -37,11 +37,11 @@ type MetricsClient interface {
// GetRawMetric gets the given metric (and an associated oldest timestamp) // GetRawMetric gets the given metric (and an associated oldest timestamp)
// for all pods matching the specified selector in the given namespace // for all pods matching the specified selector in the given namespace
GetRawMetric(metricName string, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (PodMetricsInfo, time.Time, error)
// GetObjectMetric gets the given metric (and an associated timestamp) for the given // GetObjectMetric gets the given metric (and an associated timestamp) for the given
// object in the given namespace // object in the given namespace
GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference) (int64, time.Time, error) GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error)
// GetExternalMetric gets all the values of a given external metric // GetExternalMetric gets all the values of a given external metric
// that match the specified selector. // that match the specified selector.
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
heapster "k8s.io/heapster/metrics/api/v1/types" heapster "k8s.io/heapster/metrics/api/v1/types"
metricsapi "k8s.io/metrics/pkg/apis/metrics/v1alpha1" metricsapi "k8s.io/metrics/pkg/apis/metrics/v1alpha1"
autoscaling "k8s.io/api/autoscaling/v2beta1" autoscaling "k8s.io/api/autoscaling/v2beta2"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
...@@ -109,7 +109,7 @@ func (h *HeapsterMetricsClient) GetResourceMetric(resource v1.ResourceName, name ...@@ -109,7 +109,7 @@ func (h *HeapsterMetricsClient) GetResourceMetric(resource v1.ResourceName, name
return res, timestamp, nil return res, timestamp, nil
} }
func (h *HeapsterMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) { func (h *HeapsterMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (PodMetricsInfo, time.Time, error) {
podList, err := h.podsGetter.Pods(namespace).List(metav1.ListOptions{LabelSelector: selector.String()}) podList, err := h.podsGetter.Pods(namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
if err != nil { if err != nil {
return nil, time.Time{}, fmt.Errorf("failed to get pod list while fetching metrics: %v", err) return nil, time.Time{}, fmt.Errorf("failed to get pod list while fetching metrics: %v", err)
...@@ -173,7 +173,7 @@ func (h *HeapsterMetricsClient) GetRawMetric(metricName string, namespace string ...@@ -173,7 +173,7 @@ func (h *HeapsterMetricsClient) GetRawMetric(metricName string, namespace string
return res, *timestamp, nil return res, *timestamp, nil
} }
func (h *HeapsterMetricsClient) GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference) (int64, time.Time, error) { func (h *HeapsterMetricsClient) GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error) {
return 0, time.Time{}, fmt.Errorf("object metrics are not yet supported") return 0, time.Time{}, fmt.Errorf("object metrics are not yet supported")
} }
......
...@@ -71,10 +71,11 @@ type testCase struct { ...@@ -71,10 +71,11 @@ type testCase struct {
reportedMetricsPoints [][]metricPoint reportedMetricsPoints [][]metricPoint
reportedPodMetrics [][]int64 reportedPodMetrics [][]int64
namespace string namespace string
selector labels.Selector selector labels.Selector
resourceName v1.ResourceName metricSelector labels.Selector
metricName string resourceName v1.ResourceName
metricName string
} }
func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
...@@ -211,7 +212,7 @@ func (tc *testCase) runTest(t *testing.T) { ...@@ -211,7 +212,7 @@ func (tc *testCase) runTest(t *testing.T) {
info, timestamp, err := metricsClient.GetResourceMetric(tc.resourceName, tc.namespace, tc.selector) info, timestamp, err := metricsClient.GetResourceMetric(tc.resourceName, tc.namespace, tc.selector)
tc.verifyResults(t, info, timestamp, err) tc.verifyResults(t, info, timestamp, err)
} else { } else {
info, timestamp, err := metricsClient.GetRawMetric(tc.metricName, tc.namespace, tc.selector) info, timestamp, err := metricsClient.GetRawMetric(tc.metricName, tc.namespace, tc.selector, tc.metricSelector)
tc.verifyResults(t, info, timestamp, err) tc.verifyResults(t, info, timestamp, err)
} }
} }
......
...@@ -22,12 +22,12 @@ import ( ...@@ -22,12 +22,12 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
autoscaling "k8s.io/api/autoscaling/v2beta1" autoscaling "k8s.io/api/autoscaling/v2beta2"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
customapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1" customapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta2"
resourceclient "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" resourceclient "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1"
customclient "k8s.io/metrics/pkg/client/custom_metrics" customclient "k8s.io/metrics/pkg/client/custom_metrics"
externalclient "k8s.io/metrics/pkg/client/external_metrics" externalclient "k8s.io/metrics/pkg/client/external_metrics"
...@@ -101,8 +101,8 @@ type customMetricsClient struct { ...@@ -101,8 +101,8 @@ type customMetricsClient struct {
// GetRawMetric gets the given metric (and an associated oldest timestamp) // GetRawMetric gets the given metric (and an associated oldest timestamp)
// for all pods matching the specified selector in the given namespace // for all pods matching the specified selector in the given namespace
func (c *customMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) { func (c *customMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (PodMetricsInfo, time.Time, error) {
metrics, err := c.client.NamespacedMetrics(namespace).GetForObjects(schema.GroupKind{Kind: "Pod"}, selector, metricName) metrics, err := c.client.NamespacedMetrics(namespace).GetForObjects(schema.GroupKind{Kind: "Pod"}, selector, metricName, metricSelector)
if err != nil { if err != nil {
return nil, time.Time{}, fmt.Errorf("unable to fetch metrics from custom metrics API: %v", err) return nil, time.Time{}, fmt.Errorf("unable to fetch metrics from custom metrics API: %v", err)
} }
...@@ -123,7 +123,7 @@ func (c *customMetricsClient) GetRawMetric(metricName string, namespace string, ...@@ -123,7 +123,7 @@ func (c *customMetricsClient) GetRawMetric(metricName string, namespace string,
// GetObjectMetric gets the given metric (and an associated timestamp) for the given // GetObjectMetric gets the given metric (and an associated timestamp) for the given
// object in the given namespace // object in the given namespace
func (c *customMetricsClient) GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference) (int64, time.Time, error) { func (c *customMetricsClient) GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error) {
gvk := schema.FromAPIVersionAndKind(objectRef.APIVersion, objectRef.Kind) gvk := schema.FromAPIVersionAndKind(objectRef.APIVersion, objectRef.Kind)
var metricValue *customapi.MetricValue var metricValue *customapi.MetricValue
var err error var err error
...@@ -131,9 +131,9 @@ func (c *customMetricsClient) GetObjectMetric(metricName string, namespace strin ...@@ -131,9 +131,9 @@ func (c *customMetricsClient) GetObjectMetric(metricName string, namespace strin
// handle namespace separately // handle namespace separately
// NB: we ignore namespace name here, since CrossVersionObjectReference isn't // NB: we ignore namespace name here, since CrossVersionObjectReference isn't
// supposed to allow you to escape your namespace // supposed to allow you to escape your namespace
metricValue, err = c.client.RootScopedMetrics().GetForObject(gvk.GroupKind(), namespace, metricName) metricValue, err = c.client.RootScopedMetrics().GetForObject(gvk.GroupKind(), namespace, metricName, metricSelector)
} else { } else {
metricValue, err = c.client.NamespacedMetrics(namespace).GetForObject(gvk.GroupKind(), objectRef.Name, metricName) metricValue, err = c.client.NamespacedMetrics(namespace).GetForObject(gvk.GroupKind(), objectRef.Name, metricName, metricSelector)
} }
if err != nil { if err != nil {
......
...@@ -21,7 +21,7 @@ import ( ...@@ -21,7 +21,7 @@ import (
"testing" "testing"
"time" "time"
autoscalingapi "k8s.io/api/autoscaling/v2beta1" autoscalingapi "k8s.io/api/autoscaling/v2beta2"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta/testrestmapper" "k8s.io/apimachinery/pkg/api/meta/testrestmapper"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
...@@ -32,7 +32,7 @@ import ( ...@@ -32,7 +32,7 @@ import (
core "k8s.io/client-go/testing" core "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
_ "k8s.io/kubernetes/pkg/apis/extensions/install" _ "k8s.io/kubernetes/pkg/apis/extensions/install"
cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1" cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta2"
emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1" emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1"
metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1" metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1"
metricsfake "k8s.io/metrics/pkg/client/clientset/versioned/fake" metricsfake "k8s.io/metrics/pkg/client/clientset/versioned/fake"
...@@ -143,9 +143,11 @@ func (tc *restClientTestCase) prepareTestClient(t *testing.T) (*metricsfake.Clie ...@@ -143,9 +143,11 @@ func (tc *restClientTestCase) prepareTestClient(t *testing.T) (*metricsfake.Clie
APIVersion: "v1", APIVersion: "v1",
Name: fmt.Sprintf("%s-%d", podNamePrefix, i), Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
}, },
Value: *resource.NewMilliQuantity(int64(metricPoint.level), resource.DecimalSI), Value: *resource.NewMilliQuantity(int64(metricPoint.level), resource.DecimalSI),
Timestamp: metav1.Time{Time: timestamp}, Timestamp: metav1.Time{Time: timestamp},
MetricName: tc.metricName, Metric: cmapi.MetricIdentifier{
Name: tc.metricName,
},
} }
metrics.Items = append(metrics.Items, metric) metrics.Items = append(metrics.Items, metric)
...@@ -176,9 +178,11 @@ func (tc *restClientTestCase) prepareTestClient(t *testing.T) (*metricsfake.Clie ...@@ -176,9 +178,11 @@ func (tc *restClientTestCase) prepareTestClient(t *testing.T) (*metricsfake.Clie
APIVersion: tc.singleObject.APIVersion, APIVersion: tc.singleObject.APIVersion,
Name: tc.singleObject.Name, Name: tc.singleObject.Name,
}, },
Timestamp: metav1.Time{Time: timestamp}, Timestamp: metav1.Time{Time: timestamp},
MetricName: tc.metricName, Metric: cmapi.MetricIdentifier{
Value: *resource.NewMilliQuantity(int64(metricPoint.level), resource.DecimalSI), Name: tc.metricName,
},
Value: *resource.NewMilliQuantity(int64(metricPoint.level), resource.DecimalSI),
}, },
}, },
} }
...@@ -227,10 +231,10 @@ func (tc *restClientTestCase) runTest(t *testing.T) { ...@@ -227,10 +231,10 @@ func (tc *restClientTestCase) runTest(t *testing.T) {
} }
tc.verifyResults(t, info, timestamp, err) tc.verifyResults(t, info, timestamp, err)
} else if tc.singleObject == nil { } else if tc.singleObject == nil {
info, timestamp, err := metricsClient.GetRawMetric(tc.metricName, tc.namespace, tc.selector) info, timestamp, err := metricsClient.GetRawMetric(tc.metricName, tc.namespace, tc.selector, tc.metricLabelSelector)
tc.verifyResults(t, info, timestamp, err) tc.verifyResults(t, info, timestamp, err)
} else { } else {
val, timestamp, err := metricsClient.GetObjectMetric(tc.metricName, tc.namespace, tc.singleObject) val, timestamp, err := metricsClient.GetObjectMetric(tc.metricName, tc.namespace, tc.singleObject, tc.metricLabelSelector)
info := PodMetricsInfo{tc.singleObject.Name: val} info := PodMetricsInfo{tc.singleObject.Name: val}
tc.verifyResults(t, info, timestamp, err) tc.verifyResults(t, info, timestamp, err)
} }
......
...@@ -22,7 +22,7 @@ import ( ...@@ -22,7 +22,7 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
autoscaling "k8s.io/api/autoscaling/v2beta1" autoscaling "k8s.io/api/autoscaling/v2beta2"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
...@@ -159,8 +159,8 @@ func (c *ReplicaCalculator) GetRawResourceReplicas(currentReplicas int32, target ...@@ -159,8 +159,8 @@ func (c *ReplicaCalculator) GetRawResourceReplicas(currentReplicas int32, target
// GetMetricReplicas calculates the desired replica count based on a target metric utilization // GetMetricReplicas calculates the desired replica count based on a target metric utilization
// (as a milli-value) for pods matching the given selector in the given namespace, and the // (as a milli-value) for pods matching the given selector in the given namespace, and the
// current replica count // current replica count
func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, namespace string, selector labels.Selector) (replicaCount int32, utilization int64, timestamp time.Time, err error) { func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (replicaCount int32, utilization int64, timestamp time.Time, err error) {
metrics, timestamp, err := c.metricsClient.GetRawMetric(metricName, namespace, selector) metrics, timestamp, err := c.metricsClient.GetRawMetric(metricName, namespace, selector, metricSelector)
if err != nil { if err != nil {
return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v", metricName, err) return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v", metricName, err)
} }
...@@ -238,8 +238,8 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet ...@@ -238,8 +238,8 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet
// GetObjectMetricReplicas calculates the desired replica count based on a target metric utilization (as a milli-value) // GetObjectMetricReplicas calculates the desired replica count based on a target metric utilization (as a milli-value)
// for the given object in the given namespace, and the current replica count. // for the given object in the given namespace, and the current replica count.
func (c *ReplicaCalculator) GetObjectMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, selector labels.Selector) (replicaCount int32, utilization int64, timestamp time.Time, err error) { func (c *ReplicaCalculator) GetObjectMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, selector labels.Selector, metricSelector labels.Selector) (replicaCount int32, utilization int64, timestamp time.Time, err error) {
utilization, timestamp, err = c.metricsClient.GetObjectMetric(metricName, namespace, objectRef) utilization, timestamp, err = c.metricsClient.GetObjectMetric(metricName, namespace, objectRef, metricSelector)
if err != nil { if err != nil {
return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v on %s %s/%s", metricName, objectRef.Kind, namespace, objectRef.Name, err) return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v on %s %s/%s", metricName, objectRef.Kind, namespace, objectRef.Name, err)
} }
......
...@@ -22,20 +22,20 @@ import ( ...@@ -22,20 +22,20 @@ import (
"testing" "testing"
"time" "time"
autoscalingv2 "k8s.io/api/autoscaling/v2beta1" autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta/testrestmapper" "k8s.io/apimachinery/pkg/api/meta/testrestmapper"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
core "k8s.io/client-go/testing" core "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/controller/podautoscaler/metrics"
metricsclient "k8s.io/kubernetes/pkg/controller/podautoscaler/metrics" metricsclient "k8s.io/kubernetes/pkg/controller/podautoscaler/metrics"
cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1" cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta2"
emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1" emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1"
metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1" metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1"
metricsfake "k8s.io/metrics/pkg/client/clientset/versioned/fake" metricsfake "k8s.io/metrics/pkg/client/clientset/versioned/fake"
...@@ -86,8 +86,9 @@ type replicaCalcTestCase struct { ...@@ -86,8 +86,9 @@ type replicaCalcTestCase struct {
timestamp time.Time timestamp time.Time
resource *resourceInfo resource *resourceInfo
metric *metricInfo metric *metricInfo
metricLabelSelector labels.Selector
podReadiness []v1.ConditionStatus podReadiness []v1.ConditionStatus
podStartTime []metav1.Time podStartTime []metav1.Time
...@@ -235,9 +236,11 @@ func (tc *replicaCalcTestCase) prepareTestCMClient(t *testing.T) *cmfake.FakeCus ...@@ -235,9 +236,11 @@ func (tc *replicaCalcTestCase) prepareTestCMClient(t *testing.T) *cmfake.FakeCus
Name: fmt.Sprintf("%s-%d", podNamePrefix, i), Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
Namespace: testNamespace, Namespace: testNamespace,
}, },
Timestamp: metav1.Time{Time: tc.timestamp}, Timestamp: metav1.Time{Time: tc.timestamp},
MetricName: tc.metric.name, Metric: cmapi.MetricIdentifier{
Value: *resource.NewMilliQuantity(level, resource.DecimalSI), Name: tc.metric.name,
},
Value: *resource.NewMilliQuantity(level, resource.DecimalSI),
} }
metrics.Items = append(metrics.Items, podMetric) metrics.Items = append(metrics.Items, podMetric)
} }
...@@ -265,9 +268,11 @@ func (tc *replicaCalcTestCase) prepareTestCMClient(t *testing.T) *cmfake.FakeCus ...@@ -265,9 +268,11 @@ func (tc *replicaCalcTestCase) prepareTestCMClient(t *testing.T) *cmfake.FakeCus
APIVersion: tc.metric.singleObject.APIVersion, APIVersion: tc.metric.singleObject.APIVersion,
Name: name, Name: name,
}, },
Timestamp: metav1.Time{Time: tc.timestamp}, Timestamp: metav1.Time{Time: tc.timestamp},
MetricName: tc.metric.name, Metric: cmapi.MetricIdentifier{
Value: *resource.NewMilliQuantity(int64(tc.metric.levels[0]), resource.DecimalSI), Name: tc.metric.name,
},
Value: *resource.NewMilliQuantity(int64(tc.metric.levels[0]), resource.DecimalSI),
}, },
} }
...@@ -322,7 +327,7 @@ func (tc *replicaCalcTestCase) prepareTestClient(t *testing.T) (*fake.Clientset, ...@@ -322,7 +327,7 @@ func (tc *replicaCalcTestCase) prepareTestClient(t *testing.T) (*fake.Clientset,
func (tc *replicaCalcTestCase) runTest(t *testing.T) { func (tc *replicaCalcTestCase) runTest(t *testing.T) {
testClient, testMetricsClient, testCMClient, testEMClient := tc.prepareTestClient(t) testClient, testMetricsClient, testCMClient, testEMClient := tc.prepareTestClient(t)
metricsClient := metrics.NewRESTMetricsClient(testMetricsClient.MetricsV1beta1(), testCMClient, testEMClient) metricsClient := metricsclient.NewRESTMetricsClient(testMetricsClient.MetricsV1beta1(), testCMClient, testEMClient)
replicaCalc := NewReplicaCalculator(metricsClient, testClient.Core(), defaultTestingTolerance, defaultTestingCpuTaintAfterStart, defaultTestingDelayOfInitialReadinessStatus) replicaCalc := NewReplicaCalculator(metricsClient, testClient.Core(), defaultTestingTolerance, defaultTestingCpuTaintAfterStart, defaultTestingDelayOfInitialReadinessStatus)
...@@ -357,7 +362,7 @@ func (tc *replicaCalcTestCase) runTest(t *testing.T) { ...@@ -357,7 +362,7 @@ func (tc *replicaCalcTestCase) runTest(t *testing.T) {
if tc.metric.singleObject == nil { if tc.metric.singleObject == nil {
t.Fatal("Metric specified as objectMetric but metric.singleObject is nil.") t.Fatal("Metric specified as objectMetric but metric.singleObject is nil.")
} }
outReplicas, outUtilization, outTimestamp, err = replicaCalc.GetObjectMetricReplicas(tc.currentReplicas, tc.metric.targetUtilization, tc.metric.name, testNamespace, tc.metric.singleObject, selector) outReplicas, outUtilization, outTimestamp, err = replicaCalc.GetObjectMetricReplicas(tc.currentReplicas, tc.metric.targetUtilization, tc.metric.name, testNamespace, tc.metric.singleObject, selector, nil)
case externalMetric: case externalMetric:
if tc.metric.selector == nil { if tc.metric.selector == nil {
t.Fatal("Metric specified as externalMetric but metric.selector is nil.") t.Fatal("Metric specified as externalMetric but metric.selector is nil.")
...@@ -376,7 +381,7 @@ func (tc *replicaCalcTestCase) runTest(t *testing.T) { ...@@ -376,7 +381,7 @@ func (tc *replicaCalcTestCase) runTest(t *testing.T) {
outReplicas, outUtilization, outTimestamp, err = replicaCalc.GetExternalPerPodMetricReplicas(tc.currentReplicas, tc.metric.perPodTargetUtilization, tc.metric.name, testNamespace, tc.metric.selector) outReplicas, outUtilization, outTimestamp, err = replicaCalc.GetExternalPerPodMetricReplicas(tc.currentReplicas, tc.metric.perPodTargetUtilization, tc.metric.name, testNamespace, tc.metric.selector)
case podMetric: case podMetric:
outReplicas, outUtilization, outTimestamp, err = replicaCalc.GetMetricReplicas(tc.currentReplicas, tc.metric.targetUtilization, tc.metric.name, testNamespace, selector) outReplicas, outUtilization, outTimestamp, err = replicaCalc.GetMetricReplicas(tc.currentReplicas, tc.metric.targetUtilization, tc.metric.name, testNamespace, selector, nil)
default: default:
t.Fatalf("Unknown metric type: %d", tc.metric.metricType) t.Fatalf("Unknown metric type: %d", tc.metric.metricType)
} }
......
...@@ -33,6 +33,7 @@ openapi_library( ...@@ -33,6 +33,7 @@ openapi_library(
"k8s.io/api/authorization/v1beta1", "k8s.io/api/authorization/v1beta1",
"k8s.io/api/autoscaling/v1", "k8s.io/api/autoscaling/v1",
"k8s.io/api/autoscaling/v2beta1", "k8s.io/api/autoscaling/v2beta1",
"k8s.io/api/autoscaling/v2beta2",
"k8s.io/api/batch/v1", "k8s.io/api/batch/v1",
"k8s.io/api/batch/v1beta1", "k8s.io/api/batch/v1beta1",
"k8s.io/api/batch/v2alpha1", "k8s.io/api/batch/v2alpha1",
...@@ -72,6 +73,7 @@ openapi_library( ...@@ -72,6 +73,7 @@ openapi_library(
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1", "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1",
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1", "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1",
"k8s.io/metrics/pkg/apis/custom_metrics/v1beta1", "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1",
"k8s.io/metrics/pkg/apis/custom_metrics/v1beta2",
"k8s.io/metrics/pkg/apis/external_metrics/v1beta1", "k8s.io/metrics/pkg/apis/external_metrics/v1beta1",
"k8s.io/metrics/pkg/apis/metrics/v1alpha1", "k8s.io/metrics/pkg/apis/metrics/v1alpha1",
"k8s.io/metrics/pkg/apis/metrics/v1beta1", "k8s.io/metrics/pkg/apis/metrics/v1beta1",
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -18,6 +12,7 @@ go_library( ...@@ -18,6 +12,7 @@ go_library(
"services.go", "services.go",
], ],
importpath = "k8s.io/kubernetes/pkg/master", importpath = "k8s.io/kubernetes/pkg/master",
visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/apis/admission/install:go_default_library", "//pkg/apis/admission/install:go_default_library",
"//pkg/apis/admissionregistration/install:go_default_library", "//pkg/apis/admissionregistration/install:go_default_library",
...@@ -83,6 +78,7 @@ go_library( ...@@ -83,6 +78,7 @@ go_library(
"//staging/src/k8s.io/api/authorization/v1beta1:go_default_library", "//staging/src/k8s.io/api/authorization/v1beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/batch/v1:go_default_library", "//staging/src/k8s.io/api/batch/v1:go_default_library",
"//staging/src/k8s.io/api/batch/v1beta1:go_default_library", "//staging/src/k8s.io/api/batch/v1beta1:go_default_library",
"//staging/src/k8s.io/api/batch/v2alpha1:go_default_library", "//staging/src/k8s.io/api/batch/v2alpha1:go_default_library",
...@@ -199,4 +195,5 @@ filegroup( ...@@ -199,4 +195,5 @@ filegroup(
"//pkg/master/tunneler:all-srcs", "//pkg/master/tunneler:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -35,6 +35,7 @@ import ( ...@@ -35,6 +35,7 @@ import (
authorizationapiv1beta1 "k8s.io/api/authorization/v1beta1" authorizationapiv1beta1 "k8s.io/api/authorization/v1beta1"
autoscalingapiv1 "k8s.io/api/autoscaling/v1" autoscalingapiv1 "k8s.io/api/autoscaling/v1"
autoscalingapiv2beta1 "k8s.io/api/autoscaling/v2beta1" autoscalingapiv2beta1 "k8s.io/api/autoscaling/v2beta1"
autoscalingapiv2beta2 "k8s.io/api/autoscaling/v2beta2"
batchapiv1 "k8s.io/api/batch/v1" batchapiv1 "k8s.io/api/batch/v1"
batchapiv1beta1 "k8s.io/api/batch/v1beta1" batchapiv1beta1 "k8s.io/api/batch/v1beta1"
batchapiv2alpha1 "k8s.io/api/batch/v2alpha1" batchapiv2alpha1 "k8s.io/api/batch/v2alpha1"
...@@ -487,6 +488,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig { ...@@ -487,6 +488,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
authorizationapiv1beta1.SchemeGroupVersion, authorizationapiv1beta1.SchemeGroupVersion,
autoscalingapiv1.SchemeGroupVersion, autoscalingapiv1.SchemeGroupVersion,
autoscalingapiv2beta1.SchemeGroupVersion, autoscalingapiv2beta1.SchemeGroupVersion,
autoscalingapiv2beta2.SchemeGroupVersion,
batchapiv1.SchemeGroupVersion, batchapiv1.SchemeGroupVersion,
batchapiv1beta1.SchemeGroupVersion, batchapiv1beta1.SchemeGroupVersion,
certificatesapiv1beta1.SchemeGroupVersion, certificatesapiv1beta1.SchemeGroupVersion,
......
...@@ -2972,50 +2972,50 @@ func describeHorizontalPodAutoscaler(hpa *autoscaling.HorizontalPodAutoscaler, e ...@@ -2972,50 +2972,50 @@ func describeHorizontalPodAutoscaler(hpa *autoscaling.HorizontalPodAutoscaler, e
for i, metric := range hpa.Spec.Metrics { for i, metric := range hpa.Spec.Metrics {
switch metric.Type { switch metric.Type {
case autoscaling.ExternalMetricSourceType: case autoscaling.ExternalMetricSourceType:
if metric.External.TargetAverageValue != nil { if metric.External.Target.AverageValue != nil {
current := "<unknown>" current := "<unknown>"
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil && if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil &&
hpa.Status.CurrentMetrics[i].External.CurrentAverageValue != nil { &hpa.Status.CurrentMetrics[i].External.Current.AverageValue != nil {
current = hpa.Status.CurrentMetrics[i].External.CurrentAverageValue.String() current = hpa.Status.CurrentMetrics[i].External.Current.AverageValue.String()
} }
w.Write(LEVEL_1, "%q (target average value):\t%s / %s\n", metric.External.MetricName, current, metric.External.TargetAverageValue.String()) w.Write(LEVEL_1, "%q (target average value):\t%s / %s\n", metric.External.Metric.Name, current, metric.External.Target.AverageValue.String())
} else { } else {
current := "<unknown>" current := "<unknown>"
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil { if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil {
current = hpa.Status.CurrentMetrics[i].External.CurrentValue.String() current = hpa.Status.CurrentMetrics[i].External.Current.Value.String()
} }
w.Write(LEVEL_1, "%q (target value):\t%s / %s\n", metric.External.MetricName, current, metric.External.TargetValue.String()) w.Write(LEVEL_1, "%q (target value):\t%s / %s\n", metric.External.Metric.Name, current, metric.External.Target.Value.String())
} }
case autoscaling.PodsMetricSourceType: case autoscaling.PodsMetricSourceType:
current := "<unknown>" current := "<unknown>"
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Pods != nil { if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Pods != nil {
current = hpa.Status.CurrentMetrics[i].Pods.CurrentAverageValue.String() current = hpa.Status.CurrentMetrics[i].Pods.Current.AverageValue.String()
} }
w.Write(LEVEL_1, "%q on pods:\t%s / %s\n", metric.Pods.MetricName, current, metric.Pods.TargetAverageValue.String()) w.Write(LEVEL_1, "%q on pods:\t%s / %s\n", metric.Pods.Metric.Name, current, metric.Pods.Target.AverageValue.String())
case autoscaling.ObjectMetricSourceType: case autoscaling.ObjectMetricSourceType:
current := "<unknown>" current := "<unknown>"
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Object != nil { if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Object != nil {
current = hpa.Status.CurrentMetrics[i].Object.CurrentValue.String() current = hpa.Status.CurrentMetrics[i].Object.Current.Value.String()
} }
w.Write(LEVEL_1, "%q on %s/%s:\t%s / %s\n", metric.Object.MetricName, metric.Object.Target.Kind, metric.Object.Target.Name, current, metric.Object.TargetValue.String()) w.Write(LEVEL_1, "%q on %s/%s:\t%s / %s\n", metric.Object.Metric.Name, metric.Object.DescribedObject.Kind, metric.Object.DescribedObject.Name, current, metric.Object.Target.Value.String())
case autoscaling.ResourceMetricSourceType: case autoscaling.ResourceMetricSourceType:
w.Write(LEVEL_1, "resource %s on pods", string(metric.Resource.Name)) w.Write(LEVEL_1, "resource %s on pods", string(metric.Resource.Name))
if metric.Resource.TargetAverageValue != nil { if metric.Resource.Target.AverageValue != nil {
current := "<unknown>" current := "<unknown>"
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil { if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil {
current = hpa.Status.CurrentMetrics[i].Resource.CurrentAverageValue.String() current = hpa.Status.CurrentMetrics[i].Resource.Current.AverageValue.String()
} }
w.Write(LEVEL_0, ":\t%s / %s\n", current, metric.Resource.TargetAverageValue.String()) w.Write(LEVEL_0, ":\t%s / %s\n", current, metric.Resource.Target.AverageValue.String())
} else { } else {
current := "<unknown>" current := "<unknown>"
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil && hpa.Status.CurrentMetrics[i].Resource.CurrentAverageUtilization != nil { if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil && hpa.Status.CurrentMetrics[i].Resource.Current.AverageUtilization != nil {
current = fmt.Sprintf("%d%% (%s)", *hpa.Status.CurrentMetrics[i].Resource.CurrentAverageUtilization, hpa.Status.CurrentMetrics[i].Resource.CurrentAverageValue.String()) current = fmt.Sprintf("%d%% (%s)", *hpa.Status.CurrentMetrics[i].Resource.Current.AverageUtilization, hpa.Status.CurrentMetrics[i].Resource.Current.AverageValue.String())
} }
target := "<auto>" target := "<auto>"
if metric.Resource.TargetAverageUtilization != nil { if metric.Resource.Target.AverageUtilization != nil {
target = fmt.Sprintf("%d%%", *metric.Resource.TargetAverageUtilization) target = fmt.Sprintf("%d%%", *metric.Resource.Target.AverageUtilization)
} }
w.Write(LEVEL_1, "(as a percentage of request):\t%s / %s\n", current, target) w.Write(LEVEL_1, "(as a percentage of request):\t%s / %s\n", current, target)
} }
......
...@@ -1580,47 +1580,47 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met ...@@ -1580,47 +1580,47 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met
for i, spec := range specs { for i, spec := range specs {
switch spec.Type { switch spec.Type {
case autoscaling.ExternalMetricSourceType: case autoscaling.ExternalMetricSourceType:
if spec.External.TargetAverageValue != nil { if spec.External.Target.AverageValue != nil {
current := "<unknown>" current := "<unknown>"
if len(statuses) > i && statuses[i].External != nil && statuses[i].External.CurrentAverageValue != nil { if len(statuses) > i && statuses[i].External != nil && &statuses[i].External.Current.AverageValue != nil {
current = statuses[i].External.CurrentAverageValue.String() current = statuses[i].External.Current.AverageValue.String()
} }
list = append(list, fmt.Sprintf("%s/%s (avg)", current, spec.External.TargetAverageValue.String())) list = append(list, fmt.Sprintf("%s/%s (avg)", current, spec.External.Target.AverageValue.String()))
} else { } else {
current := "<unknown>" current := "<unknown>"
if len(statuses) > i && statuses[i].External != nil { if len(statuses) > i && statuses[i].External != nil {
current = statuses[i].External.CurrentValue.String() current = statuses[i].External.Current.Value.String()
} }
list = append(list, fmt.Sprintf("%s/%s", current, spec.External.TargetValue.String())) list = append(list, fmt.Sprintf("%s/%s", current, spec.External.Target.Value.String()))
} }
case autoscaling.PodsMetricSourceType: case autoscaling.PodsMetricSourceType:
current := "<unknown>" current := "<unknown>"
if len(statuses) > i && statuses[i].Pods != nil { if len(statuses) > i && statuses[i].Pods != nil {
current = statuses[i].Pods.CurrentAverageValue.String() current = statuses[i].Pods.Current.AverageValue.String()
} }
list = append(list, fmt.Sprintf("%s/%s", current, spec.Pods.TargetAverageValue.String())) list = append(list, fmt.Sprintf("%s/%s", current, spec.Pods.Target.AverageValue.String()))
case autoscaling.ObjectMetricSourceType: case autoscaling.ObjectMetricSourceType:
current := "<unknown>" current := "<unknown>"
if len(statuses) > i && statuses[i].Object != nil { if len(statuses) > i && statuses[i].Object != nil {
current = statuses[i].Object.CurrentValue.String() current = statuses[i].Object.Current.Value.String()
} }
list = append(list, fmt.Sprintf("%s/%s", current, spec.Object.TargetValue.String())) list = append(list, fmt.Sprintf("%s/%s", current, spec.Object.Target.Value.String()))
case autoscaling.ResourceMetricSourceType: case autoscaling.ResourceMetricSourceType:
if spec.Resource.TargetAverageValue != nil { if spec.Resource.Target.AverageValue != nil {
current := "<unknown>" current := "<unknown>"
if len(statuses) > i && statuses[i].Resource != nil { if len(statuses) > i && statuses[i].Resource != nil {
current = statuses[i].Resource.CurrentAverageValue.String() current = statuses[i].Resource.Current.AverageValue.String()
} }
list = append(list, fmt.Sprintf("%s/%s", current, spec.Resource.TargetAverageValue.String())) list = append(list, fmt.Sprintf("%s/%s", current, spec.Resource.Target.AverageValue.String()))
} else { } else {
current := "<unknown>" current := "<unknown>"
if len(statuses) > i && statuses[i].Resource != nil && statuses[i].Resource.CurrentAverageUtilization != nil { if len(statuses) > i && statuses[i].Resource != nil && statuses[i].Resource.Current.AverageUtilization != nil {
current = fmt.Sprintf("%d%%", *statuses[i].Resource.CurrentAverageUtilization) current = fmt.Sprintf("%d%%", *statuses[i].Resource.Current.AverageUtilization)
} }
target := "<auto>" target := "<auto>"
if spec.Resource.TargetAverageUtilization != nil { if spec.Resource.Target.AverageUtilization != nil {
target = fmt.Sprintf("%d%%", *spec.Resource.TargetAverageUtilization) target = fmt.Sprintf("%d%%", *spec.Resource.Target.AverageUtilization)
} }
list = append(list, fmt.Sprintf("%s/%s", current, target)) list = append(list, fmt.Sprintf("%s/%s", current, target))
} }
......
...@@ -67,7 +67,10 @@ func validNewHorizontalPodAutoscaler(name string) *autoscaling.HorizontalPodAuto ...@@ -67,7 +67,10 @@ func validNewHorizontalPodAutoscaler(name string) *autoscaling.HorizontalPodAuto
Type: autoscaling.ResourceMetricSourceType, Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{ Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU, Name: api.ResourceCPU,
TargetAverageUtilization: &cpu, Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType,
AverageUtilization: &cpu,
},
}, },
}, },
}, },
......
...@@ -12,6 +12,7 @@ go_library( ...@@ -12,6 +12,7 @@ go_library(
deps = [ deps = [
"//pkg/api/legacyscheme:go_default_library", "//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/autoscaling:go_default_library", "//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/autoscaling/v2beta2:go_default_library",
"//pkg/registry/autoscaling/horizontalpodautoscaler/storage:go_default_library", "//pkg/registry/autoscaling/horizontalpodautoscaler/storage:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
serverstorage "k8s.io/apiserver/pkg/server/storage" serverstorage "k8s.io/apiserver/pkg/server/storage"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
autoscalingapiv2beta2 "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
horizontalpodautoscalerstore "k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler/storage" horizontalpodautoscalerstore "k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler/storage"
) )
...@@ -35,6 +36,9 @@ func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorag ...@@ -35,6 +36,9 @@ func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorag
// If you add a version here, be sure to add an entry in `k8s.io/kubernetes/cmd/kube-apiserver/app/aggregator.go with specific priorities. // If you add a version here, be sure to add an entry in `k8s.io/kubernetes/cmd/kube-apiserver/app/aggregator.go with specific priorities.
// TODO refactor the plumbing to provide the information in the APIGroupInfo // TODO refactor the plumbing to provide the information in the APIGroupInfo
if apiResourceConfigSource.VersionEnabled(autoscalingapiv2beta2.SchemeGroupVersion) {
apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv2beta2.SchemeGroupVersion.Version] = p.v2beta2Storage(apiResourceConfigSource, restOptionsGetter)
}
if apiResourceConfigSource.VersionEnabled(autoscalingapiv2beta1.SchemeGroupVersion) { if apiResourceConfigSource.VersionEnabled(autoscalingapiv2beta1.SchemeGroupVersion) {
apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv2beta1.SchemeGroupVersion.Version] = p.v2beta1Storage(apiResourceConfigSource, restOptionsGetter) apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv2beta1.SchemeGroupVersion.Version] = p.v2beta1Storage(apiResourceConfigSource, restOptionsGetter)
} }
...@@ -65,6 +69,16 @@ func (p RESTStorageProvider) v2beta1Storage(apiResourceConfigSource serverstorag ...@@ -65,6 +69,16 @@ func (p RESTStorageProvider) v2beta1Storage(apiResourceConfigSource serverstorag
return storage return storage
} }
func (p RESTStorageProvider) v2beta2Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) map[string]rest.Storage {
storage := map[string]rest.Storage{}
// horizontalpodautoscalers
hpaStorage, hpaStatusStorage := horizontalpodautoscalerstore.NewREST(restOptionsGetter)
storage["horizontalpodautoscalers"] = hpaStorage
storage["horizontalpodautoscalers/status"] = hpaStatusStorage
return storage
}
func (p RESTStorageProvider) GroupName() string { func (p RESTStorageProvider) GroupName() string {
return autoscaling.GroupName return autoscaling.GroupName
} }
...@@ -132,6 +132,7 @@ filegroup( ...@@ -132,6 +132,7 @@ filegroup(
"//staging/src/k8s.io/client-go/listers/authorization/v1beta1:all-srcs", "//staging/src/k8s.io/client-go/listers/authorization/v1beta1:all-srcs",
"//staging/src/k8s.io/client-go/listers/autoscaling/v1:all-srcs", "//staging/src/k8s.io/client-go/listers/autoscaling/v1:all-srcs",
"//staging/src/k8s.io/client-go/listers/autoscaling/v2beta1:all-srcs", "//staging/src/k8s.io/client-go/listers/autoscaling/v2beta1:all-srcs",
"//staging/src/k8s.io/client-go/listers/autoscaling/v2beta2:all-srcs",
"//staging/src/k8s.io/client-go/listers/batch/v1:all-srcs", "//staging/src/k8s.io/client-go/listers/batch/v1:all-srcs",
"//staging/src/k8s.io/client-go/listers/batch/v1beta1:all-srcs", "//staging/src/k8s.io/client-go/listers/batch/v1beta1:all-srcs",
"//staging/src/k8s.io/client-go/listers/batch/v2alpha1:all-srcs", "//staging/src/k8s.io/client-go/listers/batch/v2alpha1:all-srcs",
......
...@@ -69,6 +69,7 @@ filegroup( ...@@ -69,6 +69,7 @@ filegroup(
"//staging/src/k8s.io/api/authorization/v1beta1:all-srcs", "//staging/src/k8s.io/api/authorization/v1beta1:all-srcs",
"//staging/src/k8s.io/api/autoscaling/v1:all-srcs", "//staging/src/k8s.io/api/autoscaling/v1:all-srcs",
"//staging/src/k8s.io/api/autoscaling/v2beta1:all-srcs", "//staging/src/k8s.io/api/autoscaling/v2beta1:all-srcs",
"//staging/src/k8s.io/api/autoscaling/v2beta2:all-srcs",
"//staging/src/k8s.io/api/batch/v1:all-srcs", "//staging/src/k8s.io/api/batch/v1:all-srcs",
"//staging/src/k8s.io/api/batch/v1beta1:all-srcs", "//staging/src/k8s.io/api/batch/v1beta1:all-srcs",
"//staging/src/k8s.io/api/batch/v2alpha1:all-srcs", "//staging/src/k8s.io/api/batch/v2alpha1:all-srcs",
......
...@@ -257,6 +257,17 @@ message ObjectMetricSource { ...@@ -257,6 +257,17 @@ message ObjectMetricSource {
// targetValue is the target value of the metric (as a quantity). // targetValue is the target value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetValue = 3; optional k8s.io.apimachinery.pkg.api.resource.Quantity targetValue = 3;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric.
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 4;
// averageValue is the target value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity averageValue = 5;
} }
// ObjectMetricStatus indicates the current value of a metric describing a // ObjectMetricStatus indicates the current value of a metric describing a
...@@ -270,6 +281,17 @@ message ObjectMetricStatus { ...@@ -270,6 +281,17 @@ message ObjectMetricStatus {
// currentValue is the current value of the metric (as a quantity). // currentValue is the current value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentValue = 3; optional k8s.io.apimachinery.pkg.api.resource.Quantity currentValue = 3;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 4;
// averageValue is the current value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity averageValue = 5;
} }
// PodsMetricSource indicates how to scale on a metric describing each pod in // PodsMetricSource indicates how to scale on a metric describing each pod in
...@@ -283,6 +305,12 @@ message PodsMetricSource { ...@@ -283,6 +305,12 @@ message PodsMetricSource {
// targetAverageValue is the target value of the average of the // targetAverageValue is the target value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetAverageValue = 2; optional k8s.io.apimachinery.pkg.api.resource.Quantity targetAverageValue = 2;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 3;
} }
// PodsMetricStatus indicates the current value of a metric describing each pod in // PodsMetricStatus indicates the current value of a metric describing each pod in
...@@ -294,6 +322,12 @@ message PodsMetricStatus { ...@@ -294,6 +322,12 @@ message PodsMetricStatus {
// currentAverageValue is the current value of the average of the // currentAverageValue is the current value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentAverageValue = 2; optional k8s.io.apimachinery.pkg.api.resource.Quantity currentAverageValue = 2;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 3;
} }
// ResourceMetricSource indicates how to scale on a resource metric known to // ResourceMetricSource indicates how to scale on a resource metric known to
......
...@@ -211,6 +211,16 @@ type ObjectMetricSource struct { ...@@ -211,6 +211,16 @@ type ObjectMetricSource struct {
MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"` MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"`
// targetValue is the target value of the metric (as a quantity). // targetValue is the target value of the metric (as a quantity).
TargetValue resource.Quantity `json:"targetValue" protobuf:"bytes,3,name=targetValue"` TargetValue resource.Quantity `json:"targetValue" protobuf:"bytes,3,name=targetValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric.
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,name=selector"`
// averageValue is the target value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,5,name=averageValue"`
} }
// PodsMetricSource indicates how to scale on a metric describing each pod in // PodsMetricSource indicates how to scale on a metric describing each pod in
...@@ -223,6 +233,12 @@ type PodsMetricSource struct { ...@@ -223,6 +233,12 @@ type PodsMetricSource struct {
// targetAverageValue is the target value of the average of the // targetAverageValue is the target value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
TargetAverageValue resource.Quantity `json:"targetAverageValue" protobuf:"bytes,2,name=targetAverageValue"` TargetAverageValue resource.Quantity `json:"targetAverageValue" protobuf:"bytes,2,name=targetAverageValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,name=selector"`
} }
// ResourceMetricSource indicates how to scale on a resource metric known to // ResourceMetricSource indicates how to scale on a resource metric known to
...@@ -344,6 +360,16 @@ type ObjectMetricStatus struct { ...@@ -344,6 +360,16 @@ type ObjectMetricStatus struct {
MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"` MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"`
// currentValue is the current value of the metric (as a quantity). // currentValue is the current value of the metric (as a quantity).
CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"` CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,name=selector"`
// averageValue is the current value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,5,name=averageValue"`
} }
// PodsMetricStatus indicates the current value of a metric describing each pod in // PodsMetricStatus indicates the current value of a metric describing each pod in
...@@ -354,6 +380,12 @@ type PodsMetricStatus struct { ...@@ -354,6 +380,12 @@ type PodsMetricStatus struct {
// currentAverageValue is the current value of the average of the // currentAverageValue is the current value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,2,name=currentAverageValue"` CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,2,name=currentAverageValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,name=selector"`
} }
// ResourceMetricStatus indicates the current value of a resource metric known to // ResourceMetricStatus indicates the current value of a resource metric known to
......
...@@ -148,10 +148,12 @@ func (MetricStatus) SwaggerDoc() map[string]string { ...@@ -148,10 +148,12 @@ func (MetricStatus) SwaggerDoc() map[string]string {
} }
var map_ObjectMetricSource = map[string]string{ var map_ObjectMetricSource = map[string]string{
"": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).", "": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).",
"target": "target is the described Kubernetes object.", "target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.", "metricName": "metricName is the name of the metric in question.",
"targetValue": "targetValue is the target value of the metric (as a quantity).", "targetValue": "targetValue is the target value of the metric (as a quantity).",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric. When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics.",
"averageValue": "averageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
} }
func (ObjectMetricSource) SwaggerDoc() map[string]string { func (ObjectMetricSource) SwaggerDoc() map[string]string {
...@@ -163,6 +165,8 @@ var map_ObjectMetricStatus = map[string]string{ ...@@ -163,6 +165,8 @@ var map_ObjectMetricStatus = map[string]string{
"target": "target is the described Kubernetes object.", "target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.", "metricName": "metricName is the name of the metric in question.",
"currentValue": "currentValue is the current value of the metric (as a quantity).", "currentValue": "currentValue is the current value of the metric (as a quantity).",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics.",
"averageValue": "averageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
} }
func (ObjectMetricStatus) SwaggerDoc() map[string]string { func (ObjectMetricStatus) SwaggerDoc() map[string]string {
...@@ -173,6 +177,7 @@ var map_PodsMetricSource = map[string]string{ ...@@ -173,6 +177,7 @@ var map_PodsMetricSource = map[string]string{
"": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.", "": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.",
"metricName": "metricName is the name of the metric in question", "metricName": "metricName is the name of the metric in question",
"targetAverageValue": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)", "targetAverageValue": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics.",
} }
func (PodsMetricSource) SwaggerDoc() map[string]string { func (PodsMetricSource) SwaggerDoc() map[string]string {
...@@ -183,6 +188,7 @@ var map_PodsMetricStatus = map[string]string{ ...@@ -183,6 +188,7 @@ var map_PodsMetricStatus = map[string]string{
"": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).", "": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).",
"metricName": "metricName is the name of the metric in question", "metricName": "metricName is the name of the metric in question",
"currentAverageValue": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)", "currentAverageValue": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics.",
} }
func (PodsMetricStatus) SwaggerDoc() map[string]string { func (PodsMetricStatus) SwaggerDoc() map[string]string {
......
...@@ -311,6 +311,16 @@ func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) { ...@@ -311,6 +311,16 @@ func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) {
*out = *in *out = *in
out.Target = in.Target out.Target = in.Target
out.TargetValue = in.TargetValue.DeepCopy() out.TargetValue = in.TargetValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return return
} }
...@@ -329,6 +339,16 @@ func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) { ...@@ -329,6 +339,16 @@ func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) {
*out = *in *out = *in
out.Target = in.Target out.Target = in.Target
out.CurrentValue = in.CurrentValue.DeepCopy() out.CurrentValue = in.CurrentValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return return
} }
...@@ -346,6 +366,11 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus { ...@@ -346,6 +366,11 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus {
func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) { func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) {
*out = *in *out = *in
out.TargetAverageValue = in.TargetAverageValue.DeepCopy() out.TargetAverageValue = in.TargetAverageValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
return return
} }
...@@ -363,6 +388,11 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource { ...@@ -363,6 +388,11 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource {
func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) { func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) {
*out = *in *out = *in
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy() out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
return return
} }
......
...@@ -186,6 +186,7 @@ message HorizontalPodAutoscalerStatus { ...@@ -186,6 +186,7 @@ message HorizontalPodAutoscalerStatus {
optional int32 desiredReplicas = 4; optional int32 desiredReplicas = 4;
// currentMetrics is the last read state of the metrics used by this autoscaler. // currentMetrics is the last read state of the metrics used by this autoscaler.
// +optional
repeated MetricStatus currentMetrics = 5; repeated MetricStatus currentMetrics = 5;
// conditions is the set of conditions required for this autoscaler to scale its target, // conditions is the set of conditions required for this autoscaler to scale its target,
...@@ -273,6 +274,17 @@ message ObjectMetricSource { ...@@ -273,6 +274,17 @@ message ObjectMetricSource {
// targetValue is the target value of the metric (as a quantity). // targetValue is the target value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetValue = 3; optional k8s.io.apimachinery.pkg.api.resource.Quantity targetValue = 3;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 4;
// averageValue is the target value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity averageValue = 5;
} }
// ObjectMetricStatus indicates the current value of a metric describing a // ObjectMetricStatus indicates the current value of a metric describing a
...@@ -286,6 +298,17 @@ message ObjectMetricStatus { ...@@ -286,6 +298,17 @@ message ObjectMetricStatus {
// currentValue is the current value of the metric (as a quantity). // currentValue is the current value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentValue = 3; optional k8s.io.apimachinery.pkg.api.resource.Quantity currentValue = 3;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 4;
// averageValue is the current value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity averageValue = 5;
} }
// PodsMetricSource indicates how to scale on a metric describing each pod in // PodsMetricSource indicates how to scale on a metric describing each pod in
...@@ -299,6 +322,12 @@ message PodsMetricSource { ...@@ -299,6 +322,12 @@ message PodsMetricSource {
// targetAverageValue is the target value of the average of the // targetAverageValue is the target value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetAverageValue = 2; optional k8s.io.apimachinery.pkg.api.resource.Quantity targetAverageValue = 2;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 3;
} }
// PodsMetricStatus indicates the current value of a metric describing each pod in // PodsMetricStatus indicates the current value of a metric describing each pod in
...@@ -310,6 +339,12 @@ message PodsMetricStatus { ...@@ -310,6 +339,12 @@ message PodsMetricStatus {
// currentAverageValue is the current value of the average of the // currentAverageValue is the current value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentAverageValue = 2; optional k8s.io.apimachinery.pkg.api.resource.Quantity currentAverageValue = 2;
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 3;
} }
// ResourceMetricSource indicates how to scale on a resource metric known to // ResourceMetricSource indicates how to scale on a resource metric known to
......
...@@ -123,6 +123,16 @@ type ObjectMetricSource struct { ...@@ -123,6 +123,16 @@ type ObjectMetricSource struct {
MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"` MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"`
// targetValue is the target value of the metric (as a quantity). // targetValue is the target value of the metric (as a quantity).
TargetValue resource.Quantity `json:"targetValue" protobuf:"bytes,3,name=targetValue"` TargetValue resource.Quantity `json:"targetValue" protobuf:"bytes,3,name=targetValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,name=selector"`
// averageValue is the target value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,5,name=averageValue"`
} }
// PodsMetricSource indicates how to scale on a metric describing each pod in // PodsMetricSource indicates how to scale on a metric describing each pod in
...@@ -135,6 +145,12 @@ type PodsMetricSource struct { ...@@ -135,6 +145,12 @@ type PodsMetricSource struct {
// targetAverageValue is the target value of the average of the // targetAverageValue is the target value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
TargetAverageValue resource.Quantity `json:"targetAverageValue" protobuf:"bytes,2,name=targetAverageValue"` TargetAverageValue resource.Quantity `json:"targetAverageValue" protobuf:"bytes,2,name=targetAverageValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,name=selector"`
} }
// ResourceMetricSource indicates how to scale on a resource metric known to // ResourceMetricSource indicates how to scale on a resource metric known to
...@@ -200,6 +216,7 @@ type HorizontalPodAutoscalerStatus struct { ...@@ -200,6 +216,7 @@ type HorizontalPodAutoscalerStatus struct {
DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"` DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"`
// currentMetrics is the last read state of the metrics used by this autoscaler. // currentMetrics is the last read state of the metrics used by this autoscaler.
// +optional
CurrentMetrics []MetricStatus `json:"currentMetrics" protobuf:"bytes,5,rep,name=currentMetrics"` CurrentMetrics []MetricStatus `json:"currentMetrics" protobuf:"bytes,5,rep,name=currentMetrics"`
// conditions is the set of conditions required for this autoscaler to scale its target, // conditions is the set of conditions required for this autoscaler to scale its target,
...@@ -284,6 +301,16 @@ type ObjectMetricStatus struct { ...@@ -284,6 +301,16 @@ type ObjectMetricStatus struct {
MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"` MetricName string `json:"metricName" protobuf:"bytes,2,name=metricName"`
// currentValue is the current value of the metric (as a quantity). // currentValue is the current value of the metric (as a quantity).
CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"` CurrentValue resource.Quantity `json:"currentValue" protobuf:"bytes,3,name=currentValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,4,name=selector"`
// averageValue is the current value of the average of the
// metric across all relevant pods (as a quantity)
// +optional
AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,5,name=averageValue"`
} }
// PodsMetricStatus indicates the current value of a metric describing each pod in // PodsMetricStatus indicates the current value of a metric describing each pod in
...@@ -294,6 +321,12 @@ type PodsMetricStatus struct { ...@@ -294,6 +321,12 @@ type PodsMetricStatus struct {
// currentAverageValue is the current value of the average of the // currentAverageValue is the current value of the average of the
// metric across all relevant pods (as a quantity) // metric across all relevant pods (as a quantity)
CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,2,name=currentAverageValue"` CurrentAverageValue resource.Quantity `json:"currentAverageValue" protobuf:"bytes,2,name=currentAverageValue"`
// selector is the string-encoded form of a standard kubernetes label selector for the given metric
// When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping.
// When unset, just the metricName will be used to gather metrics.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,name=selector"`
} }
// ResourceMetricStatus indicates the current value of a resource metric known to // ResourceMetricStatus indicates the current value of a resource metric known to
......
...@@ -149,10 +149,12 @@ func (MetricStatus) SwaggerDoc() map[string]string { ...@@ -149,10 +149,12 @@ func (MetricStatus) SwaggerDoc() map[string]string {
} }
var map_ObjectMetricSource = map[string]string{ var map_ObjectMetricSource = map[string]string{
"": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).", "": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).",
"target": "target is the described Kubernetes object.", "target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.", "metricName": "metricName is the name of the metric in question.",
"targetValue": "targetValue is the target value of the metric (as a quantity).", "targetValue": "targetValue is the target value of the metric (as a quantity).",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics.",
"averageValue": "averageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
} }
func (ObjectMetricSource) SwaggerDoc() map[string]string { func (ObjectMetricSource) SwaggerDoc() map[string]string {
...@@ -164,6 +166,8 @@ var map_ObjectMetricStatus = map[string]string{ ...@@ -164,6 +166,8 @@ var map_ObjectMetricStatus = map[string]string{
"target": "target is the described Kubernetes object.", "target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.", "metricName": "metricName is the name of the metric in question.",
"currentValue": "currentValue is the current value of the metric (as a quantity).", "currentValue": "currentValue is the current value of the metric (as a quantity).",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the ObjectMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics.",
"averageValue": "averageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
} }
func (ObjectMetricStatus) SwaggerDoc() map[string]string { func (ObjectMetricStatus) SwaggerDoc() map[string]string {
...@@ -174,6 +178,7 @@ var map_PodsMetricSource = map[string]string{ ...@@ -174,6 +178,7 @@ var map_PodsMetricSource = map[string]string{
"": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.", "": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.",
"metricName": "metricName is the name of the metric in question", "metricName": "metricName is the name of the metric in question",
"targetAverageValue": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)", "targetAverageValue": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping When unset, just the metricName will be used to gather metrics.",
} }
func (PodsMetricSource) SwaggerDoc() map[string]string { func (PodsMetricSource) SwaggerDoc() map[string]string {
...@@ -184,6 +189,7 @@ var map_PodsMetricStatus = map[string]string{ ...@@ -184,6 +189,7 @@ var map_PodsMetricStatus = map[string]string{
"": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).", "": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).",
"metricName": "metricName is the name of the metric in question", "metricName": "metricName is the name of the metric in question",
"currentAverageValue": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)", "currentAverageValue": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set in the PodsMetricSource, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics.",
} }
func (PodsMetricStatus) SwaggerDoc() map[string]string { func (PodsMetricStatus) SwaggerDoc() map[string]string {
......
...@@ -322,6 +322,16 @@ func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) { ...@@ -322,6 +322,16 @@ func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) {
*out = *in *out = *in
out.Target = in.Target out.Target = in.Target
out.TargetValue = in.TargetValue.DeepCopy() out.TargetValue = in.TargetValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return return
} }
...@@ -340,6 +350,16 @@ func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) { ...@@ -340,6 +350,16 @@ func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) {
*out = *in *out = *in
out.Target = in.Target out.Target = in.Target
out.CurrentValue = in.CurrentValue.DeepCopy() out.CurrentValue = in.CurrentValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return return
} }
...@@ -357,6 +377,11 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus { ...@@ -357,6 +377,11 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus {
func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) { func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) {
*out = *in *out = *in
out.TargetAverageValue = in.TargetAverageValue.DeepCopy() out.TargetAverageValue = in.TargetAverageValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
return return
} }
...@@ -374,6 +399,11 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource { ...@@ -374,6 +399,11 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource {
func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) { func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) {
*out = *in *out = *in
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy() out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
return return
} }
......
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"generated.pb.go",
"register.go",
"types.go",
"types_swagger_doc_generated.go",
"zz_generated.deepcopy.go",
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/api/autoscaling/v2beta2",
importpath = "k8s.io/api/autoscaling/v2beta2",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "go_default_library_protos",
srcs = ["generated.proto"],
visibility = ["//visibility:public"],
)
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:deepcopy-gen=package
// +k8s:openapi-gen=true
package v2beta2 // import "k8s.io/api/autoscaling/v2beta2"
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const GroupName = "autoscaling"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta2"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
// Adds the list of known types to the given scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&HorizontalPodAutoscaler{},
&HorizontalPodAutoscalerList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
...@@ -883,6 +883,10 @@ ...@@ -883,6 +883,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/api/batch/v1", "ImportPath": "k8s.io/api/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
...@@ -1603,6 +1607,10 @@ ...@@ -1603,6 +1607,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/client-go/informers/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/client-go/informers/batch", "ImportPath": "k8s.io/client-go/informers/batch",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
...@@ -1783,6 +1791,10 @@ ...@@ -1783,6 +1791,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1", "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
...@@ -1887,6 +1899,10 @@ ...@@ -1887,6 +1899,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/client-go/listers/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/client-go/listers/batch/v1", "ImportPath": "k8s.io/client-go/listers/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
......
...@@ -903,6 +903,10 @@ ...@@ -903,6 +903,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/api/batch/v1", "ImportPath": "k8s.io/api/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
...@@ -1239,6 +1243,10 @@ ...@@ -1239,6 +1243,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/client-go/informers/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/client-go/informers/batch", "ImportPath": "k8s.io/client-go/informers/batch",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
...@@ -1463,6 +1471,14 @@ ...@@ -1463,6 +1471,14 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1", "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
...@@ -1643,6 +1659,10 @@ ...@@ -1643,6 +1659,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/client-go/listers/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/client-go/listers/batch/v1", "ImportPath": "k8s.io/client-go/listers/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
......
...@@ -247,6 +247,10 @@ ...@@ -247,6 +247,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/api/batch/v1", "ImportPath": "k8s.io/api/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
......
...@@ -315,6 +315,10 @@ ...@@ -315,6 +315,10 @@
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
{ {
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"ImportPath": "k8s.io/api/batch/v1", "ImportPath": "k8s.io/api/batch/v1",
"Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, },
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -13,6 +8,7 @@ go_library( ...@@ -13,6 +8,7 @@ go_library(
], ],
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/informers", importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/informers",
importpath = "k8s.io/client-go/informers", importpath = "k8s.io/client-go/informers",
visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
...@@ -21,6 +17,7 @@ go_library( ...@@ -21,6 +17,7 @@ go_library(
"//staging/src/k8s.io/api/apps/v1beta2:go_default_library", "//staging/src/k8s.io/api/apps/v1beta2:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/batch/v1:go_default_library", "//staging/src/k8s.io/api/batch/v1:go_default_library",
"//staging/src/k8s.io/api/batch/v1beta1:go_default_library", "//staging/src/k8s.io/api/batch/v1beta1:go_default_library",
"//staging/src/k8s.io/api/batch/v2alpha1:go_default_library", "//staging/src/k8s.io/api/batch/v2alpha1:go_default_library",
...@@ -93,4 +90,5 @@ filegroup( ...@@ -93,4 +90,5 @@ filegroup(
"//staging/src/k8s.io/client-go/informers/storage:all-srcs", "//staging/src/k8s.io/client-go/informers/storage:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -9,6 +9,7 @@ go_library( ...@@ -9,6 +9,7 @@ go_library(
deps = [ deps = [
"//staging/src/k8s.io/client-go/informers/autoscaling/v1:go_default_library", "//staging/src/k8s.io/client-go/informers/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/client-go/informers/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/client-go/informers/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/client-go/informers/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/client-go/informers/internalinterfaces:go_default_library", "//staging/src/k8s.io/client-go/informers/internalinterfaces:go_default_library",
], ],
) )
...@@ -26,6 +27,7 @@ filegroup( ...@@ -26,6 +27,7 @@ filegroup(
":package-srcs", ":package-srcs",
"//staging/src/k8s.io/client-go/informers/autoscaling/v1:all-srcs", "//staging/src/k8s.io/client-go/informers/autoscaling/v1:all-srcs",
"//staging/src/k8s.io/client-go/informers/autoscaling/v2beta1:all-srcs", "//staging/src/k8s.io/client-go/informers/autoscaling/v2beta1:all-srcs",
"//staging/src/k8s.io/client-go/informers/autoscaling/v2beta2:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
......
...@@ -21,6 +21,7 @@ package autoscaling ...@@ -21,6 +21,7 @@ package autoscaling
import ( import (
v1 "k8s.io/client-go/informers/autoscaling/v1" v1 "k8s.io/client-go/informers/autoscaling/v1"
v2beta1 "k8s.io/client-go/informers/autoscaling/v2beta1" v2beta1 "k8s.io/client-go/informers/autoscaling/v2beta1"
v2beta2 "k8s.io/client-go/informers/autoscaling/v2beta2"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces" internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
) )
...@@ -30,6 +31,8 @@ type Interface interface { ...@@ -30,6 +31,8 @@ type Interface interface {
V1() v1.Interface V1() v1.Interface
// V2beta1 provides access to shared informers for resources in V2beta1. // V2beta1 provides access to shared informers for resources in V2beta1.
V2beta1() v2beta1.Interface V2beta1() v2beta1.Interface
// V2beta2 provides access to shared informers for resources in V2beta2.
V2beta2() v2beta2.Interface
} }
type group struct { type group struct {
...@@ -52,3 +55,8 @@ func (g *group) V1() v1.Interface { ...@@ -52,3 +55,8 @@ func (g *group) V1() v1.Interface {
func (g *group) V2beta1() v2beta1.Interface { func (g *group) V2beta1() v2beta1.Interface {
return v2beta1.New(g.factory, g.namespace, g.tweakListOptions) return v2beta1.New(g.factory, g.namespace, g.tweakListOptions)
} }
// V2beta2 returns a new v2beta2.Interface.
func (g *group) V2beta2() v2beta2.Interface {
return v2beta2.New(g.factory, g.namespace, g.tweakListOptions)
}
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"horizontalpodautoscaler.go",
"interface.go",
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/informers/autoscaling/v2beta2",
importpath = "k8s.io/client-go/informers/autoscaling/v2beta2",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/client-go/informers/internalinterfaces:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/listers/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v2beta2
import (
time "time"
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
kubernetes "k8s.io/client-go/kubernetes"
v2beta2 "k8s.io/client-go/listers/autoscaling/v2beta2"
cache "k8s.io/client-go/tools/cache"
)
// HorizontalPodAutoscalerInformer provides access to a shared informer and lister for
// HorizontalPodAutoscalers.
type HorizontalPodAutoscalerInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2beta2.HorizontalPodAutoscalerLister
}
type horizontalPodAutoscalerInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewHorizontalPodAutoscalerInformer constructs a new informer for HorizontalPodAutoscaler type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewHorizontalPodAutoscalerInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredHorizontalPodAutoscalerInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredHorizontalPodAutoscalerInformer constructs a new informer for HorizontalPodAutoscaler type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredHorizontalPodAutoscalerInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV2beta2().HorizontalPodAutoscalers(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV2beta2().HorizontalPodAutoscalers(namespace).Watch(options)
},
},
&autoscalingv2beta2.HorizontalPodAutoscaler{},
resyncPeriod,
indexers,
)
}
func (f *horizontalPodAutoscalerInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredHorizontalPodAutoscalerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&autoscalingv2beta2.HorizontalPodAutoscaler{}, f.defaultInformer)
}
func (f *horizontalPodAutoscalerInformer) Lister() v2beta2.HorizontalPodAutoscalerLister {
return v2beta2.NewHorizontalPodAutoscalerLister(f.Informer().GetIndexer())
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v2beta2
import (
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerInformer.
HorizontalPodAutoscalers() HorizontalPodAutoscalerInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// HorizontalPodAutoscalers returns a HorizontalPodAutoscalerInformer.
func (v *version) HorizontalPodAutoscalers() HorizontalPodAutoscalerInformer {
return &horizontalPodAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
...@@ -28,6 +28,7 @@ import ( ...@@ -28,6 +28,7 @@ import (
v1beta2 "k8s.io/api/apps/v1beta2" v1beta2 "k8s.io/api/apps/v1beta2"
autoscalingv1 "k8s.io/api/autoscaling/v1" autoscalingv1 "k8s.io/api/autoscaling/v1"
v2beta1 "k8s.io/api/autoscaling/v2beta1" v2beta1 "k8s.io/api/autoscaling/v2beta1"
v2beta2 "k8s.io/api/autoscaling/v2beta2"
batchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1" batchv1beta1 "k8s.io/api/batch/v1beta1"
v2alpha1 "k8s.io/api/batch/v2alpha1" v2alpha1 "k8s.io/api/batch/v2alpha1"
...@@ -127,6 +128,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource ...@@ -127,6 +128,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case v2beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"): case v2beta1.SchemeGroupVersion.WithResource("horizontalpodautoscalers"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer()}, nil
// Group=autoscaling, Version=v2beta2
case v2beta2.SchemeGroupVersion.WithResource("horizontalpodautoscalers"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V2beta2().HorizontalPodAutoscalers().Informer()}, nil
// Group=batch, Version=v1 // Group=batch, Version=v1
case batchv1.SchemeGroupVersion.WithResource("jobs"): case batchv1.SchemeGroupVersion.WithResource("jobs"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Batch().V1().Jobs().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Batch().V1().Jobs().Informer()}, nil
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -14,6 +9,7 @@ go_library( ...@@ -14,6 +9,7 @@ go_library(
], ],
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes", importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes",
importpath = "k8s.io/client-go/kubernetes", importpath = "k8s.io/client-go/kubernetes",
visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/client-go/discovery:go_default_library", "//staging/src/k8s.io/client-go/discovery:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1:go_default_library",
...@@ -27,6 +23,7 @@ go_library( ...@@ -27,6 +23,7 @@ go_library(
"//staging/src/k8s.io/client-go/kubernetes/typed/authorization/v1beta1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/authorization/v1beta1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v2alpha1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v2alpha1:go_default_library",
...@@ -75,6 +72,7 @@ filegroup( ...@@ -75,6 +72,7 @@ filegroup(
"//staging/src/k8s.io/client-go/kubernetes/typed/authorization/v1beta1:all-srcs", "//staging/src/k8s.io/client-go/kubernetes/typed/authorization/v1beta1:all-srcs",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1:all-srcs", "//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1:all-srcs",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1:all-srcs", "//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1:all-srcs",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2:all-srcs",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1:all-srcs", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1:all-srcs",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1:all-srcs", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1:all-srcs",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v2alpha1:all-srcs", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v2alpha1:all-srcs",
...@@ -96,4 +94,5 @@ filegroup( ...@@ -96,4 +94,5 @@ filegroup(
"//staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1:all-srcs", "//staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1" authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1"
autoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1" autoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1"
autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1"
autoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2"
batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1"
batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1" batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1"
batchv2alpha1 "k8s.io/client-go/kubernetes/typed/batch/v2alpha1" batchv2alpha1 "k8s.io/client-go/kubernetes/typed/batch/v2alpha1"
...@@ -77,6 +78,7 @@ type Interface interface { ...@@ -77,6 +78,7 @@ type Interface interface {
// Deprecated: please explicitly pick a version if possible. // Deprecated: please explicitly pick a version if possible.
Autoscaling() autoscalingv1.AutoscalingV1Interface Autoscaling() autoscalingv1.AutoscalingV1Interface
AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1Interface AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1Interface
AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface
BatchV1() batchv1.BatchV1Interface BatchV1() batchv1.BatchV1Interface
// Deprecated: please explicitly pick a version if possible. // Deprecated: please explicitly pick a version if possible.
Batch() batchv1.BatchV1Interface Batch() batchv1.BatchV1Interface
...@@ -137,6 +139,7 @@ type Clientset struct { ...@@ -137,6 +139,7 @@ type Clientset struct {
authorizationV1beta1 *authorizationv1beta1.AuthorizationV1beta1Client authorizationV1beta1 *authorizationv1beta1.AuthorizationV1beta1Client
autoscalingV1 *autoscalingv1.AutoscalingV1Client autoscalingV1 *autoscalingv1.AutoscalingV1Client
autoscalingV2beta1 *autoscalingv2beta1.AutoscalingV2beta1Client autoscalingV2beta1 *autoscalingv2beta1.AutoscalingV2beta1Client
autoscalingV2beta2 *autoscalingv2beta2.AutoscalingV2beta2Client
batchV1 *batchv1.BatchV1Client batchV1 *batchv1.BatchV1Client
batchV1beta1 *batchv1beta1.BatchV1beta1Client batchV1beta1 *batchv1beta1.BatchV1beta1Client
batchV2alpha1 *batchv2alpha1.BatchV2alpha1Client batchV2alpha1 *batchv2alpha1.BatchV2alpha1Client
...@@ -243,6 +246,11 @@ func (c *Clientset) AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1In ...@@ -243,6 +246,11 @@ func (c *Clientset) AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1In
return c.autoscalingV2beta1 return c.autoscalingV2beta1
} }
// AutoscalingV2beta2 retrieves the AutoscalingV2beta2Client
func (c *Clientset) AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface {
return c.autoscalingV2beta2
}
// BatchV1 retrieves the BatchV1Client // BatchV1 retrieves the BatchV1Client
func (c *Clientset) BatchV1() batchv1.BatchV1Interface { func (c *Clientset) BatchV1() batchv1.BatchV1Interface {
return c.batchV1 return c.batchV1
...@@ -470,6 +478,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { ...@@ -470,6 +478,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
cs.autoscalingV2beta2, err = autoscalingv2beta2.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.batchV1, err = batchv1.NewForConfig(&configShallowCopy) cs.batchV1, err = batchv1.NewForConfig(&configShallowCopy)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -569,6 +581,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { ...@@ -569,6 +581,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
cs.authorizationV1beta1 = authorizationv1beta1.NewForConfigOrDie(c) cs.authorizationV1beta1 = authorizationv1beta1.NewForConfigOrDie(c)
cs.autoscalingV1 = autoscalingv1.NewForConfigOrDie(c) cs.autoscalingV1 = autoscalingv1.NewForConfigOrDie(c)
cs.autoscalingV2beta1 = autoscalingv2beta1.NewForConfigOrDie(c) cs.autoscalingV2beta1 = autoscalingv2beta1.NewForConfigOrDie(c)
cs.autoscalingV2beta2 = autoscalingv2beta2.NewForConfigOrDie(c)
cs.batchV1 = batchv1.NewForConfigOrDie(c) cs.batchV1 = batchv1.NewForConfigOrDie(c)
cs.batchV1beta1 = batchv1beta1.NewForConfigOrDie(c) cs.batchV1beta1 = batchv1beta1.NewForConfigOrDie(c)
cs.batchV2alpha1 = batchv2alpha1.NewForConfigOrDie(c) cs.batchV2alpha1 = batchv2alpha1.NewForConfigOrDie(c)
...@@ -607,6 +620,7 @@ func New(c rest.Interface) *Clientset { ...@@ -607,6 +620,7 @@ func New(c rest.Interface) *Clientset {
cs.authorizationV1beta1 = authorizationv1beta1.New(c) cs.authorizationV1beta1 = authorizationv1beta1.New(c)
cs.autoscalingV1 = autoscalingv1.New(c) cs.autoscalingV1 = autoscalingv1.New(c)
cs.autoscalingV2beta1 = autoscalingv2beta1.New(c) cs.autoscalingV2beta1 = autoscalingv2beta1.New(c)
cs.autoscalingV2beta2 = autoscalingv2beta2.New(c)
cs.batchV1 = batchv1.New(c) cs.batchV1 = batchv1.New(c)
cs.batchV1beta1 = batchv1beta1.New(c) cs.batchV1beta1 = batchv1beta1.New(c)
cs.batchV2alpha1 = batchv2alpha1.New(c) cs.batchV2alpha1 = batchv2alpha1.New(c)
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -14,6 +9,7 @@ go_library( ...@@ -14,6 +9,7 @@ go_library(
], ],
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/fake", importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/fake",
importpath = "k8s.io/client-go/kubernetes/fake", importpath = "k8s.io/client-go/kubernetes/fake",
visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
...@@ -26,6 +22,7 @@ go_library( ...@@ -26,6 +22,7 @@ go_library(
"//staging/src/k8s.io/api/authorization/v1beta1:go_default_library", "//staging/src/k8s.io/api/authorization/v1beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/batch/v1:go_default_library", "//staging/src/k8s.io/api/batch/v1:go_default_library",
"//staging/src/k8s.io/api/batch/v1beta1:go_default_library", "//staging/src/k8s.io/api/batch/v1beta1:go_default_library",
"//staging/src/k8s.io/api/batch/v2alpha1:go_default_library", "//staging/src/k8s.io/api/batch/v2alpha1:go_default_library",
...@@ -76,6 +73,8 @@ go_library( ...@@ -76,6 +73,8 @@ go_library(
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1/fake:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1/fake:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/fake:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/fake:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/fake:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/fake:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1:go_default_library",
...@@ -129,4 +128,5 @@ filegroup( ...@@ -129,4 +128,5 @@ filegroup(
name = "all-srcs", name = "all-srcs",
srcs = [":package-srcs"], srcs = [":package-srcs"],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -46,6 +46,8 @@ import ( ...@@ -46,6 +46,8 @@ import (
fakeautoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1/fake" fakeautoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1/fake"
autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1" autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1"
fakeautoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/fake" fakeautoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/fake"
autoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2"
fakeautoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake"
batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1"
fakebatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1/fake" fakebatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1/fake"
batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1" batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1"
...@@ -209,6 +211,11 @@ func (c *Clientset) AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1In ...@@ -209,6 +211,11 @@ func (c *Clientset) AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1In
return &fakeautoscalingv2beta1.FakeAutoscalingV2beta1{Fake: &c.Fake} return &fakeautoscalingv2beta1.FakeAutoscalingV2beta1{Fake: &c.Fake}
} }
// AutoscalingV2beta2 retrieves the AutoscalingV2beta2Client
func (c *Clientset) AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface {
return &fakeautoscalingv2beta2.FakeAutoscalingV2beta2{Fake: &c.Fake}
}
// BatchV1 retrieves the BatchV1Client // BatchV1 retrieves the BatchV1Client
func (c *Clientset) BatchV1() batchv1.BatchV1Interface { func (c *Clientset) BatchV1() batchv1.BatchV1Interface {
return &fakebatchv1.FakeBatchV1{Fake: &c.Fake} return &fakebatchv1.FakeBatchV1{Fake: &c.Fake}
......
...@@ -30,6 +30,7 @@ import ( ...@@ -30,6 +30,7 @@ import (
authorizationv1beta1 "k8s.io/api/authorization/v1beta1" authorizationv1beta1 "k8s.io/api/authorization/v1beta1"
autoscalingv1 "k8s.io/api/autoscaling/v1" autoscalingv1 "k8s.io/api/autoscaling/v1"
autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
batchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1" batchv1beta1 "k8s.io/api/batch/v1beta1"
batchv2alpha1 "k8s.io/api/batch/v2alpha1" batchv2alpha1 "k8s.io/api/batch/v2alpha1"
...@@ -71,6 +72,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ ...@@ -71,6 +72,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
authorizationv1beta1.AddToScheme, authorizationv1beta1.AddToScheme,
autoscalingv1.AddToScheme, autoscalingv1.AddToScheme,
autoscalingv2beta1.AddToScheme, autoscalingv2beta1.AddToScheme,
autoscalingv2beta2.AddToScheme,
batchv1.AddToScheme, batchv1.AddToScheme,
batchv1beta1.AddToScheme, batchv1beta1.AddToScheme,
batchv2alpha1.AddToScheme, batchv2alpha1.AddToScheme,
......
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
...@@ -13,6 +8,7 @@ go_library( ...@@ -13,6 +8,7 @@ go_library(
], ],
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/scheme", importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/scheme",
importpath = "k8s.io/client-go/kubernetes/scheme", importpath = "k8s.io/client-go/kubernetes/scheme",
visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
...@@ -25,6 +21,7 @@ go_library( ...@@ -25,6 +21,7 @@ go_library(
"//staging/src/k8s.io/api/authorization/v1beta1:go_default_library", "//staging/src/k8s.io/api/authorization/v1beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/api/batch/v1:go_default_library", "//staging/src/k8s.io/api/batch/v1:go_default_library",
"//staging/src/k8s.io/api/batch/v1beta1:go_default_library", "//staging/src/k8s.io/api/batch/v1beta1:go_default_library",
"//staging/src/k8s.io/api/batch/v2alpha1:go_default_library", "//staging/src/k8s.io/api/batch/v2alpha1:go_default_library",
...@@ -63,4 +60,5 @@ filegroup( ...@@ -63,4 +60,5 @@ filegroup(
name = "all-srcs", name = "all-srcs",
srcs = [":package-srcs"], srcs = [":package-srcs"],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )
...@@ -30,6 +30,7 @@ import ( ...@@ -30,6 +30,7 @@ import (
authorizationv1beta1 "k8s.io/api/authorization/v1beta1" authorizationv1beta1 "k8s.io/api/authorization/v1beta1"
autoscalingv1 "k8s.io/api/autoscaling/v1" autoscalingv1 "k8s.io/api/autoscaling/v1"
autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
batchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1" batchv1beta1 "k8s.io/api/batch/v1beta1"
batchv2alpha1 "k8s.io/api/batch/v2alpha1" batchv2alpha1 "k8s.io/api/batch/v2alpha1"
...@@ -71,6 +72,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ ...@@ -71,6 +72,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
authorizationv1beta1.AddToScheme, authorizationv1beta1.AddToScheme,
autoscalingv1.AddToScheme, autoscalingv1.AddToScheme,
autoscalingv2beta1.AddToScheme, autoscalingv2beta1.AddToScheme,
autoscalingv2beta2.AddToScheme,
batchv1.AddToScheme, batchv1.AddToScheme,
batchv1beta1.AddToScheme, batchv1beta1.AddToScheme,
batchv2alpha1.AddToScheme, batchv2alpha1.AddToScheme,
......
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"autoscaling_client.go",
"doc.go",
"generated_expansion.go",
"horizontalpodautoscaler.go",
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2",
importpath = "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v2beta2
import (
v2beta2 "k8s.io/api/autoscaling/v2beta2"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernetes/scheme"
rest "k8s.io/client-go/rest"
)
type AutoscalingV2beta2Interface interface {
RESTClient() rest.Interface
HorizontalPodAutoscalersGetter
}
// AutoscalingV2beta2Client is used to interact with features provided by the autoscaling group.
type AutoscalingV2beta2Client struct {
restClient rest.Interface
}
func (c *AutoscalingV2beta2Client) HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface {
return newHorizontalPodAutoscalers(c, namespace)
}
// NewForConfig creates a new AutoscalingV2beta2Client for the given config.
func NewForConfig(c *rest.Config) (*AutoscalingV2beta2Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &AutoscalingV2beta2Client{client}, nil
}
// NewForConfigOrDie creates a new AutoscalingV2beta2Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *AutoscalingV2beta2Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new AutoscalingV2beta2Client for the given RESTClient.
func New(c rest.Interface) *AutoscalingV2beta2Client {
return &AutoscalingV2beta2Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v2beta2.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *AutoscalingV2beta2Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v2beta2
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"fake_autoscaling_client.go",
"fake_horizontalpodautoscaler.go",
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake",
importpath = "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/api/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/client-go/testing:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeAutoscalingV2beta2 struct {
*testing.Fake
}
func (c *FakeAutoscalingV2beta2) HorizontalPodAutoscalers(namespace string) v2beta2.HorizontalPodAutoscalerInterface {
return &FakeHorizontalPodAutoscalers{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeAutoscalingV2beta2) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v2beta2 "k8s.io/api/autoscaling/v2beta2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeHorizontalPodAutoscalers implements HorizontalPodAutoscalerInterface
type FakeHorizontalPodAutoscalers struct {
Fake *FakeAutoscalingV2beta2
ns string
}
var horizontalpodautoscalersResource = schema.GroupVersionResource{Group: "autoscaling", Version: "v2beta2", Resource: "horizontalpodautoscalers"}
var horizontalpodautoscalersKind = schema.GroupVersionKind{Group: "autoscaling", Version: "v2beta2", Kind: "HorizontalPodAutoscaler"}
// Get takes name of the horizontalPodAutoscaler, and returns the corresponding horizontalPodAutoscaler object, and an error if there is any.
func (c *FakeHorizontalPodAutoscalers) Get(name string, options v1.GetOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(horizontalpodautoscalersResource, c.ns, name), &v2beta2.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
// List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors.
func (c *FakeHorizontalPodAutoscalers) List(opts v1.ListOptions) (result *v2beta2.HorizontalPodAutoscalerList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(horizontalpodautoscalersResource, horizontalpodautoscalersKind, c.ns, opts), &v2beta2.HorizontalPodAutoscalerList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2beta2.HorizontalPodAutoscalerList{ListMeta: obj.(*v2beta2.HorizontalPodAutoscalerList).ListMeta}
for _, item := range obj.(*v2beta2.HorizontalPodAutoscalerList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers.
func (c *FakeHorizontalPodAutoscalers) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(horizontalpodautoscalersResource, c.ns, opts))
}
// Create takes the representation of a horizontalPodAutoscaler and creates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if there is any.
func (c *FakeHorizontalPodAutoscalers) Create(horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler) (result *v2beta2.HorizontalPodAutoscaler, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(horizontalpodautoscalersResource, c.ns, horizontalPodAutoscaler), &v2beta2.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
// Update takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if there is any.
func (c *FakeHorizontalPodAutoscalers) Update(horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler) (result *v2beta2.HorizontalPodAutoscaler, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(horizontalpodautoscalersResource, c.ns, horizontalPodAutoscaler), &v2beta2.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeHorizontalPodAutoscalers) UpdateStatus(horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(horizontalpodautoscalersResource, "status", c.ns, horizontalPodAutoscaler), &v2beta2.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
// Delete takes name of the horizontalPodAutoscaler and deletes it. Returns an error if one occurs.
func (c *FakeHorizontalPodAutoscalers) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(horizontalpodautoscalersResource, c.ns, name), &v2beta2.HorizontalPodAutoscaler{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeHorizontalPodAutoscalers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(horizontalpodautoscalersResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v2beta2.HorizontalPodAutoscalerList{})
return err
}
// Patch applies the patch and returns the patched horizontalPodAutoscaler.
func (c *FakeHorizontalPodAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v2beta2.HorizontalPodAutoscaler, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(horizontalpodautoscalersResource, c.ns, name, data, subresources...), &v2beta2.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v2beta2
type HorizontalPodAutoscalerExpansion interface{}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment