@@ -17,15 +17,139 @@ limitations under the License.
17
17
package v1alpha1
18
18
19
19
import (
20
+ "k8s.io/apimachinery/pkg/api/resource"
20
21
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22
+ capi "sigs.k8s.io/cluster-api/api/v1beta1"
21
23
)
22
24
25
+ // NodePoolSpec defines the configuration for a Karpenter NodePool
26
+ type NodePoolSpec struct {
27
+ // Disruption specifies the disruption behavior for the node pool
28
+ // +optional
29
+ Disruption * DisruptionSpec `json:"disruption,omitempty"`
30
+
31
+ // Limits specifies the limits for the node pool
32
+ // +optional
33
+ Limits * LimitsSpec `json:"limits,omitempty"`
34
+
35
+ // Requirements specifies the requirements for the node pool
36
+ // +optional
37
+ Requirements []RequirementSpec `json:"requirements,omitempty"`
38
+
39
+ // Taints specifies the taints to apply to nodes in this pool
40
+ // +optional
41
+ Taints []TaintSpec `json:"taints,omitempty"`
42
+
43
+ // Labels specifies the labels to apply to nodes in this pool
44
+ // +optional
45
+ Labels map [string ]string `json:"labels,omitempty"`
46
+
47
+ // Weight specifies the weight of this node pool
48
+ // +optional
49
+ Weight * int32 `json:"weight,omitempty"`
50
+ }
51
+
52
+ // DisruptionSpec defines the disruption behavior for a NodePool
53
+ type DisruptionSpec struct {
54
+ // ConsolidateAfter specifies when to consolidate nodes
55
+ // +optional
56
+ ConsolidateAfter * metav1.Duration `json:"consolidateAfter,omitempty"`
57
+
58
+ // ConsolidationPolicy specifies the consolidation policy
59
+ // +optional
60
+ ConsolidationPolicy * string `json:"consolidationPolicy,omitempty"`
61
+
62
+ // ConsolidateUnder specifies when to consolidate under
63
+ // +optional
64
+ ConsolidateUnder * ConsolidateUnderSpec `json:"consolidateUnder,omitempty"`
65
+ }
66
+
67
+ // ConsolidateUnderSpec defines when to consolidate under
68
+ type ConsolidateUnderSpec struct {
69
+ // CPUUtilization specifies the CPU utilization threshold
70
+ // +optional
71
+ CPUUtilization * string `json:"cpuUtilization,omitempty"`
72
+
73
+ // MemoryUtilization specifies the memory utilization threshold
74
+ // +optional
75
+ MemoryUtilization * string `json:"memoryUtilization,omitempty"`
76
+ }
77
+
78
+ // LimitsSpec defines the limits for a NodePool
79
+ type LimitsSpec struct {
80
+ // CPU specifies the CPU limit
81
+ // +optional
82
+ CPU * resource.Quantity `json:"cpu,omitempty"`
83
+
84
+ // Memory specifies the memory limit
85
+ // +optional
86
+ Memory * resource.Quantity `json:"memory,omitempty"`
87
+ }
88
+
89
+ // RequirementSpec defines a requirement for a NodePool
90
+ type RequirementSpec struct {
91
+ // Key specifies the requirement key
92
+ Key string `json:"key"`
93
+
94
+ // Operator specifies the requirement operator
95
+ Operator string `json:"operator"`
96
+
97
+ // Values specifies the requirement values
98
+ // +optional
99
+ Values []string `json:"values,omitempty"`
100
+ }
101
+
102
+ // TaintSpec defines a taint for a NodePool
103
+ type TaintSpec struct {
104
+ // Key specifies the taint key
105
+ Key string `json:"key"`
106
+
107
+ // Value specifies the taint value
108
+ // +optional
109
+ Value * string `json:"value,omitempty"`
110
+
111
+ // Effect specifies the taint effect
112
+ Effect string `json:"effect"`
113
+ }
114
+
115
+ // EC2NodeClassSpec defines the configuration for a Karpenter EC2NodeClass
116
+ type EC2NodeClassSpec struct {
117
+ // AMIID specifies the AMI ID to use
118
+ // +optional
119
+ AMIID * string `json:"amiId,omitempty"`
120
+
121
+ // SecurityGroups specifies the security groups to use
122
+ // +optional
123
+ SecurityGroups []string `json:"securityGroups,omitempty"`
124
+
125
+ // Subnets specifies the subnets to use
126
+ // +optional
127
+ Subnets []string `json:"subnets,omitempty"`
128
+
129
+ // UserData specifies the user data to use
130
+ // +optional
131
+ UserData * string `json:"userData,omitempty"`
132
+
133
+ // Tags specifies the tags to apply to EC2 instances
134
+ // +optional
135
+ Tags map [string ]string `json:"tags,omitempty"`
136
+ }
137
+
23
138
// KarpenterMachinePoolSpec defines the desired state of KarpenterMachinePool.
24
139
type KarpenterMachinePoolSpec struct {
25
140
// The name or the Amazon Resource Name (ARN) of the instance profile associated
26
141
// with the IAM role for the instance. The instance profile contains the IAM
27
142
// role.
28
143
IamInstanceProfile string `json:"iamInstanceProfile,omitempty"`
144
+
145
+ // NodePool specifies the configuration for the Karpenter NodePool
146
+ // +optional
147
+ NodePool * NodePoolSpec `json:"nodePool,omitempty"`
148
+
149
+ // EC2NodeClass specifies the configuration for the Karpenter EC2NodeClass
150
+ // +optional
151
+ EC2NodeClass * EC2NodeClassSpec `json:"ec2NodeClass,omitempty"`
152
+
29
153
// ProviderIDList are the identification IDs of machine instances provided by the provider.
30
154
// This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances.
31
155
// +optional
@@ -41,6 +165,18 @@ type KarpenterMachinePoolStatus struct {
41
165
// Replicas is the most recently observed number of replicas
42
166
// +optional
43
167
Replicas int32 `json:"replicas"`
168
+
169
+ // Conditions defines current service state of the KarpenterMachinePool.
170
+ // +optional
171
+ Conditions capi.Conditions `json:"conditions,omitempty"`
172
+
173
+ // NodePoolReady indicates whether the NodePool is ready
174
+ // +optional
175
+ NodePoolReady bool `json:"nodePoolReady"`
176
+
177
+ // EC2NodeClassReady indicates whether the EC2NodeClass is ready
178
+ // +optional
179
+ EC2NodeClassReady bool `json:"ec2NodeClassReady"`
44
180
}
45
181
46
182
// +kubebuilder:object:root=true
@@ -72,3 +208,11 @@ type KarpenterMachinePoolList struct {
72
208
func init () {
73
209
SchemeBuilder .Register (& KarpenterMachinePool {}, & KarpenterMachinePoolList {})
74
210
}
211
+
212
+ func (in * KarpenterMachinePool ) GetConditions () capi.Conditions {
213
+ return in .Status .Conditions
214
+ }
215
+
216
+ func (in * KarpenterMachinePool ) SetConditions (conditions capi.Conditions ) {
217
+ in .Status .Conditions = conditions
218
+ }
0 commit comments