From a5fac30d815a367567512bc70409d28c151f38e5 Mon Sep 17 00:00:00 2001 From: "wangzhe.21" Date: Mon, 28 Aug 2023 21:02:24 +0800 Subject: [PATCH] feat(overcommit):add nodeOvercommitConfig crd --- ...st.kubewharf.io_nodeovercommitconfigs.yaml | 116 +++++++++++ hack/update-codegen.sh | 2 +- pkg/apis/overcommit/v1alpha1/doc.go | 22 +++ pkg/apis/overcommit/v1alpha1/register.go | 58 ++++++ pkg/apis/overcommit/v1alpha1/types.go | 70 +++++++ .../v1alpha1/zz_generated.deepcopy.go | 143 ++++++++++++++ pkg/client/clientset/versioned/clientset.go | 13 ++ .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 16 +- .../clientset/versioned/scheme/register.go | 16 +- .../typed/overcommit/v1alpha1/doc.go | 20 ++ .../typed/overcommit/v1alpha1/fake/doc.go | 20 ++ .../fake/fake_nodeovercommitconfig.go | 133 +++++++++++++ .../v1alpha1/fake/fake_overcommit_client.go | 40 ++++ .../v1alpha1/generated_expansion.go | 21 ++ .../v1alpha1/nodeovercommitconfig.go | 184 ++++++++++++++++++ .../overcommit/v1alpha1/overcommit_client.go | 107 ++++++++++ .../informers/externalversions/factory.go | 6 + .../informers/externalversions/generic.go | 5 + .../externalversions/overcommit/interface.go | 46 +++++ .../overcommit/v1alpha1/interface.go | 45 +++++ .../v1alpha1/nodeovercommitconfig.go | 89 +++++++++ .../v1alpha1/expansion_generated.go | 23 +++ .../v1alpha1/nodeovercommitconfig.go | 68 +++++++ pkg/consts/overcommit.go | 7 + 25 files changed, 1262 insertions(+), 15 deletions(-) create mode 100644 config/crd/bases/overcommit.katalyst.kubewharf.io_nodeovercommitconfigs.yaml create mode 100644 pkg/apis/overcommit/v1alpha1/doc.go create mode 100644 pkg/apis/overcommit/v1alpha1/register.go create mode 100644 pkg/apis/overcommit/v1alpha1/types.go create mode 100644 pkg/apis/overcommit/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/client/clientset/versioned/typed/overcommit/v1alpha1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_nodeovercommitconfig.go create mode 100644 pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_overcommit_client.go create mode 100644 pkg/client/clientset/versioned/typed/overcommit/v1alpha1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/overcommit/v1alpha1/nodeovercommitconfig.go create mode 100644 pkg/client/clientset/versioned/typed/overcommit/v1alpha1/overcommit_client.go create mode 100644 pkg/client/informers/externalversions/overcommit/interface.go create mode 100644 pkg/client/informers/externalversions/overcommit/v1alpha1/interface.go create mode 100644 pkg/client/informers/externalversions/overcommit/v1alpha1/nodeovercommitconfig.go create mode 100644 pkg/client/listers/overcommit/v1alpha1/expansion_generated.go create mode 100644 pkg/client/listers/overcommit/v1alpha1/nodeovercommitconfig.go diff --git a/config/crd/bases/overcommit.katalyst.kubewharf.io_nodeovercommitconfigs.yaml b/config/crd/bases/overcommit.katalyst.kubewharf.io_nodeovercommitconfigs.yaml new file mode 100644 index 0000000..16644d5 --- /dev/null +++ b/config/crd/bases/overcommit.katalyst.kubewharf.io_nodeovercommitconfigs.yaml @@ -0,0 +1,116 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: nodeovercommitconfigs.overcommit.katalyst.kubewharf.io +spec: + group: overcommit.katalyst.kubewharf.io + names: + kind: NodeOvercommitConfig + listKind: NodeOvercommitConfigList + plural: nodeovercommitconfigs + shortNames: + - noc + singular: nodeovercommitconfig + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .spec.resourceOvercommitRatioConfig + name: OVERCOMMITRATIO + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: NodeOvercommitConfig is the Schema for the nodeovercommitconfigs + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: NodeOvercommitConfigSpec is a description of a NodeOvercommitConfig + properties: + nodeList: + description: NodeList decides whether to check and update nodes if + node in NodeList when Type equals to NodeList + items: + type: string + type: array + nodeSelector: + description: Selector decides whether to update Nodes if the Node + matches the selector when Type equals to LabelSelector + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: A label selector requirement is a selector that + contains values, a key, and an operator that relates the key + and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: operator represents a key's relationship to + a set of values. Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + 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. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + 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. + type: object + type: object + resourceOvercommitRatioConfig: + additionalProperties: + type: string + description: ResourceOvercommitRatioConfig describes the resource + overcommit ratio that needs to inject into Node.Annotations cpu,memory + are supported. + type: object + type: object + status: + properties: + matchedNodeList: + description: NodeList which the nodeOvercommitConfig rules matched + items: + type: string + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 97fd821..6b72364 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -26,7 +26,7 @@ SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. # instead of the $GOPATH directly. For normal projects this can be dropped. ./hack/generate-groups.sh all \ github.com/kubewharf/katalyst-api/pkg/client github.com/kubewharf/katalyst-api/pkg/apis \ - "node:v1alpha1 autoscaling:v1alpha1 config:v1alpha1 workload:v1alpha1" \ + "node:v1alpha1 autoscaling:v1alpha1 config:v1alpha1 workload:v1alpha1 overcommit:v1alpha1" \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../../../" \ --go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt diff --git a/pkg/apis/overcommit/v1alpha1/doc.go b/pkg/apis/overcommit/v1alpha1/doc.go new file mode 100644 index 0000000..db419c2 --- /dev/null +++ b/pkg/apis/overcommit/v1alpha1/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2022 The Katalyst 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 +// +groupName=overcommit.katalyst.kubewharf.io +// +k8s:openapi-gen=true + +// Package v1alpha1 provides alpha API for Katalyst Overcommit API objects. +package v1alpha1 // import "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" diff --git a/pkg/apis/overcommit/v1alpha1/register.go b/pkg/apis/overcommit/v1alpha1/register.go new file mode 100644 index 0000000..9f475a7 --- /dev/null +++ b/pkg/apis/overcommit/v1alpha1/register.go @@ -0,0 +1,58 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + // GroupName is the group name used in this package + GroupName string = "overcommit.katalyst.kubewharf.io" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +const ( + ResourceNameNodeOvercommitConfigs = "nodeovercommitconfigs" +) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder collects schemas to build. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is used by generated client to add this scheme to the generated client. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &NodeOvercommitConfig{}, + &NodeOvercommitConfigList{}, + ) + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/overcommit/v1alpha1/types.go b/pkg/apis/overcommit/v1alpha1/types.go new file mode 100644 index 0000000..a3fd479 --- /dev/null +++ b/pkg/apis/overcommit/v1alpha1/types.go @@ -0,0 +1,70 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// NodeOvercommitConfigSpec is a description of a NodeOvercommitConfig +type NodeOvercommitConfigSpec struct { + // Selector decides whether to update Nodes if the Node matches the selector when Type equals to LabelSelector + // +optional + Selector *metav1.LabelSelector `json:"nodeSelector,omitempty"` + + // NodeList decides whether to check and update nodes if node in NodeList when Type equals to NodeList + // +optional + NodeList []string `json:"nodeList,omitempty"` + + // ResourceOvercommitRatioConfig describes the resource overcommit ratio that needs to inject into Node.Annotations + // cpu,memory are supported. + // +optional + ResourceOvercommitRatioConfig map[v1.ResourceName]string `json:"resourceOvercommitRatioConfig,omitempty"` +} + +type NodeOvercommitConfigStatus struct { + // NodeList which the nodeOvercommitConfig rules matched + MatchedNodeList []string `json:"matchedNodeList,omitempty"` +} + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,shortName=noc +// +kubebuilder:printcolumn:name="OVERCOMMITRATIO",type=string,JSONPath=".spec.resourceOvercommitRatioConfig" + +// NodeOvercommitConfig is the Schema for the nodeovercommitconfigs API +type NodeOvercommitConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NodeOvercommitConfigSpec `json:"spec,omitempty"` + Status NodeOvercommitConfigStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +//+kubebuilder:object:root=true + +// NodeOvercommitConfigList contains a list of NodeOvercommitConfig +type NodeOvercommitConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NodeOvercommitConfig `json:"items"` +} diff --git a/pkg/apis/overcommit/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/overcommit/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000..c2fce22 --- /dev/null +++ b/pkg/apis/overcommit/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,143 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022 The Katalyst 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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeOvercommitConfig) DeepCopyInto(out *NodeOvercommitConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeOvercommitConfig. +func (in *NodeOvercommitConfig) DeepCopy() *NodeOvercommitConfig { + if in == nil { + return nil + } + out := new(NodeOvercommitConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeOvercommitConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeOvercommitConfigList) DeepCopyInto(out *NodeOvercommitConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NodeOvercommitConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeOvercommitConfigList. +func (in *NodeOvercommitConfigList) DeepCopy() *NodeOvercommitConfigList { + if in == nil { + return nil + } + out := new(NodeOvercommitConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeOvercommitConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeOvercommitConfigSpec) DeepCopyInto(out *NodeOvercommitConfigSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.NodeList != nil { + in, out := &in.NodeList, &out.NodeList + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ResourceOvercommitRatioConfig != nil { + in, out := &in.ResourceOvercommitRatioConfig, &out.ResourceOvercommitRatioConfig + *out = make(map[corev1.ResourceName]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeOvercommitConfigSpec. +func (in *NodeOvercommitConfigSpec) DeepCopy() *NodeOvercommitConfigSpec { + if in == nil { + return nil + } + out := new(NodeOvercommitConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeOvercommitConfigStatus) DeepCopyInto(out *NodeOvercommitConfigStatus) { + *out = *in + if in.MatchedNodeList != nil { + in, out := &in.MatchedNodeList, &out.MatchedNodeList + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeOvercommitConfigStatus. +func (in *NodeOvercommitConfigStatus) DeepCopy() *NodeOvercommitConfigStatus { + if in == nil { + return nil + } + out := new(NodeOvercommitConfigStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 67695db..901df8c 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -25,6 +25,7 @@ import ( autoscalingv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" configv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/config/v1alpha1" nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/node/v1alpha1" + overcommitv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/overcommit/v1alpha1" workloadv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/workload/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" @@ -36,6 +37,7 @@ type Interface interface { AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface ConfigV1alpha1() configv1alpha1.ConfigV1alpha1Interface NodeV1alpha1() nodev1alpha1.NodeV1alpha1Interface + OvercommitV1alpha1() overcommitv1alpha1.OvercommitV1alpha1Interface WorkloadV1alpha1() workloadv1alpha1.WorkloadV1alpha1Interface } @@ -46,6 +48,7 @@ type Clientset struct { autoscalingV1alpha1 *autoscalingv1alpha1.AutoscalingV1alpha1Client configV1alpha1 *configv1alpha1.ConfigV1alpha1Client nodeV1alpha1 *nodev1alpha1.NodeV1alpha1Client + overcommitV1alpha1 *overcommitv1alpha1.OvercommitV1alpha1Client workloadV1alpha1 *workloadv1alpha1.WorkloadV1alpha1Client } @@ -64,6 +67,11 @@ func (c *Clientset) NodeV1alpha1() nodev1alpha1.NodeV1alpha1Interface { return c.nodeV1alpha1 } +// OvercommitV1alpha1 retrieves the OvercommitV1alpha1Client +func (c *Clientset) OvercommitV1alpha1() overcommitv1alpha1.OvercommitV1alpha1Interface { + return c.overcommitV1alpha1 +} + // WorkloadV1alpha1 retrieves the WorkloadV1alpha1Client func (c *Clientset) WorkloadV1alpha1() workloadv1alpha1.WorkloadV1alpha1Interface { return c.workloadV1alpha1 @@ -125,6 +133,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.overcommitV1alpha1, err = overcommitv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.workloadV1alpha1, err = workloadv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -153,6 +165,7 @@ func New(c rest.Interface) *Clientset { cs.autoscalingV1alpha1 = autoscalingv1alpha1.New(c) cs.configV1alpha1 = configv1alpha1.New(c) cs.nodeV1alpha1 = nodev1alpha1.New(c) + cs.overcommitV1alpha1 = overcommitv1alpha1.New(c) cs.workloadV1alpha1 = workloadv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index f68c41c..92fead6 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -26,6 +26,8 @@ import ( fakeconfigv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/config/v1alpha1/fake" nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/node/v1alpha1" fakenodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/node/v1alpha1/fake" + overcommitv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/overcommit/v1alpha1" + fakeovercommitv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake" workloadv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/workload/v1alpha1" fakeworkloadv1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/workload/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" @@ -100,6 +102,11 @@ func (c *Clientset) NodeV1alpha1() nodev1alpha1.NodeV1alpha1Interface { return &fakenodev1alpha1.FakeNodeV1alpha1{Fake: &c.Fake} } +// OvercommitV1alpha1 retrieves the OvercommitV1alpha1Client +func (c *Clientset) OvercommitV1alpha1() overcommitv1alpha1.OvercommitV1alpha1Interface { + return &fakeovercommitv1alpha1.FakeOvercommitV1alpha1{Fake: &c.Fake} +} + // WorkloadV1alpha1 retrieves the WorkloadV1alpha1Client func (c *Clientset) WorkloadV1alpha1() workloadv1alpha1.WorkloadV1alpha1Interface { return &fakeworkloadv1alpha1.FakeWorkloadV1alpha1{Fake: &c.Fake} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 39e11b6..4632364 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -22,6 +22,7 @@ import ( autoscalingv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha1" configv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/config/v1alpha1" nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1" + overcommitv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" workloadv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/workload/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -37,20 +38,21 @@ var localSchemeBuilder = runtime.SchemeBuilder{ autoscalingv1alpha1.AddToScheme, configv1alpha1.AddToScheme, nodev1alpha1.AddToScheme, + overcommitv1alpha1.AddToScheme, workloadv1alpha1.AddToScheme, } // 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/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 632af74..b49f332 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -22,6 +22,7 @@ import ( autoscalingv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha1" configv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/config/v1alpha1" nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1" + overcommitv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" workloadv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/workload/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -37,20 +38,21 @@ var localSchemeBuilder = runtime.SchemeBuilder{ autoscalingv1alpha1.AddToScheme, configv1alpha1.AddToScheme, nodev1alpha1.AddToScheme, + overcommitv1alpha1.AddToScheme, workloadv1alpha1.AddToScheme, } // 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/client/clientset/versioned/typed/overcommit/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/doc.go new file mode 100644 index 0000000..b4638d4 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/doc.go new file mode 100644 index 0000000..f968721 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2022 The Katalyst 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 diff --git a/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_nodeovercommitconfig.go b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_nodeovercommitconfig.go new file mode 100644 index 0000000..bc68de1 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_nodeovercommitconfig.go @@ -0,0 +1,133 @@ +/* +Copyright 2022 The Katalyst 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 ( + "context" + + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" + 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" +) + +// FakeNodeOvercommitConfigs implements NodeOvercommitConfigInterface +type FakeNodeOvercommitConfigs struct { + Fake *FakeOvercommitV1alpha1 +} + +var nodeovercommitconfigsResource = schema.GroupVersionResource{Group: "overcommit.katalyst.kubewharf.io", Version: "v1alpha1", Resource: "nodeovercommitconfigs"} + +var nodeovercommitconfigsKind = schema.GroupVersionKind{Group: "overcommit.katalyst.kubewharf.io", Version: "v1alpha1", Kind: "NodeOvercommitConfig"} + +// Get takes name of the nodeOvercommitConfig, and returns the corresponding nodeOvercommitConfig object, and an error if there is any. +func (c *FakeNodeOvercommitConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodeOvercommitConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(nodeovercommitconfigsResource, name), &v1alpha1.NodeOvercommitConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeOvercommitConfig), err +} + +// List takes label and field selectors, and returns the list of NodeOvercommitConfigs that match those selectors. +func (c *FakeNodeOvercommitConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeOvercommitConfigList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(nodeovercommitconfigsResource, nodeovercommitconfigsKind, opts), &v1alpha1.NodeOvercommitConfigList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NodeOvercommitConfigList{ListMeta: obj.(*v1alpha1.NodeOvercommitConfigList).ListMeta} + for _, item := range obj.(*v1alpha1.NodeOvercommitConfigList).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 nodeOvercommitConfigs. +func (c *FakeNodeOvercommitConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(nodeovercommitconfigsResource, opts)) +} + +// Create takes the representation of a nodeOvercommitConfig and creates it. Returns the server's representation of the nodeOvercommitConfig, and an error, if there is any. +func (c *FakeNodeOvercommitConfigs) Create(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.CreateOptions) (result *v1alpha1.NodeOvercommitConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(nodeovercommitconfigsResource, nodeOvercommitConfig), &v1alpha1.NodeOvercommitConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeOvercommitConfig), err +} + +// Update takes the representation of a nodeOvercommitConfig and updates it. Returns the server's representation of the nodeOvercommitConfig, and an error, if there is any. +func (c *FakeNodeOvercommitConfigs) Update(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.UpdateOptions) (result *v1alpha1.NodeOvercommitConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(nodeovercommitconfigsResource, nodeOvercommitConfig), &v1alpha1.NodeOvercommitConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeOvercommitConfig), 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 *FakeNodeOvercommitConfigs) UpdateStatus(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.UpdateOptions) (*v1alpha1.NodeOvercommitConfig, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(nodeovercommitconfigsResource, "status", nodeOvercommitConfig), &v1alpha1.NodeOvercommitConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeOvercommitConfig), err +} + +// Delete takes name of the nodeOvercommitConfig and deletes it. Returns an error if one occurs. +func (c *FakeNodeOvercommitConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(nodeovercommitconfigsResource, name, opts), &v1alpha1.NodeOvercommitConfig{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNodeOvercommitConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(nodeovercommitconfigsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NodeOvercommitConfigList{}) + return err +} + +// Patch applies the patch and returns the patched nodeOvercommitConfig. +func (c *FakeNodeOvercommitConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeOvercommitConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(nodeovercommitconfigsResource, name, pt, data, subresources...), &v1alpha1.NodeOvercommitConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeOvercommitConfig), err +} diff --git a/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_overcommit_client.go b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_overcommit_client.go new file mode 100644 index 0000000..9ffc861 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/fake/fake_overcommit_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2022 The Katalyst 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 ( + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/typed/overcommit/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeOvercommitV1alpha1 struct { + *testing.Fake +} + +func (c *FakeOvercommitV1alpha1) NodeOvercommitConfigs() v1alpha1.NodeOvercommitConfigInterface { + return &FakeNodeOvercommitConfigs{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeOvercommitV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/generated_expansion.go new file mode 100644 index 0000000..fd0d700 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 + +type NodeOvercommitConfigExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/nodeovercommitconfig.go b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/nodeovercommitconfig.go new file mode 100644 index 0000000..5ffcedc --- /dev/null +++ b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/nodeovercommitconfig.go @@ -0,0 +1,184 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" + scheme "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NodeOvercommitConfigsGetter has a method to return a NodeOvercommitConfigInterface. +// A group's client should implement this interface. +type NodeOvercommitConfigsGetter interface { + NodeOvercommitConfigs() NodeOvercommitConfigInterface +} + +// NodeOvercommitConfigInterface has methods to work with NodeOvercommitConfig resources. +type NodeOvercommitConfigInterface interface { + Create(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.CreateOptions) (*v1alpha1.NodeOvercommitConfig, error) + Update(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.UpdateOptions) (*v1alpha1.NodeOvercommitConfig, error) + UpdateStatus(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.UpdateOptions) (*v1alpha1.NodeOvercommitConfig, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NodeOvercommitConfig, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NodeOvercommitConfigList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeOvercommitConfig, err error) + NodeOvercommitConfigExpansion +} + +// nodeOvercommitConfigs implements NodeOvercommitConfigInterface +type nodeOvercommitConfigs struct { + client rest.Interface +} + +// newNodeOvercommitConfigs returns a NodeOvercommitConfigs +func newNodeOvercommitConfigs(c *OvercommitV1alpha1Client) *nodeOvercommitConfigs { + return &nodeOvercommitConfigs{ + client: c.RESTClient(), + } +} + +// Get takes name of the nodeOvercommitConfig, and returns the corresponding nodeOvercommitConfig object, and an error if there is any. +func (c *nodeOvercommitConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodeOvercommitConfig, err error) { + result = &v1alpha1.NodeOvercommitConfig{} + err = c.client.Get(). + Resource("nodeovercommitconfigs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NodeOvercommitConfigs that match those selectors. +func (c *nodeOvercommitConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeOvercommitConfigList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NodeOvercommitConfigList{} + err = c.client.Get(). + Resource("nodeovercommitconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nodeOvercommitConfigs. +func (c *nodeOvercommitConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("nodeovercommitconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a nodeOvercommitConfig and creates it. Returns the server's representation of the nodeOvercommitConfig, and an error, if there is any. +func (c *nodeOvercommitConfigs) Create(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.CreateOptions) (result *v1alpha1.NodeOvercommitConfig, err error) { + result = &v1alpha1.NodeOvercommitConfig{} + err = c.client.Post(). + Resource("nodeovercommitconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodeOvercommitConfig). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a nodeOvercommitConfig and updates it. Returns the server's representation of the nodeOvercommitConfig, and an error, if there is any. +func (c *nodeOvercommitConfigs) Update(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.UpdateOptions) (result *v1alpha1.NodeOvercommitConfig, err error) { + result = &v1alpha1.NodeOvercommitConfig{} + err = c.client.Put(). + Resource("nodeovercommitconfigs"). + Name(nodeOvercommitConfig.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodeOvercommitConfig). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *nodeOvercommitConfigs) UpdateStatus(ctx context.Context, nodeOvercommitConfig *v1alpha1.NodeOvercommitConfig, opts v1.UpdateOptions) (result *v1alpha1.NodeOvercommitConfig, err error) { + result = &v1alpha1.NodeOvercommitConfig{} + err = c.client.Put(). + Resource("nodeovercommitconfigs"). + Name(nodeOvercommitConfig.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodeOvercommitConfig). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the nodeOvercommitConfig and deletes it. Returns an error if one occurs. +func (c *nodeOvercommitConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("nodeovercommitconfigs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *nodeOvercommitConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("nodeovercommitconfigs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched nodeOvercommitConfig. +func (c *nodeOvercommitConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeOvercommitConfig, err error) { + result = &v1alpha1.NodeOvercommitConfig{} + err = c.client.Patch(pt). + Resource("nodeovercommitconfigs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/overcommit_client.go b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/overcommit_client.go new file mode 100644 index 0000000..be583b2 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/overcommit/v1alpha1/overcommit_client.go @@ -0,0 +1,107 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" + "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type OvercommitV1alpha1Interface interface { + RESTClient() rest.Interface + NodeOvercommitConfigsGetter +} + +// OvercommitV1alpha1Client is used to interact with features provided by the overcommit.katalyst.kubewharf.io group. +type OvercommitV1alpha1Client struct { + restClient rest.Interface +} + +func (c *OvercommitV1alpha1Client) NodeOvercommitConfigs() NodeOvercommitConfigInterface { + return newNodeOvercommitConfigs(c) +} + +// NewForConfig creates a new OvercommitV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*OvercommitV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new OvercommitV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*OvercommitV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &OvercommitV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new OvercommitV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *OvercommitV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new OvercommitV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *OvercommitV1alpha1Client { + return &OvercommitV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + 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 *OvercommitV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index 3115206..3cd4bdb 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -28,6 +28,7 @@ import ( config "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/config" internalinterfaces "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/internalinterfaces" node "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/node" + overcommit "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/overcommit" workload "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/workload" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -178,6 +179,7 @@ type SharedInformerFactory interface { Autoscaling() autoscaling.Interface Config() config.Interface Node() node.Interface + Overcommit() overcommit.Interface Workload() workload.Interface } @@ -193,6 +195,10 @@ func (f *sharedInformerFactory) Node() node.Interface { return node.New(f, f.namespace, f.tweakListOptions) } +func (f *sharedInformerFactory) Overcommit() overcommit.Interface { + return overcommit.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Workload() workload.Interface { return workload.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 699c318..d0fa0d4 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -24,6 +24,7 @@ import ( v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha1" configv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/config/v1alpha1" nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1" + overcommitv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" workloadv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/workload/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" @@ -71,6 +72,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case nodev1alpha1.SchemeGroupVersion.WithResource("customnoderesources"): return &genericInformer{resource: resource.GroupResource(), informer: f.Node().V1alpha1().CustomNodeResources().Informer()}, nil + // Group=overcommit.katalyst.kubewharf.io, Version=v1alpha1 + case overcommitv1alpha1.SchemeGroupVersion.WithResource("nodeovercommitconfigs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Overcommit().V1alpha1().NodeOvercommitConfigs().Informer()}, nil + // Group=workload.katalyst.kubewharf.io, Version=v1alpha1 case workloadv1alpha1.SchemeGroupVersion.WithResource("serviceprofiledescriptors"): return &genericInformer{resource: resource.GroupResource(), informer: f.Workload().V1alpha1().ServiceProfileDescriptors().Informer()}, nil diff --git a/pkg/client/informers/externalversions/overcommit/interface.go b/pkg/client/informers/externalversions/overcommit/interface.go new file mode 100644 index 0000000..6dc11d5 --- /dev/null +++ b/pkg/client/informers/externalversions/overcommit/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2022 The Katalyst 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 overcommit + +import ( + internalinterfaces "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/overcommit/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group 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 &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/overcommit/v1alpha1/interface.go b/pkg/client/informers/externalversions/overcommit/v1alpha1/interface.go new file mode 100644 index 0000000..09528fc --- /dev/null +++ b/pkg/client/informers/externalversions/overcommit/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 + +import ( + internalinterfaces "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // NodeOvercommitConfigs returns a NodeOvercommitConfigInformer. + NodeOvercommitConfigs() NodeOvercommitConfigInformer +} + +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} +} + +// NodeOvercommitConfigs returns a NodeOvercommitConfigInformer. +func (v *version) NodeOvercommitConfigs() NodeOvercommitConfigInformer { + return &nodeOvercommitConfigInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/overcommit/v1alpha1/nodeovercommitconfig.go b/pkg/client/informers/externalversions/overcommit/v1alpha1/nodeovercommitconfig.go new file mode 100644 index 0000000..a01e481 --- /dev/null +++ b/pkg/client/informers/externalversions/overcommit/v1alpha1/nodeovercommitconfig.go @@ -0,0 +1,89 @@ +/* +Copyright 2022 The Katalyst 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 v1alpha1 + +import ( + "context" + time "time" + + overcommitv1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" + versioned "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/listers/overcommit/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NodeOvercommitConfigInformer provides access to a shared informer and lister for +// NodeOvercommitConfigs. +type NodeOvercommitConfigInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NodeOvercommitConfigLister +} + +type nodeOvercommitConfigInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewNodeOvercommitConfigInformer constructs a new informer for NodeOvercommitConfig 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 NewNodeOvercommitConfigInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNodeOvercommitConfigInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredNodeOvercommitConfigInformer constructs a new informer for NodeOvercommitConfig 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 NewFilteredNodeOvercommitConfigInformer(client versioned.Interface, 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.OvercommitV1alpha1().NodeOvercommitConfigs().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OvercommitV1alpha1().NodeOvercommitConfigs().Watch(context.TODO(), options) + }, + }, + &overcommitv1alpha1.NodeOvercommitConfig{}, + resyncPeriod, + indexers, + ) +} + +func (f *nodeOvercommitConfigInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNodeOvercommitConfigInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *nodeOvercommitConfigInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&overcommitv1alpha1.NodeOvercommitConfig{}, f.defaultInformer) +} + +func (f *nodeOvercommitConfigInformer) Lister() v1alpha1.NodeOvercommitConfigLister { + return v1alpha1.NewNodeOvercommitConfigLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/overcommit/v1alpha1/expansion_generated.go b/pkg/client/listers/overcommit/v1alpha1/expansion_generated.go new file mode 100644 index 0000000..e4f964c --- /dev/null +++ b/pkg/client/listers/overcommit/v1alpha1/expansion_generated.go @@ -0,0 +1,23 @@ +/* +Copyright 2022 The Katalyst 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +// NodeOvercommitConfigListerExpansion allows custom methods to be added to +// NodeOvercommitConfigLister. +type NodeOvercommitConfigListerExpansion interface{} diff --git a/pkg/client/listers/overcommit/v1alpha1/nodeovercommitconfig.go b/pkg/client/listers/overcommit/v1alpha1/nodeovercommitconfig.go new file mode 100644 index 0000000..e69f636 --- /dev/null +++ b/pkg/client/listers/overcommit/v1alpha1/nodeovercommitconfig.go @@ -0,0 +1,68 @@ +/* +Copyright 2022 The Katalyst 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/overcommit/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NodeOvercommitConfigLister helps list NodeOvercommitConfigs. +// All objects returned here must be treated as read-only. +type NodeOvercommitConfigLister interface { + // List lists all NodeOvercommitConfigs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NodeOvercommitConfig, err error) + // Get retrieves the NodeOvercommitConfig from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NodeOvercommitConfig, error) + NodeOvercommitConfigListerExpansion +} + +// nodeOvercommitConfigLister implements the NodeOvercommitConfigLister interface. +type nodeOvercommitConfigLister struct { + indexer cache.Indexer +} + +// NewNodeOvercommitConfigLister returns a new NodeOvercommitConfigLister. +func NewNodeOvercommitConfigLister(indexer cache.Indexer) NodeOvercommitConfigLister { + return &nodeOvercommitConfigLister{indexer: indexer} +} + +// List lists all NodeOvercommitConfigs in the indexer. +func (s *nodeOvercommitConfigLister) List(selector labels.Selector) (ret []*v1alpha1.NodeOvercommitConfig, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NodeOvercommitConfig)) + }) + return ret, err +} + +// Get retrieves the NodeOvercommitConfig from the index for a given name. +func (s *nodeOvercommitConfigLister) Get(name string) (*v1alpha1.NodeOvercommitConfig, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("nodeovercommitconfig"), name) + } + return obj.(*v1alpha1.NodeOvercommitConfig), nil +} diff --git a/pkg/consts/overcommit.go b/pkg/consts/overcommit.go index 5ac98ab..f7f7ccd 100644 --- a/pkg/consts/overcommit.go +++ b/pkg/consts/overcommit.go @@ -26,3 +26,10 @@ const ( NodeAnnotationOriginalAllocatableCPUKey = "katalyst.kubewharf.io/original_allocatable_cpu" NodeAnnotationOriginalAllocatableMemoryKey = "katalyst.kubewharf.io/original_allocatable_memory" ) + +const ( + NodeOvercommitSelectorKey = "katalyst.kubewharf.io/overcommit_node_pool" + + DefaultNodeCPUOvercommitRatio = "1" + DefaultNodeMemoryOvercommitRatio = "1" +)