diff --git a/api/v1beta1/kkmachinetemplate_types.go b/api/v1beta1/kkmachinetemplate_types.go index ef6f10877..150dd8ae1 100644 --- a/api/v1beta1/kkmachinetemplate_types.go +++ b/api/v1beta1/kkmachinetemplate_types.go @@ -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"` @@ -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 diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index c7a21d9a7..f6dfd6332 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -621,6 +621,7 @@ func (in *KKMachineTemplate) DeepCopyInto(out *KKMachineTemplate) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KKMachineTemplate. @@ -706,6 +707,28 @@ func (in *KKMachineTemplateSpec) DeepCopy() *KKMachineTemplateSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KKMachineTemplateStatus) DeepCopyInto(out *KKMachineTemplateStatus) { + *out = *in + if in.Capacity != nil { + in, out := &in.Capacity, &out.Capacity + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KKMachineTemplateStatus. +func (in *KKMachineTemplateStatus) DeepCopy() *KKMachineTemplateStatus { + if in == nil { + return nil + } + out := new(KKMachineTemplateStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Nodes) DeepCopyInto(out *Nodes) { *out = *in diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_kkmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_kkmachinetemplates.yaml index 4c299d7e8..398a90529 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_kkmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_kkmachinetemplates.yaml @@ -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 @@ -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: {}