Skip to content

Commit 818abca

Browse files
authored
Merge pull request #3684 from Skarlso/scale_from_0
Add scaling from 0 support
2 parents 19b6440 + 8e04c07 commit 818abca

File tree

8 files changed

+273
-21
lines changed

8 files changed

+273
-21
lines changed

api/v1alpha3/awsmachine_conversion.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
106106

107107
restoreSpec(&restored.Spec.Template.Spec, &dst.Spec.Template.Spec)
108108

109+
dst.Status = restored.Status
110+
109111
return nil
110112
}
111113

@@ -123,6 +125,10 @@ func (r *AWSMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error {
123125
return nil
124126
}
125127

128+
func Convert_v1beta1_AWSMachineTemplate_To_v1alpha3_AWSMachineTemplate(in *infrav1.AWSMachineTemplate, out *AWSMachineTemplate, s apiconversion.Scope) error {
129+
return autoConvert_v1beta1_AWSMachineTemplate_To_v1alpha3_AWSMachineTemplate(in, out, s)
130+
}
131+
126132
// ConvertTo converts the v1alpha3 AWSMachineTemplateList receiver to a v1beta1 AWSMachineTemplateList.
127133
func (r *AWSMachineTemplateList) ConvertTo(dstRaw conversion.Hub) error {
128134
dst := dstRaw.(*infrav1.AWSMachineTemplateList)

api/v1alpha3/zz_generated.conversion.go

Lines changed: 6 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/awsmachine_conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
8383

8484
dst.Spec.Template.ObjectMeta = restored.Spec.Template.ObjectMeta
8585
dst.Spec.Template.Spec.Ignition = restored.Spec.Template.Spec.Ignition
86+
dst.Status = restored.Status
8687

8788
return nil
8889
}
@@ -103,6 +104,10 @@ func (r *AWSMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error {
103104
return nil
104105
}
105106

107+
func Convert_v1beta1_AWSMachineTemplate_To_v1alpha4_AWSMachineTemplate(in *v1beta1.AWSMachineTemplate, out *AWSMachineTemplate, s apiconversion.Scope) error {
108+
return autoConvert_v1beta1_AWSMachineTemplate_To_v1alpha4_AWSMachineTemplate(in, out, s)
109+
}
110+
106111
// ConvertTo converts the v1alpha4 AWSMachineTemplateList receiver to a v1beta1 AWSMachineTemplateList.
107112
func (src *AWSMachineTemplateList) ConvertTo(dstRaw conversion.Hub) error {
108113
dst := dstRaw.(*infrav1.AWSMachineTemplateList)

api/v1alpha4/zz_generated.conversion.go

Lines changed: 6 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/awsmachinetemplate_types.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
corev1 "k8s.io/api/core/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122

2223
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2324
)
2425

26+
// AWSMachineTemplateStatus defines a status for an AWSMachineTemplate.
27+
type AWSMachineTemplateStatus struct {
28+
// Capacity defines the resource capacity for this machine.
29+
// This value is used for autoscaling from zero operations as defined in:
30+
// https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
31+
// +optional
32+
Capacity corev1.ResourceList `json:"capacity,omitempty"`
33+
}
34+
2535
// AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate.
2636
type AWSMachineTemplateSpec struct {
2737
Template AWSMachineTemplateResource `json:"template"`
@@ -37,7 +47,8 @@ type AWSMachineTemplate struct {
3747
metav1.TypeMeta `json:",inline"`
3848
metav1.ObjectMeta `json:"metadata,omitempty"`
3949

40-
Spec AWSMachineTemplateSpec `json:"spec,omitempty"`
50+
Spec AWSMachineTemplateSpec `json:"spec,omitempty"`
51+
Status AWSMachineTemplateStatus `json:"status,omitempty"`
4152
}
4253

4354
// +kubebuilder:object:root=true

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,21 @@ spec:
11151115
required:
11161116
- template
11171117
type: object
1118+
status:
1119+
description: AWSMachineTemplateStatus defines a status for an AWSMachineTemplate.
1120+
properties:
1121+
capacity:
1122+
additionalProperties:
1123+
anyOf:
1124+
- type: integer
1125+
- type: string
1126+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
1127+
x-kubernetes-int-or-string: true
1128+
description: 'Capacity defines the resource capacity for this machine.
1129+
This value is used for autoscaling from zero operations as defined
1130+
in: https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md'
1131+
type: object
1132+
type: object
11181133
type: object
11191134
served: true
11201135
storage: true

0 commit comments

Comments
 (0)