Skip to content
Open
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
4 changes: 4 additions & 0 deletions api/v1beta1/awsmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
}
}

// Restore Status fields that don't exist in v1beta1.
dst.Status.NodeInfo = restored.Status.NodeInfo
dst.Status.Conditions = restored.Status.Conditions

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ func Convert_v1beta2_AWSMachineStatus_To_v1beta1_AWSMachineStatus(in *v1beta2.AW
// Note: DedicatedHostID is not present in v1beta1, so it will be dropped during conversion
return autoConvert_v1beta2_AWSMachineStatus_To_v1beta1_AWSMachineStatus(in, out, s)
}

func Convert_v1beta2_AWSMachineTemplateStatus_To_v1beta1_AWSMachineTemplateStatus(in *v1beta2.AWSMachineTemplateStatus, out *AWSMachineTemplateStatus, s conversion.Scope) error {
// NodeInfo and Conditions fields are ignored (dropped) as they don't exist in v1beta1
return autoConvert_v1beta2_AWSMachineTemplateStatus_To_v1beta1_AWSMachineTemplateStatus(in, out, s)
}
7 changes: 2 additions & 5 deletions api/v1beta1/zz_generated.conversion.go

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

57 changes: 57 additions & 0 deletions api/v1beta2/awsmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,59 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// Architecture represents the CPU architecture of the node.
// Its underlying type is a string and its value can be any of amd64, arm64.
type Architecture string

// Architecture constants.
const (
ArchitectureAmd64 Architecture = "amd64"
ArchitectureArm64 Architecture = "arm64"
)

// OperatingSystem represents the operating system of the node.
// Its underlying type is a string and its value can be any of linux, windows.
type OperatingSystem string

// Operating system constants.
const (
// OperatingSystemLinux represents the Linux operating system.
OperatingSystemLinux OperatingSystem = "linux"
// OperatingSystemWindows represents the Windows operating system.
OperatingSystemWindows OperatingSystem = "windows"
)

// NodeInfo contains information about the node's architecture and operating system.
type NodeInfo struct {
// Architecture is the CPU architecture of the node.
// Its underlying type is a string and its value can be any of amd64, arm64.
// +kubebuilder:validation:Enum=amd64;arm64
// +optional
Architecture Architecture `json:"architecture,omitempty"`
// OperatingSystem is the operating system of the node.
// Its underlying type is a string and its value can be any of linux, windows.
// +kubebuilder:validation:Enum=linux;windows
// +optional
OperatingSystem OperatingSystem `json:"operatingSystem,omitempty"`
}

// AWSMachineTemplateStatus defines a status for an AWSMachineTemplate.
type AWSMachineTemplateStatus 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"`

// NodeInfo contains information about the node's architecture and operating system.
// 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
NodeInfo *NodeInfo `json:"nodeInfo,omitempty"`

// Conditions defines current service state of the AWSMachineTemplate.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate.
Expand All @@ -40,6 +86,7 @@ type AWSMachineTemplateSpec struct {
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=awsmachinetemplates,scope=Namespaced,categories=cluster-api,shortName=awsmt
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +k8s:defaulter-gen=true

// AWSMachineTemplate is the schema for the Amazon EC2 Machine Templates API.
Expand Down Expand Up @@ -71,6 +118,16 @@ type AWSMachineTemplateResource struct {
Spec AWSMachineSpec `json:"spec"`
}

// GetConditions returns the observations of the operational state of the AWSMachineTemplate resource.
func (r *AWSMachineTemplate) GetConditions() clusterv1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the AWSMachineTemplate to the predescribed clusterv1.Conditions.
func (r *AWSMachineTemplate) SetConditions(conditions clusterv1.Conditions) {
r.Status.Conditions = conditions
}

func init() {
SchemeBuilder.Register(&AWSMachineTemplate{}, &AWSMachineTemplateList{})
}
27 changes: 27 additions & 0 deletions api/v1beta2/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 @@ -1156,7 +1156,84 @@ spec:
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
conditions:
description: Conditions defines current service state of the AWSMachineTemplate.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
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 field may be empty.
maxLength: 10240
minLength: 1
type: string
reason:
description: |-
reason is the reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may be empty.
maxLength: 256
minLength: 1
type: string
severity:
description: |-
severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
maxLength: 32
type: string
status:
description: status of the condition, one of 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.
maxLength: 256
minLength: 1
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
nodeInfo:
description: |-
NodeInfo contains information about the node's architecture and operating system.
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
properties:
architecture:
description: |-
Architecture is the CPU architecture of the node.
Its underlying type is a string and its value can be any of amd64, arm64.
enum:
- amd64
- arm64
type: string
operatingSystem:
description: |-
OperatingSystem is the operating system of the node.
Its underlying type is a string and its value can be any of linux, windows.
enum:
- linux
- windows
type: string
type: object
type: object
type: object
served: true
storage: true
subresources:
status: {}
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ rules:
resources:
- awsclusters/status
- awsfargateprofiles/status
- awsmachinetemplates/status
- rosaclusters/status
- rosanetworks/status
- rosaroleconfigs/status
Expand Down
Loading