Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(capkk): add status to support autoscaling from zero operations #1675

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions api/v1beta1/kkmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ limitations under the License.
package v1beta1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// KKMachineTemplateStatus defines a status for an KKMachineTemplate.
type KKMachineTemplateStatus struct {
// Capacity defines the resource capacity for this machine.
// This value is used for autoscaling from zero operations as defined in:
// https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
// +optional
Capacity corev1.ResourceList `json:"capacity,omitempty"`
}

// KKMachineTemplateSpec defines the desired state of KKMachineTemplate
type KKMachineTemplateSpec struct {
Template KKMachineTemplateResource `json:"template"`
Expand All @@ -37,15 +47,19 @@ type KKMachineTemplateResource struct {
Spec KKMachineSpec `json:"spec"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=kkmachinetemplates,scope=Namespaced,categories=cluster-api,shortName=kkmt
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of KKMachineTemplate"
// +k8s:defaulter-gen=true

// KKMachineTemplate is the Schema for the kkmachinetemplates API
type KKMachineTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KKMachineTemplateSpec `json:"spec,omitempty"`
Spec KKMachineTemplateSpec `json:"spec,omitempty"`
Status KKMachineTemplateStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
23 changes: 23 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ metadata:
spec:
group: infrastructure.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: KKMachineTemplate
listKind: KKMachineTemplateList
plural: kkmachinetemplates
shortNames:
- kkmt
singular: kkmachinetemplate
scope: Namespaced
versions:
- name: v1beta1
- additionalPrinterColumns:
- description: Time duration since creation of KKMachineTemplate
jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1beta1
schema:
openAPIV3Schema:
description: KKMachineTemplate is the Schema for the kkmachinetemplates API
Expand Down Expand Up @@ -129,8 +138,22 @@ spec:
required:
- template
type: object
status:
description: KKMachineTemplateStatus defines a status for an KKMachineTemplate.
properties:
capacity:
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: 'Capacity defines the resource capacity for this machine.
This value is used for autoscaling from zero operations as defined
in: https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md'
type: object
type: object
type: object
served: true
storage: true
subresources:
status: {}
subresources: {}