Skip to content

Commit 56615b5

Browse files
add AWSMachineTemplate NodeInfo
1 parent 9a92a43 commit 56615b5

File tree

10 files changed

+358
-20
lines changed

10 files changed

+358
-20
lines changed

api/v1beta1/awsmachine_conversion.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
136136
}
137137
}
138138

139+
// Restore Status fields that don't exist in v1beta1.
140+
dst.Status.NodeInfo = restored.Status.NodeInfo
141+
139142
return nil
140143
}
141144

api/v1beta1/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,8 @@ func Convert_v1beta2_AWSMachineStatus_To_v1beta1_AWSMachineStatus(in *v1beta2.AW
108108
// Note: DedicatedHostID is not present in v1beta1, so it will be dropped during conversion
109109
return autoConvert_v1beta2_AWSMachineStatus_To_v1beta1_AWSMachineStatus(in, out, s)
110110
}
111+
112+
func Convert_v1beta2_AWSMachineTemplateStatus_To_v1beta1_AWSMachineTemplateStatus(in *v1beta2.AWSMachineTemplateStatus, out *AWSMachineTemplateStatus, s conversion.Scope) error {
113+
// NodeInfo field is ignored (dropped) as it doesn't exist in v1beta1
114+
return autoConvert_v1beta2_AWSMachineTemplateStatus_To_v1beta1_AWSMachineTemplateStatus(in, out, s)
115+
}

api/v1beta1/zz_generated.conversion.go

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/awsmachinetemplate_types.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,51 @@ import (
2323
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2424
)
2525

26+
// Architecture represents the CPU architecture of the node.
27+
// Its underlying type is a string and its value can be any of amd64, arm64.
28+
// +kubebuilder:validation:Enum=amd64;arm64
29+
// +enum
30+
type Architecture string
31+
32+
// Architecture constants.
33+
const (
34+
ArchitectureAmd64 Architecture = "amd64"
35+
ArchitectureArm64 Architecture = "arm64"
36+
)
37+
38+
// Operating system constants.
39+
const (
40+
// OperatingSystemLinux represents the Linux operating system.
41+
OperatingSystemLinux = "linux"
42+
// OperatingSystemWindows represents the Windows operating system.
43+
OperatingSystemWindows = "windows"
44+
)
45+
46+
// NodeInfo contains information about the node's architecture and operating system.
47+
type NodeInfo struct {
48+
// Architecture is the CPU architecture of the node.
49+
// Its underlying type is a string and its value can be any of amd64, arm64.
50+
// +optional
51+
Architecture Architecture `json:"architecture,omitempty"`
52+
// OperatingSystem is a string representing the operating system of the node.
53+
// This may be a string like 'linux' or 'windows'.
54+
// +optional
55+
OperatingSystem string `json:"operatingSystem,omitempty"`
56+
}
57+
2658
// AWSMachineTemplateStatus defines a status for an AWSMachineTemplate.
2759
type AWSMachineTemplateStatus struct {
2860
// Capacity defines the resource capacity for this machine.
2961
// This value is used for autoscaling from zero operations as defined in:
3062
// https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
3163
// +optional
3264
Capacity corev1.ResourceList `json:"capacity,omitempty"`
65+
66+
// NodeInfo contains information about the node's architecture and operating system.
67+
// This value is used for autoscaling from zero operations as defined in:
68+
// https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
69+
// +optional
70+
NodeInfo *NodeInfo `json:"nodeInfo,omitempty"`
3371
}
3472

3573
// AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate.

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 20 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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,26 @@ spec:
11561156
This value is used for autoscaling from zero operations as defined in:
11571157
https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
11581158
type: object
1159+
nodeInfo:
1160+
description: |-
1161+
NodeInfo contains information about the node's architecture and operating system.
1162+
This value is used for autoscaling from zero operations as defined in:
1163+
https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
1164+
properties:
1165+
architecture:
1166+
description: |-
1167+
Architecture is the CPU architecture of the node.
1168+
Its underlying type is a string and its value can be any of amd64, arm64.
1169+
enum:
1170+
- amd64
1171+
- arm64
1172+
type: string
1173+
operatingSystem:
1174+
description: |-
1175+
OperatingSystem is a string representing the operating system of the node.
1176+
This may be a string like 'linux' or 'windows'.
1177+
type: string
1178+
type: object
11591179
type: object
11601180
type: object
11611181
served: true

config/rbac/role.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ rules:
101101
- controlplane.cluster.x-k8s.io
102102
resources:
103103
- '*'
104+
- kubeadmcontrolplanes
104105
verbs:
105106
- get
106107
- list

0 commit comments

Comments
 (0)