From 92cce5210e19f05b51351a66e9758de6a6a11dc5 Mon Sep 17 00:00:00 2001 From: halfrost Date: Mon, 15 Aug 2022 21:29:59 -0700 Subject: [PATCH] Add cluster resource modeling api --- pkg/apis/cluster/types.go | 80 ++++++++++++ pkg/apis/cluster/v1alpha1/types.go | 61 +++++++++ .../v1alpha1/zz_generated.conversion.go | 118 ++++++++++++++++-- .../cluster/v1alpha1/zz_generated.deepcopy.go | 48 +++++++ pkg/apis/cluster/zz_generated.deepcopy.go | 69 ++++++++++ .../clientset/versioned/fake/register.go | 14 +-- .../clientset/versioned/scheme/register.go | 14 +-- pkg/generated/openapi/zz_generated.openapi.go | 90 ++++++++++++- vendor/k8s.io/api/core/v1/generated.proto | 16 --- .../pkg/api/resource/generated.proto | 16 --- .../pkg/apis/meta/v1/generated.proto | 17 +-- .../apimachinery/pkg/runtime/generated.proto | 16 --- .../pkg/runtime/schema/generated.proto | 16 --- .../pkg/util/intstr/generated.proto | 16 --- 14 files changed, 471 insertions(+), 120 deletions(-) diff --git a/pkg/apis/cluster/types.go b/pkg/apis/cluster/types.go index 38edcc98da50..57c6ae52a52e 100644 --- a/pkg/apis/cluster/types.go +++ b/pkg/apis/cluster/types.go @@ -2,6 +2,7 @@ package cluster import ( corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -104,6 +105,66 @@ type ClusterSpec struct { // any resource that does not tolerate the Taint. // +optional Taints []corev1.Taint + + // ResourceModels is the list of resource modeling in this cluster. Each modeling quota can be customized by the user. + // Modeling name must be one of the following: cpu, memory, storage, ephemeral-storage. + // If the user does not define the modeling name and modeling quota, it will be the default model. + // The default model index from 0 to 11. Each default model's cpu quota is (2^index-1, 2^index], index >= 0 + // Each default model's memory quota is also (2^index-1, 2^index], index >= 0, for example, model0 is like this: + // - index: 0 + // ranges: + // - name: CPU + // min: 0 C + // max: 1 C + // - name: memory + // min: 0 GB + // max: 1 GB + // model10 is like this: + // - index: 10 + // range: + // - name: CPU + // min: 512 C + // max: 1024 C + // - name: memory + // min: 512 GB + // max: 1024 GB + // model11 is like this: + // - index: 11 + // range: + // - name: CPU + // min: 1024 C + // max: MAXINT + // - name: memory + // min: 1024 GB + // max: MAXINT + // +optional + ResourceModels []ResourceModel +} + +// ResourceModel describes the modeling that you want to statistics. +type ResourceModel struct { + // Grade is the index for the resource modeling. + // +optional + Grade int + + // Ranges describes the resource quota ranges. + // +optional + Ranges []ResourceModelItem +} + +// ResourceModelItem describes the detail of each modeling quota that ranges from min to max. +type ResourceModelItem struct { + // Name is the name for the resource that you want to categorize. + // +optional + Name corev1.ResourceName + + // Min is the minimum amount of this resource represented by resource name。 + // +optional + Min resource.Quantity + + // Max is the maximum amount of this resource represented by resource name。 + // +optional + Max resource.Quantity } const ( @@ -216,6 +277,25 @@ type ResourceSummary struct { // Total amount of required resources of all Pods that have been scheduled to nodes. // +optional Allocated corev1.ResourceList + + // AllocatableModeling represents the number of each resources modeling in a cluster that are available for scheduling. + // Total amount of allocatable resources on all nodes. + // The Grade of AllocatableModelingItem is the index of ResourceModel, + // The Count of AllocatableModelingItem is the number of nodes that own the resources delineated by this modeling. + // For example, AllocatableModelingItem{Grade: 2, Count: 10}, which means there are 10 such resource models of ResourceModel[2]. + // +optional + AllocatableModeling []AllocatableModelingItem +} + +// AllocatableModelingItem represents the number of this resources modeling in a cluster that are available for scheduling. +type AllocatableModelingItem struct { + // Grade is the index of ResourceModel. + // +optional + Grade int + + // Count is the number of nodes that own the resources delineated by this modeling. + // +optional + Count int } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/cluster/v1alpha1/types.go b/pkg/apis/cluster/v1alpha1/types.go index 11bdced409ce..568efba7724a 100644 --- a/pkg/apis/cluster/v1alpha1/types.go +++ b/pkg/apis/cluster/v1alpha1/types.go @@ -2,6 +2,7 @@ package v1alpha1 import ( corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -116,6 +117,66 @@ type ClusterSpec struct { // any resource that does not tolerate the Taint. // +optional Taints []corev1.Taint `json:"taints,omitempty"` + + // ResourceModels is the list of resource modeling in this cluster. Each modeling quota can be customized by the user. + // Modeling name must be one of the following: cpu, memory, storage, ephemeral-storage. + // If the user does not define the modeling name and modeling quota, it will be the default model. + // The default model index from 0 to 11. Each default model's cpu quota is (2^index-1, 2^index], index >= 0 + // Each default model's memory quota is also (2^index-1, 2^index], index >= 0, for example, model0 is like this: + // - index: 0 + // ranges: + // - name: CPU + // min: 0 C + // max: 1 C + // - name: memory + // min: 0 GB + // max: 1 GB + // model10 is like this: + // - index: 10 + // range: + // - name: CPU + // min: 512 C + // max: 1024 C + // - name: memory + // min: 512 GB + // max: 1024 GB + // model11 is like this: + // - index: 11 + // range: + // - name: CPU + // min: 1024 C + // max: MAXINT + // - name: memory + // min: 1024 GB + // max: MAXINT + // +optional + ResourceModels []ResourceModel `json:"resourceModels,omitempty"` +} + +// ResourceModel describes the modeling that you want to statistics. +type ResourceModel struct { + // Grade is the index for the resource modeling. + // +optional + Grade int `json:"grade,omitempty"` + + // Ranges describes the resource quota ranges. + // +optional + Ranges []ResourceModelItem `json:"ranges,omitempty"` +} + +// ResourceModelItem describes the detail of each modeling quota that ranges from min to max. +type ResourceModelItem struct { + // Name is the name for the resource that you want to categorize. + // +optional + Name corev1.ResourceName `json:"name,omitempty"` + + // Min is the minimum amount of this resource represented by resource name。 + // +optional + Min resource.Quantity `json:"min,omitempty"` + + // Max is the maximum amount of this resource represented by resource name。 + // +optional + Max resource.Quantity `json:"max,omitempty"` } const ( diff --git a/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go b/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go index 86cd65413519..7ce5edc8f0df 100644 --- a/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go @@ -113,6 +113,26 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*ResourceModel)(nil), (*cluster.ResourceModel)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ResourceModel_To_cluster_ResourceModel(a.(*ResourceModel), b.(*cluster.ResourceModel), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*cluster.ResourceModel)(nil), (*ResourceModel)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_cluster_ResourceModel_To_v1alpha1_ResourceModel(a.(*cluster.ResourceModel), b.(*ResourceModel), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ResourceModelItem)(nil), (*cluster.ResourceModelItem)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ResourceModelItem_To_cluster_ResourceModelItem(a.(*ResourceModelItem), b.(*cluster.ResourceModelItem), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*cluster.ResourceModelItem)(nil), (*ResourceModelItem)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_cluster_ResourceModelItem_To_v1alpha1_ResourceModelItem(a.(*cluster.ResourceModelItem), b.(*ResourceModelItem), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*ResourceSummary)(nil), (*cluster.ResourceSummary)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_ResourceSummary_To_cluster_ResourceSummary(a.(*ResourceSummary), b.(*cluster.ResourceSummary), scope) }); err != nil { @@ -209,7 +229,17 @@ func Convert_cluster_Cluster_To_v1alpha1_Cluster(in *cluster.Cluster, out *Clust func autoConvert_v1alpha1_ClusterList_To_cluster_ClusterList(in *ClusterList, out *cluster.ClusterList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]cluster.Cluster)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]cluster.Cluster, len(*in)) + for i := range *in { + if err := Convert_v1alpha1_Cluster_To_cluster_Cluster(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -220,7 +250,17 @@ func Convert_v1alpha1_ClusterList_To_cluster_ClusterList(in *ClusterList, out *c func autoConvert_cluster_ClusterList_To_v1alpha1_ClusterList(in *cluster.ClusterList, out *ClusterList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]Cluster)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Cluster, len(*in)) + for i := range *in { + if err := Convert_cluster_Cluster_To_v1alpha1_Cluster(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -280,6 +320,7 @@ func autoConvert_v1alpha1_ClusterSpec_To_cluster_ClusterSpec(in *ClusterSpec, ou out.Region = in.Region out.Zone = in.Zone out.Taints = *(*[]v1.Taint)(unsafe.Pointer(&in.Taints)) + out.ResourceModels = *(*[]cluster.ResourceModel)(unsafe.Pointer(&in.ResourceModels)) return nil } @@ -301,6 +342,7 @@ func autoConvert_cluster_ClusterSpec_To_v1alpha1_ClusterSpec(in *cluster.Cluster out.Region = in.Region out.Zone = in.Zone out.Taints = *(*[]v1.Taint)(unsafe.Pointer(&in.Taints)) + out.ResourceModels = *(*[]ResourceModel)(unsafe.Pointer(&in.ResourceModels)) return nil } @@ -314,7 +356,15 @@ func autoConvert_v1alpha1_ClusterStatus_To_cluster_ClusterStatus(in *ClusterStat out.APIEnablements = *(*[]cluster.APIEnablement)(unsafe.Pointer(&in.APIEnablements)) out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) out.NodeSummary = (*cluster.NodeSummary)(unsafe.Pointer(in.NodeSummary)) - out.ResourceSummary = (*cluster.ResourceSummary)(unsafe.Pointer(in.ResourceSummary)) + if in.ResourceSummary != nil { + in, out := &in.ResourceSummary, &out.ResourceSummary + *out = new(cluster.ResourceSummary) + if err := Convert_v1alpha1_ResourceSummary_To_cluster_ResourceSummary(*in, *out, s); err != nil { + return err + } + } else { + out.ResourceSummary = nil + } return nil } @@ -328,7 +378,15 @@ func autoConvert_cluster_ClusterStatus_To_v1alpha1_ClusterStatus(in *cluster.Clu out.APIEnablements = *(*[]APIEnablement)(unsafe.Pointer(&in.APIEnablements)) out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) out.NodeSummary = (*NodeSummary)(unsafe.Pointer(in.NodeSummary)) - out.ResourceSummary = (*ResourceSummary)(unsafe.Pointer(in.ResourceSummary)) + if in.ResourceSummary != nil { + in, out := &in.ResourceSummary, &out.ResourceSummary + *out = new(ResourceSummary) + if err := Convert_cluster_ResourceSummary_To_v1alpha1_ResourceSummary(*in, *out, s); err != nil { + return err + } + } else { + out.ResourceSummary = nil + } return nil } @@ -381,6 +439,52 @@ func Convert_cluster_NodeSummary_To_v1alpha1_NodeSummary(in *cluster.NodeSummary return autoConvert_cluster_NodeSummary_To_v1alpha1_NodeSummary(in, out, s) } +func autoConvert_v1alpha1_ResourceModel_To_cluster_ResourceModel(in *ResourceModel, out *cluster.ResourceModel, s conversion.Scope) error { + out.Grade = in.Grade + out.Ranges = *(*[]cluster.ResourceModelItem)(unsafe.Pointer(&in.Ranges)) + return nil +} + +// Convert_v1alpha1_ResourceModel_To_cluster_ResourceModel is an autogenerated conversion function. +func Convert_v1alpha1_ResourceModel_To_cluster_ResourceModel(in *ResourceModel, out *cluster.ResourceModel, s conversion.Scope) error { + return autoConvert_v1alpha1_ResourceModel_To_cluster_ResourceModel(in, out, s) +} + +func autoConvert_cluster_ResourceModel_To_v1alpha1_ResourceModel(in *cluster.ResourceModel, out *ResourceModel, s conversion.Scope) error { + out.Grade = in.Grade + out.Ranges = *(*[]ResourceModelItem)(unsafe.Pointer(&in.Ranges)) + return nil +} + +// Convert_cluster_ResourceModel_To_v1alpha1_ResourceModel is an autogenerated conversion function. +func Convert_cluster_ResourceModel_To_v1alpha1_ResourceModel(in *cluster.ResourceModel, out *ResourceModel, s conversion.Scope) error { + return autoConvert_cluster_ResourceModel_To_v1alpha1_ResourceModel(in, out, s) +} + +func autoConvert_v1alpha1_ResourceModelItem_To_cluster_ResourceModelItem(in *ResourceModelItem, out *cluster.ResourceModelItem, s conversion.Scope) error { + out.Name = v1.ResourceName(in.Name) + out.Min = in.Min + out.Max = in.Max + return nil +} + +// Convert_v1alpha1_ResourceModelItem_To_cluster_ResourceModelItem is an autogenerated conversion function. +func Convert_v1alpha1_ResourceModelItem_To_cluster_ResourceModelItem(in *ResourceModelItem, out *cluster.ResourceModelItem, s conversion.Scope) error { + return autoConvert_v1alpha1_ResourceModelItem_To_cluster_ResourceModelItem(in, out, s) +} + +func autoConvert_cluster_ResourceModelItem_To_v1alpha1_ResourceModelItem(in *cluster.ResourceModelItem, out *ResourceModelItem, s conversion.Scope) error { + out.Name = v1.ResourceName(in.Name) + out.Min = in.Min + out.Max = in.Max + return nil +} + +// Convert_cluster_ResourceModelItem_To_v1alpha1_ResourceModelItem is an autogenerated conversion function. +func Convert_cluster_ResourceModelItem_To_v1alpha1_ResourceModelItem(in *cluster.ResourceModelItem, out *ResourceModelItem, s conversion.Scope) error { + return autoConvert_cluster_ResourceModelItem_To_v1alpha1_ResourceModelItem(in, out, s) +} + func autoConvert_v1alpha1_ResourceSummary_To_cluster_ResourceSummary(in *ResourceSummary, out *cluster.ResourceSummary, s conversion.Scope) error { out.Allocatable = *(*v1.ResourceList)(unsafe.Pointer(&in.Allocatable)) out.Allocating = *(*v1.ResourceList)(unsafe.Pointer(&in.Allocating)) @@ -397,10 +501,6 @@ func autoConvert_cluster_ResourceSummary_To_v1alpha1_ResourceSummary(in *cluster out.Allocatable = *(*v1.ResourceList)(unsafe.Pointer(&in.Allocatable)) out.Allocating = *(*v1.ResourceList)(unsafe.Pointer(&in.Allocating)) out.Allocated = *(*v1.ResourceList)(unsafe.Pointer(&in.Allocated)) + // WARNING: in.AllocatableModeling requires manual conversion: does not exist in peer-type return nil } - -// Convert_cluster_ResourceSummary_To_v1alpha1_ResourceSummary is an autogenerated conversion function. -func Convert_cluster_ResourceSummary_To_v1alpha1_ResourceSummary(in *cluster.ResourceSummary, out *ResourceSummary, s conversion.Scope) error { - return autoConvert_cluster_ResourceSummary_To_v1alpha1_ResourceSummary(in, out, s) -} diff --git a/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go index a0094ef3269c..3612c769d7ab 100644 --- a/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go @@ -161,6 +161,13 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ResourceModels != nil { + in, out := &in.ResourceModels, &out.ResourceModels + *out = make([]ResourceModel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -246,6 +253,47 @@ func (in *NodeSummary) DeepCopy() *NodeSummary { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceModel) DeepCopyInto(out *ResourceModel) { + *out = *in + if in.Ranges != nil { + in, out := &in.Ranges, &out.Ranges + *out = make([]ResourceModelItem, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceModel. +func (in *ResourceModel) DeepCopy() *ResourceModel { + if in == nil { + return nil + } + out := new(ResourceModel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceModelItem) DeepCopyInto(out *ResourceModelItem) { + *out = *in + out.Min = in.Min.DeepCopy() + out.Max = in.Max.DeepCopy() + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceModelItem. +func (in *ResourceModelItem) DeepCopy() *ResourceModelItem { + if in == nil { + return nil + } + out := new(ResourceModelItem) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceSummary) DeepCopyInto(out *ResourceSummary) { *out = *in diff --git a/pkg/apis/cluster/zz_generated.deepcopy.go b/pkg/apis/cluster/zz_generated.deepcopy.go index 727a154e611f..7fd0d121295f 100644 --- a/pkg/apis/cluster/zz_generated.deepcopy.go +++ b/pkg/apis/cluster/zz_generated.deepcopy.go @@ -48,6 +48,22 @@ func (in *APIResource) DeepCopy() *APIResource { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AllocatableModelingItem) DeepCopyInto(out *AllocatableModelingItem) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllocatableModelingItem. +func (in *AllocatableModelingItem) DeepCopy() *AllocatableModelingItem { + if in == nil { + return nil + } + out := new(AllocatableModelingItem) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Cluster) DeepCopyInto(out *Cluster) { *out = *in @@ -161,6 +177,13 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ResourceModels != nil { + in, out := &in.ResourceModels, &out.ResourceModels + *out = make([]ResourceModel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -246,6 +269,47 @@ func (in *NodeSummary) DeepCopy() *NodeSummary { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceModel) DeepCopyInto(out *ResourceModel) { + *out = *in + if in.Ranges != nil { + in, out := &in.Ranges, &out.Ranges + *out = make([]ResourceModelItem, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceModel. +func (in *ResourceModel) DeepCopy() *ResourceModel { + if in == nil { + return nil + } + out := new(ResourceModel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceModelItem) DeepCopyInto(out *ResourceModelItem) { + *out = *in + out.Min = in.Min.DeepCopy() + out.Max = in.Max.DeepCopy() + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceModelItem. +func (in *ResourceModelItem) DeepCopy() *ResourceModelItem { + if in == nil { + return nil + } + out := new(ResourceModelItem) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceSummary) DeepCopyInto(out *ResourceSummary) { *out = *in @@ -270,6 +334,11 @@ func (in *ResourceSummary) DeepCopyInto(out *ResourceSummary) { (*out)[key] = val.DeepCopy() } } + if in.AllocatableModeling != nil { + in, out := &in.AllocatableModeling, &out.AllocatableModeling + *out = make([]AllocatableModelingItem, len(*in)) + copy(*out, *in) + } return } diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index dbff90bea41f..d41ff63f1887 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -33,14 +33,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index d6e6255645d5..0cf70bbe8837 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -33,14 +33,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 67496c412a3a..566046d4af94 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -26,6 +26,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ClusterStatus": schema_pkg_apis_cluster_v1alpha1_ClusterStatus(ref), "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.LocalSecretReference": schema_pkg_apis_cluster_v1alpha1_LocalSecretReference(ref), "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.NodeSummary": schema_pkg_apis_cluster_v1alpha1_NodeSummary(ref), + "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModel": schema_pkg_apis_cluster_v1alpha1_ResourceModel(ref), + "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModelItem": schema_pkg_apis_cluster_v1alpha1_ResourceModelItem(ref), "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceSummary": schema_pkg_apis_cluster_v1alpha1_ResourceSummary(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.DependentObjectReference": schema_pkg_apis_config_v1alpha1_DependentObjectReference(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.RequestStatus": schema_pkg_apis_config_v1alpha1_RequestStatus(ref), @@ -742,12 +744,26 @@ func schema_pkg_apis_cluster_v1alpha1_ClusterSpec(ref common.ReferenceCallback) }, }, }, + "resourceModels": { + SchemaProps: spec.SchemaProps{ + Description: "ResourceModels is the list of resource modeling in this cluster. Each modeling quota can be customized by the user. Modeling name must be one of the following: cpu, memory, storage, ephemeral-storage. If the user does not define the modeling name and modeling quota, it will be the default model. The default model index from 0 to 11. Each default model's cpu quota is (2^index-1, 2^index], index >= 0 Each default model's memory quota is also (2^index-1, 2^index], index >= 0, for example, model0 is like this: - index: 0 ranges:\n - name: CPU\n min: 0 C\n max: 1 C\n - name: memory\n min: 0 GB\n max: 1 GB\nmodel10 is like this: - index: 10 range:\n - name: CPU\n min: 512 C\n max: 1024 C\n - name: memory\n min: 512 GB\n max: 1024 GB\nmodel11 is like this: - index: 11 range:\n - name: CPU\n min: 1024 C\n max: MAXINT\n - name: memory\n min: 1024 GB\n max: MAXINT", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModel"), + }, + }, + }, + }, + }, }, Required: []string{"syncMode"}, }, }, Dependencies: []string{ - "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.LocalSecretReference", "k8s.io/api/core/v1.Taint"}, + "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.LocalSecretReference", "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModel", "k8s.io/api/core/v1.Taint"}, } } @@ -870,6 +886,78 @@ func schema_pkg_apis_cluster_v1alpha1_NodeSummary(ref common.ReferenceCallback) } } +func schema_pkg_apis_cluster_v1alpha1_ResourceModel(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceModel describes the modeling that you want to statistics.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "grade": { + SchemaProps: spec.SchemaProps{ + Description: "Grade is the index for the resource modeling.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "ranges": { + SchemaProps: spec.SchemaProps{ + Description: "Ranges describes the resource quota ranges.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModelItem"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModelItem"}, + } +} + +func schema_pkg_apis_cluster_v1alpha1_ResourceModelItem(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceModelItem describes the detail of each modeling quota that ranges from min to max.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name for the resource that you want to categorize.", + Type: []string{"string"}, + Format: "", + }, + }, + "min": { + SchemaProps: spec.SchemaProps{ + Description: "Min is the minimum amount of this resource represented by resource name。", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + "max": { + SchemaProps: spec.SchemaProps{ + Description: "Max is the maximum amount of this resource represented by resource name。", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + func schema_pkg_apis_cluster_v1alpha1_ResourceSummary(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/vendor/k8s.io/api/core/v1/generated.proto b/vendor/k8s.io/api/core/v1/generated.proto index 41423f45f72d..bcd73aa89c1f 100644 --- a/vendor/k8s.io/api/core/v1/generated.proto +++ b/vendor/k8s.io/api/core/v1/generated.proto @@ -1,19 +1,3 @@ -/* -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. -*/ - // This file was autogenerated by go-to-protobuf. Do not edit it manually! diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto index 79abc0ff5e72..b8181e162022 100644 --- a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto +++ b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto @@ -1,19 +1,3 @@ -/* -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. -*/ - // This file was autogenerated by go-to-protobuf. Do not edit it manually! diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto index b6c77351527d..8a810e69d2ff 100644 --- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto +++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto @@ -1,19 +1,3 @@ -/* -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. -*/ - // This file was autogenerated by go-to-protobuf. Do not edit it manually! @@ -1049,6 +1033,7 @@ message StatusDetails { } // TableOptions are used when a Table is requested by the caller. +// +k8s:conversion-gen:explicit-from=net/url.Values // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object message TableOptions { // includeObject decides whether to include each object along with its columnar information. diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/generated.proto b/vendor/k8s.io/apimachinery/pkg/runtime/generated.proto index de634e2c64e4..38f3ed0fd7b6 100644 --- a/vendor/k8s.io/apimachinery/pkg/runtime/generated.proto +++ b/vendor/k8s.io/apimachinery/pkg/runtime/generated.proto @@ -1,19 +1,3 @@ -/* -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. -*/ - // This file was autogenerated by go-to-protobuf. Do not edit it manually! diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto b/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto index 01a9c01e5c83..7762a29253c2 100644 --- a/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto +++ b/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto @@ -1,19 +1,3 @@ -/* -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. -*/ - // This file was autogenerated by go-to-protobuf. Do not edit it manually! diff --git a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto index 7c63c5e45af5..666b05e97d08 100644 --- a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto +++ b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto @@ -1,19 +1,3 @@ -/* -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. -*/ - // This file was autogenerated by go-to-protobuf. Do not edit it manually!