mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Removed cluster autoscaler types frome extensions/v1beta1
This commit is contained in:
parent
9c1d8bf99d
commit
ea2075404d
@ -47,8 +47,6 @@ func AddToScheme(scheme *runtime.Scheme) {
|
||||
func addKnownTypes(scheme *runtime.Scheme) {
|
||||
// TODO this gets cleaned up when the types are fixed
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&ClusterAutoscaler{},
|
||||
&ClusterAutoscalerList{},
|
||||
&Deployment{},
|
||||
&DeploymentList{},
|
||||
&DeploymentRollback{},
|
||||
@ -75,8 +73,6 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *ClusterAutoscaler) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterAutoscalerList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Deployment) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentRollback) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -753,67 +753,6 @@ type IngressBackend struct {
|
||||
ServicePort intstr.IntOrString `json:"servicePort"`
|
||||
}
|
||||
|
||||
type NodeResource string
|
||||
|
||||
const (
|
||||
// Percentage of node's CPUs that is currently used.
|
||||
CpuConsumption NodeResource = "CpuConsumption"
|
||||
|
||||
// Percentage of node's CPUs that is currently requested for pods.
|
||||
CpuRequest NodeResource = "CpuRequest"
|
||||
|
||||
// Percentage od node's memory that is currently used.
|
||||
MemConsumption NodeResource = "MemConsumption"
|
||||
|
||||
// Percentage of node's CPUs that is currently requested for pods.
|
||||
MemRequest NodeResource = "MemRequest"
|
||||
)
|
||||
|
||||
// NodeUtilization describes what percentage of a particular resource is used on a node.
|
||||
type NodeUtilization struct {
|
||||
Resource NodeResource `json:"resource"`
|
||||
|
||||
// The accepted values are from 0 to 1.
|
||||
Value float64 `json:"value"`
|
||||
}
|
||||
|
||||
// Configuration of the Cluster Autoscaler
|
||||
type ClusterAutoscalerSpec struct {
|
||||
// Minimum number of nodes that the cluster should have.
|
||||
MinNodes int `json:"minNodes"`
|
||||
|
||||
// Maximum number of nodes that the cluster should have.
|
||||
MaxNodes int `json:"maxNodes"`
|
||||
|
||||
// Target average utilization of the cluster nodes. New nodes will be added if one of the
|
||||
// targets is exceeded. Cluster size will be decreased if the current utilization is too low
|
||||
// for all targets.
|
||||
TargetUtilization []NodeUtilization `json:"target"`
|
||||
}
|
||||
|
||||
type ClusterAutoscaler struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
||||
// Standard object's metadata.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
// For now (experimental api) it is required that the name is set to "ClusterAutoscaler" and namespace is "default".
|
||||
api.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Spec defines the desired behavior of this daemon set.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
|
||||
Spec ClusterAutoscalerSpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// There will be just one (or none) ClusterAutoscaler.
|
||||
type ClusterAutoscalerList struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
// Standard object's metadata.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
unversioned.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []ClusterAutoscaler `json:"items"`
|
||||
}
|
||||
|
||||
// +genclient=true
|
||||
|
||||
// ReplicaSet represents the configuration of a replica set.
|
||||
|
@ -37,8 +37,6 @@ func AddToScheme(scheme *runtime.Scheme) {
|
||||
// Adds the list of known types to api.Scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&ClusterAutoscaler{},
|
||||
&ClusterAutoscalerList{},
|
||||
&Deployment{},
|
||||
&DeploymentList{},
|
||||
&DeploymentRollback{},
|
||||
@ -65,8 +63,6 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *ClusterAutoscaler) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterAutoscalerList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Deployment) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentRollback) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -763,67 +763,6 @@ type IngressBackend struct {
|
||||
ServicePort intstr.IntOrString `json:"servicePort"`
|
||||
}
|
||||
|
||||
type NodeResource string
|
||||
|
||||
const (
|
||||
// Percentage of node's CPUs that is currently used.
|
||||
CpuConsumption NodeResource = "CpuConsumption"
|
||||
|
||||
// Percentage of node's CPUs that is currently requested for pods.
|
||||
CpuRequest NodeResource = "CpuRequest"
|
||||
|
||||
// Percentage od node's memory that is currently used.
|
||||
MemConsumption NodeResource = "MemConsumption"
|
||||
|
||||
// Percentage of node's CPUs that is currently requested for pods.
|
||||
MemRequest NodeResource = "MemRequest"
|
||||
)
|
||||
|
||||
// NodeUtilization describes what percentage of a particular resource is used on a node.
|
||||
type NodeUtilization struct {
|
||||
Resource NodeResource `json:"resource"`
|
||||
|
||||
// The accepted values are from 0 to 1.
|
||||
Value float64 `json:"value"`
|
||||
}
|
||||
|
||||
// Configuration of the Cluster Autoscaler
|
||||
type ClusterAutoscalerSpec struct {
|
||||
// Minimum number of nodes that the cluster should have.
|
||||
MinNodes int32 `json:"minNodes"`
|
||||
|
||||
// Maximum number of nodes that the cluster should have.
|
||||
MaxNodes int32 `json:"maxNodes"`
|
||||
|
||||
// Target average utilization of the cluster nodes. New nodes will be added if one of the
|
||||
// targets is exceeded. Cluster size will be decreased if the current utilization is too low
|
||||
// for all targets.
|
||||
TargetUtilization []NodeUtilization `json:"target"`
|
||||
}
|
||||
|
||||
type ClusterAutoscaler struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
||||
// Standard object's metadata.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
// For now (experimental api) it is required that the name is set to "ClusterAutoscaler" and namespace is "default".
|
||||
v1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Spec defines the desired behavior of this daemon set.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
|
||||
Spec ClusterAutoscalerSpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// There will be just one (or none) ClusterAutoscaler.
|
||||
type ClusterAutoscalerList struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
// Standard object's metadata.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
unversioned.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []ClusterAutoscaler `json:"items"`
|
||||
}
|
||||
|
||||
// ExportOptions is the query options to the standard REST get call.
|
||||
type ExportOptions struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
@ -594,43 +594,6 @@ func validateIngressBackend(backend *extensions.IngressBackend, fldPath *field.P
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateClusterAutoscalerSpec(spec extensions.ClusterAutoscalerSpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if spec.MinNodes < 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("minNodes"), spec.MinNodes, "must be greater than or equal to 0"))
|
||||
}
|
||||
if spec.MaxNodes < spec.MinNodes {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("maxNodes"), spec.MaxNodes, "must be greater than or equal to `minNodes`"))
|
||||
}
|
||||
if len(spec.TargetUtilization) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetUtilization"), ""))
|
||||
}
|
||||
for _, target := range spec.TargetUtilization {
|
||||
if len(target.Resource) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetUtilization", "resource"), ""))
|
||||
}
|
||||
if target.Value <= 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetUtilization", "value"), target.Value, "must be greater than 0"))
|
||||
}
|
||||
if target.Value > 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetUtilization", "value"), target.Value, "must be less than or equal to 1"))
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateClusterAutoscaler(autoscaler *extensions.ClusterAutoscaler) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if autoscaler.Name != "ClusterAutoscaler" {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata", "name"), autoscaler.Name, "must be 'ClusterAutoscaler'"))
|
||||
}
|
||||
if autoscaler.Namespace != api.NamespaceDefault {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata", "namespace"), autoscaler.Namespace, "must be 'default'"))
|
||||
}
|
||||
allErrs = append(allErrs, validateClusterAutoscalerSpec(autoscaler.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateScale(scale *extensions.Scale) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&scale.ObjectMeta, true, apivalidation.NameIsDNSSubdomain, field.NewPath("metadata"))...)
|
||||
|
@ -1299,120 +1299,6 @@ func TestValidateIngressStatusUpdate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateClusterAutoscaler(t *testing.T) {
|
||||
successCases := []extensions.ClusterAutoscaler{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, successCase := range successCases {
|
||||
if errs := ValidateClusterAutoscaler(&successCase); len(errs) != 0 {
|
||||
t.Errorf("expected success: %v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
errorCases := map[string]extensions.ClusterAutoscaler{
|
||||
"must be 'ClusterAutoscaler'": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "TestClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"must be 'default'": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: "test",
|
||||
},
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
`must be greater than or equal to 0`: {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: -1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"must be greater than or equal to `minNodes`": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 10,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"Required value": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []extensions.NodeUtilization{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for k, v := range errorCases {
|
||||
errs := ValidateClusterAutoscaler(&v)
|
||||
if len(errs) == 0 {
|
||||
t.Errorf("[%s] expected failure", k)
|
||||
} else if !strings.Contains(errs[0].Error(), k) {
|
||||
t.Errorf("unexpected error: %v, expected: %q", errs[0], k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScale(t *testing.T) {
|
||||
successCases := []extensions.Scale{
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user