Add capacity buffer CRD

This commit is contained in:
Omran 2025-09-09 08:54:08 +00:00
parent 45d513d8e1
commit 509aa6be9f
No known key found for this signature in database
33 changed files with 2760 additions and 0 deletions

View File

@ -0,0 +1,24 @@
/*
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:deepcopy-gen=package
// +groupName=autoscaling.x-k8s.io
// +k8s:openapi-gen=true
// +k8s:protobuf-gen=package
// +k8s:prerelease-lifecycle-gen=true
// +kubebuilder:object:generate=true
package v1

View File

@ -0,0 +1,56 @@
/*
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: "autoscaling.x-k8s.io", Version: "v1"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
// SchemeBuilder points to a list of functions added to Scheme.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
// AddToScheme applies all the stored functions to the scheme.
AddToScheme = localSchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&CapacityBuffer{},
&CapacityBufferList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

View File

@ -0,0 +1,190 @@
/*
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:deepcopy-gen=package
// +groupName=autoscaling.x-k8s.io
// +k8s:protobuf-gen=package
// Package v1 contains the v1 API for the autoscaling.x-k8s.io group.
// This API group defines custom resources used by the Cluster Autoscaler
// for managing buffer capacity.
package v1
import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// Dependencies for the generation of the code:
_ "github.com/onsi/ginkgo/v2"
_ "github.com/onsi/gomega"
_ "k8s.io/code-generator"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=capacitybuffers,scope=Cluster,shortName=cb
// +kubebuilder:printcolumn:name="Strategy",type="string",JSONPath=".spec.provisioningStrategy",description="The strategy used for provisioning buffer capacity."
// +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".spec.replicas",description="The desired number of buffer chunks, if specified."
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason",description="The readiness status of the CapacityBuffer."
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="The age of the CapacityBuffer."
// +k8s:openapi-gen=true
// CapacityBuffer is the configuration that an autoscaler can use to provision buffer capacity within a cluster.
// This buffer is represented by placeholder pods that trigger the Cluster Autoscaler to scale up nodes in advance,
// ensuring that there is always spare capacity available to handle sudden workload spikes or to speed up scaling events.
type CapacityBuffer struct {
// Standard Kubernetes object metadata.
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Spec defines the desired characteristics of the buffer.
// +kubebuilder:validation:Required
Spec CapacityBufferSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
// Status represents the current state of the buffer and its readiness for autoprovisioning.
// +optional
Status CapacityBufferStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// LocalObjectRef contains the name of the object being referred to.
type LocalObjectRef struct {
// Name of the object.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
}
// ResourceName is the name identifying a resource mirroring k8s.io/api/core/v1.ResourceName.
// +k8s:openapi-gen=true
type ResourceName string
// ScalableRef contains name, kind and API group of an object that can be scaled.
type ScalableRef struct {
// APIGroup of the scalable object.
// Empty string for the core API group
// +optional
APIGroup string `json:"apiGroup,omitempty" protobuf:"bytes,1,opt,name=apiGroup"`
// Kind of the scalable object (e.g., "Deployment", "StatefulSet").
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Kind string `json:"kind" protobuf:"bytes,2,opt,name=kind"`
// Name of the scalable object.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Name string `json:"name" protobuf:"bytes,3,opt,name=name"`
}
// ResourceList is a set of (resource name, quantity) pairs.
// This is mirroring k8s.io/api/core/v1.ResourceList to avoid direct dependency.
// +k8s:openapi-gen=true
type ResourceList map[ResourceName]resource.Quantity
// CapacityBufferSpec defines the desired state of CapacityBuffer.
type CapacityBufferSpec struct {
// ProvisioningStrategy defines how the buffer is utilized.
// "active-capacity" is the default strategy, where the buffer actively scales up the cluster by creating placeholder pods.
// +kubebuilder:validation:Enum=active-capacity
// +kubebuilder:default="active-capacity"
// +optional
ProvisioningStrategy *string `json:"provisioningStrategy,omitempty" protobuf:"bytes,1,opt,name=provisioningStrategy"`
// PodTemplateRef is a reference to a PodTemplate resource in the same namespace
// that declares the shape of a single chunk of the buffer. The pods created
// from this template will be used as placeholder pods for the buffer capacity.
// Exactly one of `podTemplateRef`, `scalableRef` should be specified.
// +optional
// +kubebuilder:validation:Xor=podTemplateRef,scalableRef
PodTemplateRef *LocalObjectRef `json:"podTemplateRef,omitempty" protobuf:"bytes,2,opt,name=podTemplateRef"`
// ScalableRef is a reference to an object of a kind that has a scale subresource
// and specifies its label selector field. This allows the CapacityBuffer to
// manage the buffer by scaling an existing scalable resource.
// Exactly one of `podTemplateRef`, `scalableRef` should be specified.
// +optional
// +kubebuilder:validation:Xor=podTemplateRef,scalableRef
ScalableRef *ScalableRef `json:"scalableRef,omitempty" protobuf:"bytes,3,opt,name=scalableRef"`
// Replicas defines the desired number of buffer chunks to provision.
// If neither `replicas` nor `percentage` is set, as many chunks as fit within
// defined resource limits (if any) will be created. If both are set, the maximum
// of the two will be used.
// This field is mutually exclusive with `percentage` when `scalableRef` is set.
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:ExclusiveMinimum=false
// +kubebuilder:validation:Xor=replicas,percentage
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,4,opt,name=replicas"`
// Percentage defines the desired buffer capacity as a percentage of the
// `scalableRef`'s current replicas. This is only applicable if `scalableRef` is set.
// The absolute number of replicas is calculated from the percentage by rounding up to a minimum of 1.
// For example, if `scalableRef` has 10 replicas and `percentage` is 20, 2 buffer chunks will be created.
// This field is mutually exclusive with `replicas`.
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
// +kubebuilder:validation:ExclusiveMaximum=false
// +kubebuilder:validation:ExclusiveMinimum=false
// +kubebuilder:validation:Xor=replicas,percentage
Percentage *int32 `json:"percentage,omitempty" protobuf:"varint,5,opt,name=percentage"`
// Limits, if specified, will limit the number of chunks created for this buffer
// based on total resource requests (e.g., CPU, memory). If there are no other
// limitations for the number of chunks (i.e., `replicas` or `percentage` are not set),
// this will be used to create as many chunks as fit into these limits.
// +optional
Limits *ResourceList `json:"limits,omitempty" protobuf:"bytes,6,opt,name=limits"`
}
// CapacityBufferStatus defines the observed state of CapacityBuffer.
type CapacityBufferStatus struct {
// PodTemplateRef is the observed reference to the PodTemplate that was used
// to provision the buffer. If this field is not set, and the `conditions`
// indicate an error, it provides details about the error state.
// +optional
PodTemplateRef *LocalObjectRef `json:"podTemplateRef,omitempty" protobuf:"bytes,1,opt,name=podTemplateRef"`
// Replicas is the actual number of buffer chunks currently provisioned.
// +optional
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`
// PodTemplateGeneration is the observed generation of the PodTemplate, used
// to determine if the status is up-to-date with the desired `spec.podTemplateRef`.
// +optional
PodTemplateGeneration *int64 `json:"podTemplateGeneration,omitempty" protobuf:"varint,3,opt,name=podTemplateGeneration"`
// Conditions provide a standard mechanism for reporting the buffer's state.
// The "Ready" condition indicates if the buffer is successfully provisioned
// and active. Other conditions may report on various aspects of the buffer's
// health and provisioning process.
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,4,rep,name=conditions"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CapacityBufferList contains a list of CapacityBuffer objects.
type CapacityBufferList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Items []CapacityBuffer `json:"items" protobuf:"bytes,2,rep,name=items"`
}

View File

@ -0,0 +1,233 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1
import (
resource "k8s.io/apimachinery/pkg/api/resource"
metav1 "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 *CapacityBuffer) DeepCopyInto(out *CapacityBuffer) {
*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 CapacityBuffer.
func (in *CapacityBuffer) DeepCopy() *CapacityBuffer {
if in == nil {
return nil
}
out := new(CapacityBuffer)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *CapacityBuffer) 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 *CapacityBufferList) DeepCopyInto(out *CapacityBufferList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]CapacityBuffer, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacityBufferList.
func (in *CapacityBufferList) DeepCopy() *CapacityBufferList {
if in == nil {
return nil
}
out := new(CapacityBufferList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *CapacityBufferList) 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 *CapacityBufferSpec) DeepCopyInto(out *CapacityBufferSpec) {
*out = *in
if in.ProvisioningStrategy != nil {
in, out := &in.ProvisioningStrategy, &out.ProvisioningStrategy
*out = new(string)
**out = **in
}
if in.PodTemplateRef != nil {
in, out := &in.PodTemplateRef, &out.PodTemplateRef
*out = new(LocalObjectRef)
**out = **in
}
if in.ScalableRef != nil {
in, out := &in.ScalableRef, &out.ScalableRef
*out = new(ScalableRef)
**out = **in
}
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(int32)
**out = **in
}
if in.Percentage != nil {
in, out := &in.Percentage, &out.Percentage
*out = new(int32)
**out = **in
}
if in.Limits != nil {
in, out := &in.Limits, &out.Limits
*out = new(ResourceList)
if **in != nil {
in, out := *in, *out
*out = make(map[ResourceName]resource.Quantity, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacityBufferSpec.
func (in *CapacityBufferSpec) DeepCopy() *CapacityBufferSpec {
if in == nil {
return nil
}
out := new(CapacityBufferSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CapacityBufferStatus) DeepCopyInto(out *CapacityBufferStatus) {
*out = *in
if in.PodTemplateRef != nil {
in, out := &in.PodTemplateRef, &out.PodTemplateRef
*out = new(LocalObjectRef)
**out = **in
}
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(int32)
**out = **in
}
if in.PodTemplateGeneration != nil {
in, out := &in.PodTemplateGeneration, &out.PodTemplateGeneration
*out = new(int64)
**out = **in
}
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]metav1.Condition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacityBufferStatus.
func (in *CapacityBufferStatus) DeepCopy() *CapacityBufferStatus {
if in == nil {
return nil
}
out := new(CapacityBufferStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LocalObjectRef) DeepCopyInto(out *LocalObjectRef) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalObjectRef.
func (in *LocalObjectRef) DeepCopy() *LocalObjectRef {
if in == nil {
return nil
}
out := new(LocalObjectRef)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in ResourceList) DeepCopyInto(out *ResourceList) {
{
in := &in
*out = make(ResourceList, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceList.
func (in ResourceList) DeepCopy() ResourceList {
if in == nil {
return nil
}
out := new(ResourceList)
in.DeepCopyInto(out)
return *out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ScalableRef) DeepCopyInto(out *ScalableRef) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScalableRef.
func (in *ScalableRef) DeepCopy() *ScalableRef {
if in == nil {
return nil
}
out := new(ScalableRef)
in.DeepCopyInto(out)
return out
}

View File

@ -0,0 +1,242 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
metav1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// CapacityBufferApplyConfiguration represents a declarative configuration of the CapacityBuffer type for use
// with apply.
type CapacityBufferApplyConfiguration struct {
metav1.TypeMetaApplyConfiguration `json:",inline"`
*metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
Spec *CapacityBufferSpecApplyConfiguration `json:"spec,omitempty"`
Status *CapacityBufferStatusApplyConfiguration `json:"status,omitempty"`
}
// CapacityBuffer constructs a declarative configuration of the CapacityBuffer type for use with
// apply.
func CapacityBuffer(name, namespace string) *CapacityBufferApplyConfiguration {
b := &CapacityBufferApplyConfiguration{}
b.WithName(name)
b.WithNamespace(namespace)
b.WithKind("CapacityBuffer")
b.WithAPIVersion("autoscaling.x-k8s.io/v1")
return b
}
func (b CapacityBufferApplyConfiguration) IsApplyConfiguration() {}
// WithKind sets the Kind field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Kind field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithKind(value string) *CapacityBufferApplyConfiguration {
b.TypeMetaApplyConfiguration.Kind = &value
return b
}
// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the APIVersion field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithAPIVersion(value string) *CapacityBufferApplyConfiguration {
b.TypeMetaApplyConfiguration.APIVersion = &value
return b
}
// WithName sets the Name field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Name field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithName(value string) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.Name = &value
return b
}
// WithGenerateName sets the GenerateName field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the GenerateName field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithGenerateName(value string) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.GenerateName = &value
return b
}
// WithNamespace sets the Namespace field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Namespace field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithNamespace(value string) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.Namespace = &value
return b
}
// WithUID sets the UID field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the UID field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithUID(value types.UID) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.UID = &value
return b
}
// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ResourceVersion field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithResourceVersion(value string) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.ResourceVersion = &value
return b
}
// WithGeneration sets the Generation field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Generation field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithGeneration(value int64) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.Generation = &value
return b
}
// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the CreationTimestamp field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.CreationTimestamp = &value
return b
}
// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the DeletionTimestamp field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value
return b
}
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value
return b
}
// WithLabels puts the entries into the Labels field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, the entries provided by each call will be put on the Labels field,
// overwriting an existing map entries in Labels field with the same key.
func (b *CapacityBufferApplyConfiguration) WithLabels(entries map[string]string) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
}
for k, v := range entries {
b.ObjectMetaApplyConfiguration.Labels[k] = v
}
return b
}
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, the entries provided by each call will be put on the Annotations field,
// overwriting an existing map entries in Annotations field with the same key.
func (b *CapacityBufferApplyConfiguration) WithAnnotations(entries map[string]string) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
}
for k, v := range entries {
b.ObjectMetaApplyConfiguration.Annotations[k] = v
}
return b
}
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
func (b *CapacityBufferApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
if values[i] == nil {
panic("nil value passed to WithOwnerReferences")
}
b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i])
}
return b
}
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Finalizers field.
func (b *CapacityBufferApplyConfiguration) WithFinalizers(values ...string) *CapacityBufferApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
}
return b
}
func (b *CapacityBufferApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
if b.ObjectMetaApplyConfiguration == nil {
b.ObjectMetaApplyConfiguration = &metav1.ObjectMetaApplyConfiguration{}
}
}
// WithSpec sets the Spec field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Spec field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithSpec(value *CapacityBufferSpecApplyConfiguration) *CapacityBufferApplyConfiguration {
b.Spec = value
return b
}
// WithStatus sets the Status field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Status field is set to the value of the last call.
func (b *CapacityBufferApplyConfiguration) WithStatus(value *CapacityBufferStatusApplyConfiguration) *CapacityBufferApplyConfiguration {
b.Status = value
return b
}
// GetKind retrieves the value of the Kind field in the declarative configuration.
func (b *CapacityBufferApplyConfiguration) GetKind() *string {
return b.TypeMetaApplyConfiguration.Kind
}
// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration.
func (b *CapacityBufferApplyConfiguration) GetAPIVersion() *string {
return b.TypeMetaApplyConfiguration.APIVersion
}
// GetName retrieves the value of the Name field in the declarative configuration.
func (b *CapacityBufferApplyConfiguration) GetName() *string {
b.ensureObjectMetaApplyConfigurationExists()
return b.ObjectMetaApplyConfiguration.Name
}
// GetNamespace retrieves the value of the Namespace field in the declarative configuration.
func (b *CapacityBufferApplyConfiguration) GetNamespace() *string {
b.ensureObjectMetaApplyConfigurationExists()
return b.ObjectMetaApplyConfiguration.Namespace
}

View File

@ -0,0 +1,88 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
autoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
)
// CapacityBufferSpecApplyConfiguration represents a declarative configuration of the CapacityBufferSpec type for use
// with apply.
type CapacityBufferSpecApplyConfiguration struct {
ProvisioningStrategy *string `json:"provisioningStrategy,omitempty"`
PodTemplateRef *LocalObjectRefApplyConfiguration `json:"podTemplateRef,omitempty"`
ScalableRef *ScalableRefApplyConfiguration `json:"scalableRef,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
Percentage *int32 `json:"percentage,omitempty"`
Limits *autoscalingxk8siov1.ResourceList `json:"limits,omitempty"`
}
// CapacityBufferSpecApplyConfiguration constructs a declarative configuration of the CapacityBufferSpec type for use with
// apply.
func CapacityBufferSpec() *CapacityBufferSpecApplyConfiguration {
return &CapacityBufferSpecApplyConfiguration{}
}
// WithProvisioningStrategy sets the ProvisioningStrategy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ProvisioningStrategy field is set to the value of the last call.
func (b *CapacityBufferSpecApplyConfiguration) WithProvisioningStrategy(value string) *CapacityBufferSpecApplyConfiguration {
b.ProvisioningStrategy = &value
return b
}
// WithPodTemplateRef sets the PodTemplateRef field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PodTemplateRef field is set to the value of the last call.
func (b *CapacityBufferSpecApplyConfiguration) WithPodTemplateRef(value *LocalObjectRefApplyConfiguration) *CapacityBufferSpecApplyConfiguration {
b.PodTemplateRef = value
return b
}
// WithScalableRef sets the ScalableRef field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ScalableRef field is set to the value of the last call.
func (b *CapacityBufferSpecApplyConfiguration) WithScalableRef(value *ScalableRefApplyConfiguration) *CapacityBufferSpecApplyConfiguration {
b.ScalableRef = value
return b
}
// WithReplicas sets the Replicas field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Replicas field is set to the value of the last call.
func (b *CapacityBufferSpecApplyConfiguration) WithReplicas(value int32) *CapacityBufferSpecApplyConfiguration {
b.Replicas = &value
return b
}
// WithPercentage sets the Percentage field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Percentage field is set to the value of the last call.
func (b *CapacityBufferSpecApplyConfiguration) WithPercentage(value int32) *CapacityBufferSpecApplyConfiguration {
b.Percentage = &value
return b
}
// WithLimits sets the Limits field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Limits field is set to the value of the last call.
func (b *CapacityBufferSpecApplyConfiguration) WithLimits(value autoscalingxk8siov1.ResourceList) *CapacityBufferSpecApplyConfiguration {
b.Limits = &value
return b
}

View File

@ -0,0 +1,75 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
metav1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// CapacityBufferStatusApplyConfiguration represents a declarative configuration of the CapacityBufferStatus type for use
// with apply.
type CapacityBufferStatusApplyConfiguration struct {
PodTemplateRef *LocalObjectRefApplyConfiguration `json:"podTemplateRef,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
PodTemplateGeneration *int64 `json:"podTemplateGeneration,omitempty"`
Conditions []metav1.ConditionApplyConfiguration `json:"conditions,omitempty"`
}
// CapacityBufferStatusApplyConfiguration constructs a declarative configuration of the CapacityBufferStatus type for use with
// apply.
func CapacityBufferStatus() *CapacityBufferStatusApplyConfiguration {
return &CapacityBufferStatusApplyConfiguration{}
}
// WithPodTemplateRef sets the PodTemplateRef field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PodTemplateRef field is set to the value of the last call.
func (b *CapacityBufferStatusApplyConfiguration) WithPodTemplateRef(value *LocalObjectRefApplyConfiguration) *CapacityBufferStatusApplyConfiguration {
b.PodTemplateRef = value
return b
}
// WithReplicas sets the Replicas field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Replicas field is set to the value of the last call.
func (b *CapacityBufferStatusApplyConfiguration) WithReplicas(value int32) *CapacityBufferStatusApplyConfiguration {
b.Replicas = &value
return b
}
// WithPodTemplateGeneration sets the PodTemplateGeneration field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PodTemplateGeneration field is set to the value of the last call.
func (b *CapacityBufferStatusApplyConfiguration) WithPodTemplateGeneration(value int64) *CapacityBufferStatusApplyConfiguration {
b.PodTemplateGeneration = &value
return b
}
// WithConditions adds the given value to the Conditions field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Conditions field.
func (b *CapacityBufferStatusApplyConfiguration) WithConditions(values ...*metav1.ConditionApplyConfiguration) *CapacityBufferStatusApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithConditions")
}
b.Conditions = append(b.Conditions, *values[i])
}
return b
}

View File

@ -0,0 +1,39 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
// LocalObjectRefApplyConfiguration represents a declarative configuration of the LocalObjectRef type for use
// with apply.
type LocalObjectRefApplyConfiguration struct {
Name *string `json:"name,omitempty"`
}
// LocalObjectRefApplyConfiguration constructs a declarative configuration of the LocalObjectRef type for use with
// apply.
func LocalObjectRef() *LocalObjectRefApplyConfiguration {
return &LocalObjectRefApplyConfiguration{}
}
// WithName sets the Name field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Name field is set to the value of the last call.
func (b *LocalObjectRefApplyConfiguration) WithName(value string) *LocalObjectRefApplyConfiguration {
b.Name = &value
return b
}

View File

@ -0,0 +1,57 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
// ScalableRefApplyConfiguration represents a declarative configuration of the ScalableRef type for use
// with apply.
type ScalableRefApplyConfiguration struct {
APIGroup *string `json:"apiGroup,omitempty"`
Kind *string `json:"kind,omitempty"`
Name *string `json:"name,omitempty"`
}
// ScalableRefApplyConfiguration constructs a declarative configuration of the ScalableRef type for use with
// apply.
func ScalableRef() *ScalableRefApplyConfiguration {
return &ScalableRefApplyConfiguration{}
}
// WithAPIGroup sets the APIGroup field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the APIGroup field is set to the value of the last call.
func (b *ScalableRefApplyConfiguration) WithAPIGroup(value string) *ScalableRefApplyConfiguration {
b.APIGroup = &value
return b
}
// WithKind sets the Kind field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Kind field is set to the value of the last call.
func (b *ScalableRefApplyConfiguration) WithKind(value string) *ScalableRefApplyConfiguration {
b.Kind = &value
return b
}
// WithName sets the Name field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Name field is set to the value of the last call.
func (b *ScalableRefApplyConfiguration) WithName(value string) *ScalableRefApplyConfiguration {
b.Name = &value
return b
}

View File

@ -0,0 +1,62 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package internal
import (
fmt "fmt"
sync "sync"
typed "sigs.k8s.io/structured-merge-diff/v6/typed"
)
func Parser() *typed.Parser {
parserOnce.Do(func() {
var err error
parser, err = typed.NewParser(schemaYAML)
if err != nil {
panic(fmt.Sprintf("Failed to parse schema: %v", err))
}
})
return parser
}
var parserOnce sync.Once
var parser *typed.Parser
var schemaYAML = typed.YAMLObject(`types:
- name: __untyped_atomic_
scalar: untyped
list:
elementType:
namedType: __untyped_atomic_
elementRelationship: atomic
map:
elementType:
namedType: __untyped_atomic_
elementRelationship: atomic
- name: __untyped_deduced_
scalar: untyped
list:
elementType:
namedType: __untyped_atomic_
elementRelationship: atomic
map:
elementType:
namedType: __untyped_deduced_
elementRelationship: separable
`)

View File

@ -0,0 +1,52 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package applyconfiguration
import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
v1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
autoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/applyconfiguration/autoscaling.x-k8s.io/v1"
internal "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/applyconfiguration/internal"
)
// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no
// apply configuration type exists for the given GroupVersionKind.
func ForKind(kind schema.GroupVersionKind) interface{} {
switch kind {
// Group=autoscaling.x-k8s.io, Version=v1
case v1.SchemeGroupVersion.WithKind("CapacityBuffer"):
return &autoscalingxk8siov1.CapacityBufferApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("CapacityBufferSpec"):
return &autoscalingxk8siov1.CapacityBufferSpecApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("CapacityBufferStatus"):
return &autoscalingxk8siov1.CapacityBufferStatusApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("LocalObjectRef"):
return &autoscalingxk8siov1.LocalObjectRefApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("ScalableRef"):
return &autoscalingxk8siov1.ScalableRefApplyConfiguration{}
}
return nil
}
func NewTypeConverter(scheme *runtime.Scheme) managedfields.TypeConverter {
return managedfields.NewSchemeTypeConverter(scheme, internal.Parser())
}

View File

@ -0,0 +1,120 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package versioned
import (
fmt "fmt"
http "net/http"
autoscalingv1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned/typed/autoscaling.x-k8s.io/v1"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
AutoscalingV1() autoscalingv1.AutoscalingV1Interface
}
// Clientset contains the clients for groups.
type Clientset struct {
*discovery.DiscoveryClient
autoscalingV1 *autoscalingv1.AutoscalingV1Client
}
// AutoscalingV1 retrieves the AutoscalingV1Client
func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface {
return c.autoscalingV1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
return nil
}
return c.DiscoveryClient
}
// NewForConfig creates a new Clientset for the given config.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfig will generate a rate-limiter in configShallowCopy.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.UserAgent == "" {
configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
}
// share the transport between all clients
httpClient, err := rest.HTTPClientFor(&configShallowCopy)
if err != nil {
return nil, err
}
return NewForConfigAndClient(&configShallowCopy, httpClient)
}
// NewForConfigAndClient creates a new Clientset for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
if configShallowCopy.Burst <= 0 {
return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
}
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.autoscalingV1, err = autoscalingv1.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
return &cs, nil
}
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
cs, err := NewForConfig(c)
if err != nil {
panic(err)
}
return cs
}
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.autoscalingV1 = autoscalingv1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}

View File

@ -0,0 +1,131 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
applyconfiguration "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/applyconfiguration"
clientset "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned"
autoscalingv1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned/typed/autoscaling.x-k8s.io/v1"
fakeautoscalingv1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned/typed/autoscaling.x-k8s.io/v1/fake"
"k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
//
// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves
// server side apply testing. NewClientset is only available when apply configurations are generated (e.g.
// via --with-applyconfig).
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
var opts metav1.ListOptions
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
opts = watchActcion.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns, opts)
if err != nil {
return false, nil, err
}
return true, watch, nil
})
return cs
}
// Clientset implements clientset.Interface. Meant to be embedded into a
// struct to get a default implementation. This makes faking out just the method
// you want to test easier.
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
// NewClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewClientset(objects ...runtime.Object) *Clientset {
o := testing.NewFieldManagedObjectTracker(
scheme,
codecs.UniversalDecoder(),
applyconfiguration.NewTypeConverter(scheme),
)
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
var opts metav1.ListOptions
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
opts = watchActcion.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns, opts)
if err != nil {
return false, nil, err
}
return true, watch, nil
})
return cs
}
var (
_ clientset.Interface = &Clientset{}
_ testing.FakeClient = &Clientset{}
)
// AutoscalingV1 retrieves the AutoscalingV1Client
func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface {
return &fakeautoscalingv1.FakeAutoscalingV1{Fake: &c.Fake}
}

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated fake clientset.
package fake

View File

@ -0,0 +1,56 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
autoscalingv1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
autoscalingv1.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"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(scheme))
}

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package contains the scheme of the automatically generated clientset.
package scheme

View File

@ -0,0 +1,56 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package scheme
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
autoscalingv1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
)
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
autoscalingv1.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"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(Scheme))
}

View File

@ -0,0 +1,101 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
http "net/http"
autoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
scheme "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned/scheme"
rest "k8s.io/client-go/rest"
)
type AutoscalingV1Interface interface {
RESTClient() rest.Interface
CapacityBuffersGetter
}
// AutoscalingV1Client is used to interact with features provided by the autoscaling.x-k8s.io group.
type AutoscalingV1Client struct {
restClient rest.Interface
}
func (c *AutoscalingV1Client) CapacityBuffers(namespace string) CapacityBufferInterface {
return newCapacityBuffers(c, namespace)
}
// NewForConfig creates a new AutoscalingV1Client for the given config.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*AutoscalingV1Client, error) {
config := *c
setConfigDefaults(&config)
httpClient, err := rest.HTTPClientFor(&config)
if err != nil {
return nil, err
}
return NewForConfigAndClient(&config, httpClient)
}
// NewForConfigAndClient creates a new AutoscalingV1Client 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) (*AutoscalingV1Client, error) {
config := *c
setConfigDefaults(&config)
client, err := rest.RESTClientForConfigAndClient(&config, h)
if err != nil {
return nil, err
}
return &AutoscalingV1Client{client}, nil
}
// NewForConfigOrDie creates a new AutoscalingV1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *AutoscalingV1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new AutoscalingV1Client for the given RESTClient.
func New(c rest.Interface) *AutoscalingV1Client {
return &AutoscalingV1Client{c}
}
func setConfigDefaults(config *rest.Config) {
gv := autoscalingxk8siov1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *AutoscalingV1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@ -0,0 +1,74 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
context "context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
autoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
applyconfigurationautoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/applyconfiguration/autoscaling.x-k8s.io/v1"
scheme "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned/scheme"
gentype "k8s.io/client-go/gentype"
)
// CapacityBuffersGetter has a method to return a CapacityBufferInterface.
// A group's client should implement this interface.
type CapacityBuffersGetter interface {
CapacityBuffers(namespace string) CapacityBufferInterface
}
// CapacityBufferInterface has methods to work with CapacityBuffer resources.
type CapacityBufferInterface interface {
Create(ctx context.Context, capacityBuffer *autoscalingxk8siov1.CapacityBuffer, opts metav1.CreateOptions) (*autoscalingxk8siov1.CapacityBuffer, error)
Update(ctx context.Context, capacityBuffer *autoscalingxk8siov1.CapacityBuffer, opts metav1.UpdateOptions) (*autoscalingxk8siov1.CapacityBuffer, error)
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
UpdateStatus(ctx context.Context, capacityBuffer *autoscalingxk8siov1.CapacityBuffer, opts metav1.UpdateOptions) (*autoscalingxk8siov1.CapacityBuffer, error)
Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
Get(ctx context.Context, name string, opts metav1.GetOptions) (*autoscalingxk8siov1.CapacityBuffer, error)
List(ctx context.Context, opts metav1.ListOptions) (*autoscalingxk8siov1.CapacityBufferList, error)
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *autoscalingxk8siov1.CapacityBuffer, err error)
Apply(ctx context.Context, capacityBuffer *applyconfigurationautoscalingxk8siov1.CapacityBufferApplyConfiguration, opts metav1.ApplyOptions) (result *autoscalingxk8siov1.CapacityBuffer, err error)
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
ApplyStatus(ctx context.Context, capacityBuffer *applyconfigurationautoscalingxk8siov1.CapacityBufferApplyConfiguration, opts metav1.ApplyOptions) (result *autoscalingxk8siov1.CapacityBuffer, err error)
CapacityBufferExpansion
}
// capacityBuffers implements CapacityBufferInterface
type capacityBuffers struct {
*gentype.ClientWithListAndApply[*autoscalingxk8siov1.CapacityBuffer, *autoscalingxk8siov1.CapacityBufferList, *applyconfigurationautoscalingxk8siov1.CapacityBufferApplyConfiguration]
}
// newCapacityBuffers returns a CapacityBuffers
func newCapacityBuffers(c *AutoscalingV1Client, namespace string) *capacityBuffers {
return &capacityBuffers{
gentype.NewClientWithListAndApply[*autoscalingxk8siov1.CapacityBuffer, *autoscalingxk8siov1.CapacityBufferList, *applyconfigurationautoscalingxk8siov1.CapacityBufferApplyConfiguration](
"capacitybuffers",
c.RESTClient(),
scheme.ParameterCodec,
namespace,
func() *autoscalingxk8siov1.CapacityBuffer { return &autoscalingxk8siov1.CapacityBuffer{} },
func() *autoscalingxk8siov1.CapacityBufferList { return &autoscalingxk8siov1.CapacityBufferList{} },
),
}
}

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake

View File

@ -0,0 +1,40 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned/typed/autoscaling.x-k8s.io/v1"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeAutoscalingV1 struct {
*testing.Fake
}
func (c *FakeAutoscalingV1) CapacityBuffers(namespace string) v1.CapacityBufferInterface {
return newFakeCapacityBuffers(c, namespace)
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeAutoscalingV1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@ -0,0 +1,51 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
autoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/applyconfiguration/autoscaling.x-k8s.io/v1"
typedautoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned/typed/autoscaling.x-k8s.io/v1"
gentype "k8s.io/client-go/gentype"
)
// fakeCapacityBuffers implements CapacityBufferInterface
type fakeCapacityBuffers struct {
*gentype.FakeClientWithListAndApply[*v1.CapacityBuffer, *v1.CapacityBufferList, *autoscalingxk8siov1.CapacityBufferApplyConfiguration]
Fake *FakeAutoscalingV1
}
func newFakeCapacityBuffers(fake *FakeAutoscalingV1, namespace string) typedautoscalingxk8siov1.CapacityBufferInterface {
return &fakeCapacityBuffers{
gentype.NewFakeClientWithListAndApply[*v1.CapacityBuffer, *v1.CapacityBufferList, *autoscalingxk8siov1.CapacityBufferApplyConfiguration](
fake.Fake,
namespace,
v1.SchemeGroupVersion.WithResource("capacitybuffers"),
v1.SchemeGroupVersion.WithKind("CapacityBuffer"),
func() *v1.CapacityBuffer { return &v1.CapacityBuffer{} },
func() *v1.CapacityBufferList { return &v1.CapacityBufferList{} },
func(dst, src *v1.CapacityBufferList) { dst.ListMeta = src.ListMeta },
func(list *v1.CapacityBufferList) []*v1.CapacityBuffer { return gentype.ToPointerSlice(list.Items) },
func(list *v1.CapacityBufferList, items []*v1.CapacityBuffer) {
list.Items = gentype.FromPointerSlice(items)
},
),
fake,
}
}

View File

@ -0,0 +1,21 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
type CapacityBufferExpansion interface{}

View File

@ -0,0 +1,46 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package autoscaling
import (
v1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/informers/externalversions/autoscaling.x-k8s.io/v1"
internalinterfaces "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/informers/externalversions/internalinterfaces"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1 provides access to shared informers for resources in V1.
V1() v1.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}
}
// V1 returns a new v1.Interface.
func (g *group) V1() v1.Interface {
return v1.New(g.factory, g.namespace, g.tweakListOptions)
}

View File

@ -0,0 +1,102 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
context "context"
time "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
capacitybufferautoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
versioned "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned"
internalinterfaces "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/informers/externalversions/internalinterfaces"
autoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/listers/autoscaling.x-k8s.io/v1"
cache "k8s.io/client-go/tools/cache"
)
// CapacityBufferInformer provides access to a shared informer and lister for
// CapacityBuffers.
type CapacityBufferInformer interface {
Informer() cache.SharedIndexInformer
Lister() autoscalingxk8siov1.CapacityBufferLister
}
type capacityBufferInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewCapacityBufferInformer constructs a new informer for CapacityBuffer 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 NewCapacityBufferInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredCapacityBufferInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredCapacityBufferInformer constructs a new informer for CapacityBuffer 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 NewFilteredCapacityBufferInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV1().CapacityBuffers(namespace).List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV1().CapacityBuffers(namespace).Watch(context.Background(), options)
},
ListWithContextFunc: func(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV1().CapacityBuffers(namespace).List(ctx, options)
},
WatchFuncWithContext: func(ctx context.Context, options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV1().CapacityBuffers(namespace).Watch(ctx, options)
},
},
&capacitybufferautoscalingxk8siov1.CapacityBuffer{},
resyncPeriod,
indexers,
)
}
func (f *capacityBufferInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredCapacityBufferInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *capacityBufferInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&capacitybufferautoscalingxk8siov1.CapacityBuffer{}, f.defaultInformer)
}
func (f *capacityBufferInformer) Lister() autoscalingxk8siov1.CapacityBufferLister {
return autoscalingxk8siov1.NewCapacityBufferLister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,45 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
internalinterfaces "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// CapacityBuffers returns a CapacityBufferInformer.
CapacityBuffers() CapacityBufferInformer
}
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}
}
// CapacityBuffers returns a CapacityBufferInformer.
func (v *version) CapacityBuffers() CapacityBufferInformer {
return &capacityBufferInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@ -0,0 +1,262 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
reflect "reflect"
sync "sync"
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
versioned "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned"
autoscalingxk8sio "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/informers/externalversions/autoscaling.x-k8s.io"
internalinterfaces "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/informers/externalversions/internalinterfaces"
cache "k8s.io/client-go/tools/cache"
)
// SharedInformerOption defines the functional option type for SharedInformerFactory.
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
type sharedInformerFactory struct {
client versioned.Interface
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration
transform cache.TransformFunc
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
// wg tracks how many goroutines were started.
wg sync.WaitGroup
// shuttingDown is true when Shutdown has been called. It may still be running
// because it needs to wait for goroutines.
shuttingDown bool
}
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
for k, v := range resyncConfig {
factory.customResync[reflect.TypeOf(k)] = v
}
return factory
}
}
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.tweakListOptions = tweakListOptions
return factory
}
}
// WithNamespace limits the SharedInformerFactory to the specified namespace.
func WithNamespace(namespace string) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.namespace = namespace
return factory
}
}
// WithTransform sets a transform on all informers.
func WithTransform(transform cache.TransformFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.transform = transform
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
}
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
// Listers obtained via this SharedInformerFactory will be subject to the same filters
// as specified here.
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
factory := &sharedInformerFactory{
client: client,
namespace: v1.NamespaceAll,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
customResync: make(map[reflect.Type]time.Duration),
}
// Apply all options
for _, opt := range options {
factory = opt(factory)
}
return factory
}
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
if f.shuttingDown {
return
}
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
f.wg.Add(1)
// We need a new variable in each loop iteration,
// otherwise the goroutine would use the loop variable
// and that keeps changing.
informer := informer
go func() {
defer f.wg.Done()
informer.Run(stopCh)
}()
f.startedInformers[informerType] = true
}
}
}
func (f *sharedInformerFactory) Shutdown() {
f.lock.Lock()
f.shuttingDown = true
f.lock.Unlock()
// Will return immediately if there is nothing to wait for.
f.wg.Wait()
}
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
informers := func() map[reflect.Type]cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informers := map[reflect.Type]cache.SharedIndexInformer{}
for informerType, informer := range f.informers {
if f.startedInformers[informerType] {
informers[informerType] = informer
}
}
return informers
}()
res := map[reflect.Type]bool{}
for informType, informer := range informers {
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
}
return res
}
// InformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(obj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
resyncPeriod, exists := f.customResync[informerType]
if !exists {
resyncPeriod = f.defaultResync
}
informer = newFunc(f.client, resyncPeriod)
informer.SetTransform(f.transform)
f.informers[informerType] = informer
return informer
}
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
//
// It is typically used like this:
//
// ctx, cancel := context.Background()
// defer cancel()
// factory := NewSharedInformerFactory(client, resyncPeriod)
// defer factory.WaitForStop() // Returns immediately if nothing was started.
// genericInformer := factory.ForResource(resource)
// typedInformer := factory.SomeAPIGroup().V1().SomeType()
// factory.Start(ctx.Done()) // Start processing these informers.
// synced := factory.WaitForCacheSync(ctx.Done())
// for v, ok := range synced {
// if !ok {
// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v)
// return
// }
// }
//
// // Creating informers can also be created after Start, but then
// // Start must be called again:
// anotherGenericInformer := factory.ForResource(resource)
// factory.Start(ctx.Done())
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
// Start initializes all requested informers. They are handled in goroutines
// which run until the stop channel gets closed.
// Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync.
Start(stopCh <-chan struct{})
// Shutdown marks a factory as shutting down. At that point no new
// informers can be started anymore and Start will return without
// doing anything.
//
// In addition, Shutdown blocks until all goroutines have terminated. For that
// to happen, the close channel(s) that they were started with must be closed,
// either before Shutdown gets called or while it is waiting.
//
// Shutdown may be called multiple times, even concurrently. All such calls will
// block until all goroutines have terminated.
Shutdown()
// WaitForCacheSync blocks until all started informers' caches were synced
// or the stop channel gets closed.
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
// ForResource gives generic access to a shared informer of the matching type.
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
// InformerFor returns the SharedIndexInformer for obj using an internal
// client.
InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer
Autoscaling() autoscalingxk8sio.Interface
}
func (f *sharedInformerFactory) Autoscaling() autoscalingxk8sio.Interface {
return autoscalingxk8sio.New(f, f.namespace, f.tweakListOptions)
}

View File

@ -0,0 +1,62 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
fmt "fmt"
schema "k8s.io/apimachinery/pkg/runtime/schema"
v1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
cache "k8s.io/client-go/tools/cache"
)
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
Informer() cache.SharedIndexInformer
Lister() cache.GenericLister
}
type genericInformer struct {
informer cache.SharedIndexInformer
resource schema.GroupResource
}
// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
return f.informer
}
// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}
// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=autoscaling.x-k8s.io, Version=v1
case v1.SchemeGroupVersion.WithResource("capacitybuffers"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1().CapacityBuffers().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
}

View File

@ -0,0 +1,40 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package internalinterfaces
import (
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
versioned "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/client/clientset/versioned"
cache "k8s.io/client-go/tools/cache"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View File

@ -0,0 +1,70 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1
import (
labels "k8s.io/apimachinery/pkg/labels"
autoscalingxk8siov1 "k8s.io/autoscaler/cluster-autoscaler/apis/capacitybuffer/autoscaling.x-k8s.io/v1"
listers "k8s.io/client-go/listers"
cache "k8s.io/client-go/tools/cache"
)
// CapacityBufferLister helps list CapacityBuffers.
// All objects returned here must be treated as read-only.
type CapacityBufferLister interface {
// List lists all CapacityBuffers in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*autoscalingxk8siov1.CapacityBuffer, err error)
// CapacityBuffers returns an object that can list and get CapacityBuffers.
CapacityBuffers(namespace string) CapacityBufferNamespaceLister
CapacityBufferListerExpansion
}
// capacityBufferLister implements the CapacityBufferLister interface.
type capacityBufferLister struct {
listers.ResourceIndexer[*autoscalingxk8siov1.CapacityBuffer]
}
// NewCapacityBufferLister returns a new CapacityBufferLister.
func NewCapacityBufferLister(indexer cache.Indexer) CapacityBufferLister {
return &capacityBufferLister{listers.New[*autoscalingxk8siov1.CapacityBuffer](indexer, autoscalingxk8siov1.Resource("capacitybuffer"))}
}
// CapacityBuffers returns an object that can list and get CapacityBuffers.
func (s *capacityBufferLister) CapacityBuffers(namespace string) CapacityBufferNamespaceLister {
return capacityBufferNamespaceLister{listers.NewNamespaced[*autoscalingxk8siov1.CapacityBuffer](s.ResourceIndexer, namespace)}
}
// CapacityBufferNamespaceLister helps list and get CapacityBuffers.
// All objects returned here must be treated as read-only.
type CapacityBufferNamespaceLister interface {
// List lists all CapacityBuffers in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*autoscalingxk8siov1.CapacityBuffer, err error)
// Get retrieves the CapacityBuffer from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*autoscalingxk8siov1.CapacityBuffer, error)
CapacityBufferNamespaceListerExpansion
}
// capacityBufferNamespaceLister implements the CapacityBufferNamespaceLister
// interface.
type capacityBufferNamespaceLister struct {
listers.ResourceIndexer[*autoscalingxk8siov1.CapacityBuffer]
}

View File

@ -0,0 +1,27 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1
// CapacityBufferListerExpansion allows custom methods to be added to
// CapacityBufferLister.
type CapacityBufferListerExpansion interface{}
// CapacityBufferNamespaceListerExpansion allows custom methods to be added to
// CapacityBufferNamespaceLister.
type CapacityBufferNamespaceListerExpansion interface{}

View File

@ -0,0 +1,258 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: capacitybuffers.autoscaling.x-k8s.io
spec:
group: autoscaling.x-k8s.io
names:
kind: CapacityBuffer
listKind: CapacityBufferList
plural: capacitybuffers
shortNames:
- cb
singular: capacitybuffer
scope: Cluster
versions:
- additionalPrinterColumns:
- description: The strategy used for provisioning buffer capacity.
jsonPath: .spec.provisioningStrategy
name: Strategy
type: string
- description: The desired number of buffer chunks, if specified.
jsonPath: .spec.replicas
name: Replicas
type: integer
- description: The readiness status of the CapacityBuffer.
jsonPath: .status.conditions[?(@.type=='Ready')].reason
name: Status
type: string
- description: The age of the CapacityBuffer.
jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1
schema:
openAPIV3Schema:
description: |-
CapacityBuffer is the configuration that an autoscaler can use to provision buffer capacity within a cluster.
This buffer is represented by placeholder pods that trigger the Cluster Autoscaler to scale up nodes in advance,
ensuring that there is always spare capacity available to handle sudden workload spikes or to speed up scaling events.
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: Spec defines the desired characteristics of the buffer.
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits, if specified, will limit the number of chunks created for this buffer
based on total resource requests (e.g., CPU, memory). If there are no other
limitations for the number of chunks (i.e., `replicas` or `percentage` are not set),
this will be used to create as many chunks as fit into these limits.
type: object
percentage:
description: |-
Percentage defines the desired buffer capacity as a percentage of the
`scalableRef`'s current replicas. This is only applicable if `scalableRef` is set.
The absolute number of replicas is calculated from the percentage by rounding up to a minimum of 1.
For example, if `scalableRef` has 10 replicas and `percentage` is 20, 2 buffer chunks will be created.
This field is mutually exclusive with `replicas`.
format: int32
maximum: 100
minimum: 0
type: integer
podTemplateRef:
description: |-
PodTemplateRef is a reference to a PodTemplate resource in the same namespace
that declares the shape of a single chunk of the buffer. The pods created
from this template will be used as placeholder pods for the buffer capacity.
Exactly one of `podTemplateRef`, `scalableRef` should be specified.
properties:
name:
description: Name of the object.
minLength: 1
type: string
required:
- name
type: object
provisioningStrategy:
default: active-capacity
description: |-
ProvisioningStrategy defines how the buffer is utilized.
"active-capacity" is the default strategy, where the buffer actively scales up the cluster by creating placeholder pods.
enum:
- active-capacity
type: string
replicas:
description: |-
Replicas defines the desired number of buffer chunks to provision.
If neither `replicas` nor `percentage` is set, as many chunks as fit within
defined resource limits (if any) will be created. If both are set, the maximum
of the two will be used.
This field is mutually exclusive with `percentage` when `scalableRef` is set.
format: int32
minimum: 0
type: integer
scalableRef:
description: |-
ScalableRef is a reference to an object of a kind that has a scale subresource
and specifies its label selector field. This allows the CapacityBuffer to
manage the buffer by scaling an existing scalable resource.
Exactly one of `podTemplateRef`, `scalableRef` should be specified.
properties:
apiGroup:
description: |-
APIGroup of the scalable object.
Empty string for the core API group
type: string
kind:
description: Kind of the scalable object (e.g., "Deployment",
"StatefulSet").
minLength: 1
type: string
name:
description: Name of the scalable object.
minLength: 1
type: string
required:
- kind
- name
type: object
type: object
status:
description: Status represents the current state of the buffer and its
readiness for autoprovisioning.
properties:
conditions:
description: |-
Conditions provide a standard mechanism for reporting the buffer's state.
The "Ready" condition indicates if the buffer is successfully provisioned
and active. Other conditions may report on various aspects of the buffer's
health and provisioning process.
items:
description: "Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: |-
type of condition in CamelCase or in foo.example.com/CamelCase.
---
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
useful (see .node.status.conditions), the ability to deconflict is important.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
podTemplateGeneration:
description: |-
PodTemplateGeneration is the observed generation of the PodTemplate, used
to determine if the status is up-to-date with the desired `spec.podTemplateRef`.
format: int64
type: integer
podTemplateRef:
description: |-
PodTemplateRef is the observed reference to the PodTemplate that was used
to provision the buffer. If this field is not set, and the `conditions`
indicate an error, it provides details about the error state.
properties:
name:
description: Name of the object.
minLength: 1
type: string
required:
- name
type: object
replicas:
description: Replicas is the actual number of buffer chunks currently
provisioned.
format: int32
type: integer
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}