Skip to content

Commit 4dad1d7

Browse files
chore: Revert unneeded v1beta1 api changes (aws#4626)
1 parent c146865 commit 4dad1d7

31 files changed

+325
-343
lines changed

pkg/apis/apis.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ var (
4848
var (
4949
//go:embed crds/karpenter.k8s.aws_awsnodetemplates.yaml
5050
AWSNodeTemplateCRD []byte
51-
//go:embed crds/compute.k8s.aws_nodeclasses.yaml
52-
NodeClassCRD []byte
53-
CRDs = append(apis.CRDs,
51+
//go:embed crds/karpenter.k8s.aws_ec2nodeclasses.yaml
52+
EC2NodeClassCRD []byte
53+
CRDs = append(apis.CRDs,
5454
lo.Must(functional.Unmarshal[v1.CustomResourceDefinition](AWSNodeTemplateCRD)),
55-
lo.Must(functional.Unmarshal[v1.CustomResourceDefinition](NodeClassCRD)),
55+
lo.Must(functional.Unmarshal[v1.CustomResourceDefinition](EC2NodeClassCRD)),
5656
)
5757
)
5858

pkg/apis/crds/compute.k8s.aws_nodeclasses.yaml pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@ kind: CustomResourceDefinition
44
metadata:
55
annotations:
66
controller-gen.kubebuilder.io/version: v0.13.0
7-
name: nodeclasses.compute.k8s.aws
7+
name: ec2nodeclasses.karpenter.k8s.aws
88
spec:
9-
group: compute.k8s.aws
9+
group: karpenter.k8s.aws
1010
names:
1111
categories:
1212
- karpenter
13-
kind: NodeClass
14-
listKind: NodeClassList
15-
plural: nodeclasses
16-
singular: nodeclass
13+
kind: EC2NodeClass
14+
listKind: EC2NodeClassList
15+
plural: ec2nodeclasses
16+
shortNames:
17+
- ec2nc
18+
- ec2ncs
19+
singular: ec2nodeclass
1720
scope: Cluster
1821
versions:
1922
- name: v1beta1
2023
schema:
2124
openAPIV3Schema:
22-
description: NodeClass is the Schema for the NodeClass API
25+
description: EC2NodeClass is the Schema for the EC2NodeClass API
2326
properties:
2427
apiVersion:
2528
description: 'APIVersion defines the versioned schema of this representation
@@ -34,7 +37,7 @@ spec:
3437
metadata:
3538
type: object
3639
spec:
37-
description: NodeClassSpec is the top level specification for the AWS
40+
description: EC2NodeClassSpec is the top level specification for the AWS
3841
Karpenter Provider. This will contain configuration necessary to launch
3942
instances in AWS.
4043
properties:
@@ -61,9 +64,6 @@ spec:
6164
description: Owner is the owner for the ami. You can specify
6265
a combination of AWS account IDs, "self", "amazon", and "aws-marketplace"
6366
type: string
64-
ssm:
65-
description: SSM is the ssm alias for an ami.
66-
type: string
6767
tags:
6868
additionalProperties:
6969
type: string
@@ -262,7 +262,7 @@ spec:
262262
type: string
263263
type: object
264264
status:
265-
description: NodeClassStatus contains the resolved state of the NodeClass
265+
description: EC2NodeClassStatus contains the resolved state of the EC2NodeClass
266266
properties:
267267
amis:
268268
description: AMI contains the current AMI values that are available

pkg/apis/v1beta1/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ limitations under the License.
1515
// +k8s:openapi-gen=true
1616
// +k8s:deepcopy-gen=package,register
1717
// +k8s:defaulter-gen=TypeMeta
18-
// +groupName=compute.k8s.aws
18+
// +groupName=karpenter.k8s.aws
1919
package v1beta1 // doc.go is discovered by codegen

pkg/apis/v1beta1/nodeclass.go pkg/apis/v1beta1/ec2nodeclass.go

+11-14
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
)
2525

26-
// NodeClassSpec is the top level specification for the AWS Karpenter Provider.
26+
// EC2NodeClassSpec is the top level specification for the AWS Karpenter Provider.
2727
// This will contain configuration necessary to launch instances in AWS.
28-
type NodeClassSpec struct {
28+
type EC2NodeClassSpec struct {
2929
// SubnetSelectorTerms is a list of or subnet selector terms. The terms are ORed.
3030
// +optional
3131
SubnetSelectorTerms []SubnetSelectorTerm `json:"subnetSelectorTerms" hash:"ignore"`
@@ -150,9 +150,6 @@ type AMISelectorTerm struct {
150150
// You can specify a combination of AWS account IDs, "self", "amazon", and "aws-marketplace"
151151
// +optional
152152
Owner string `json:"owner,omitempty"`
153-
// SSM is the ssm alias for an ami.
154-
// +optional
155-
SSM string `json:"ssm,omitempty"`
156153
}
157154

158155
// MetadataOptions contains parameters for specifying the exposure of the
@@ -265,35 +262,35 @@ type BlockDevice struct {
265262
VolumeType *string `json:"volumeType,omitempty"`
266263
}
267264

268-
// NodeClass is the Schema for the NodeClass API
265+
// EC2NodeClass is the Schema for the EC2NodeClass API
269266
// +kubebuilder:object:root=true
270-
// +kubebuilder:resource:path=nodeclasses,scope=Cluster,categories=karpenter
267+
// +kubebuilder:resource:path=ec2nodeclasses,scope=Cluster,categories=karpenter,shortName={ec2nc,ec2ncs}
271268
// +kubebuilder:subresource:status
272-
type NodeClass struct {
269+
type EC2NodeClass struct {
273270
metav1.TypeMeta `json:",inline"`
274271
metav1.ObjectMeta `json:"metadata,omitempty"`
275272

276-
Spec NodeClassSpec `json:"spec,omitempty"`
277-
Status NodeClassStatus `json:"status,omitempty"`
273+
Spec EC2NodeClassSpec `json:"spec,omitempty"`
274+
Status EC2NodeClassStatus `json:"status,omitempty"`
278275

279276
// IsNodeTemplate tells Karpenter whether the in-memory representation of this object
280277
// is actually referring to a AWSNodeTemplate object. This value is not actually part of the v1beta1 public-facing API
281278
// TODO @joinnis: Remove this field when v1alpha5 is unsupported in a future version of Karpenter
282279
IsNodeTemplate bool `json:"-" hash:"ignore"`
283280
}
284281

285-
func (a *NodeClass) Hash() string {
282+
func (a *EC2NodeClass) Hash() string {
286283
return fmt.Sprint(lo.Must(hashstructure.Hash(a.Spec, hashstructure.FormatV2, &hashstructure.HashOptions{
287284
SlicesAsSets: true,
288285
IgnoreZeroValue: true,
289286
ZeroNil: true,
290287
})))
291288
}
292289

293-
// NodeClassList contains a list of NodeClass
290+
// EC2NodeClassList contains a list of EC2NodeClass
294291
// +kubebuilder:object:root=true
295-
type NodeClassList struct {
292+
type EC2NodeClassList struct {
296293
metav1.TypeMeta `json:",inline"`
297294
metav1.ListMeta `json:"metadata,omitempty"`
298-
Items []NodeClass `json:"items"`
295+
Items []EC2NodeClass `json:"items"`
299296
}

pkg/apis/v1beta1/nodeclass_defaults.go pkg/apis/v1beta1/ec2nodeclass_defaults.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ import (
1818
"context"
1919
)
2020

21-
// SetDefaults for the NodeClass
22-
func (a *NodeClass) SetDefaults(_ context.Context) {}
21+
// SetDefaults for the EC2NodeClass
22+
func (a *EC2NodeClass) SetDefaults(_ context.Context) {}

pkg/apis/v1beta1/nodeclass_status.go pkg/apis/v1beta1/ec2nodeclass_status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ type AMI struct {
4949
Requirements []v1.NodeSelectorRequirement `json:"requirements"`
5050
}
5151

52-
// NodeClassStatus contains the resolved state of the NodeClass
53-
type NodeClassStatus struct {
52+
// EC2NodeClassStatus contains the resolved state of the EC2NodeClass
53+
type EC2NodeClassStatus struct {
5454
// Subnets contains the current Subnet values that are available to the
5555
// cluster under the subnet selectors.
5656
// +optional

pkg/apis/v1beta1/nodeclass_validation.go pkg/apis/v1beta1/ec2nodeclass_validation.go

+24-24
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ var (
4242
maxVolumeSize = *resource.NewScaledQuantity(64, resource.Tera)
4343
)
4444

45-
func (a *NodeClass) SupportedVerbs() []admissionregistrationv1.OperationType {
45+
func (a *EC2NodeClass) SupportedVerbs() []admissionregistrationv1.OperationType {
4646
return []admissionregistrationv1.OperationType{
4747
admissionregistrationv1.Create,
4848
admissionregistrationv1.Update,
4949
}
5050
}
5151

52-
func (a *NodeClass) Validate(ctx context.Context) (errs *apis.FieldError) {
52+
func (a *EC2NodeClass) Validate(ctx context.Context) (errs *apis.FieldError) {
5353
return errs.Also(
5454
apis.ValidateObjectMetadata(a).ViaField("metadata"),
5555
a.Spec.validate(ctx).ViaField("spec"),
5656
)
5757
}
5858

59-
func (in *NodeClassSpec) validate(_ context.Context) (errs *apis.FieldError) {
59+
func (in *EC2NodeClassSpec) validate(_ context.Context) (errs *apis.FieldError) {
6060
return errs.Also(
6161
in.validateSubnetSelectorTerms().ViaField(subnetSelectorTermsPath),
6262
in.validateSecurityGroupSelectorTerms().ViaField(securityGroupSelectorTermsPath),
@@ -69,7 +69,7 @@ func (in *NodeClassSpec) validate(_ context.Context) (errs *apis.FieldError) {
6969
)
7070
}
7171

72-
func (in *NodeClassSpec) validateSubnetSelectorTerms() (errs *apis.FieldError) {
72+
func (in *EC2NodeClassSpec) validateSubnetSelectorTerms() (errs *apis.FieldError) {
7373
if len(in.SubnetSelectorTerms) == 0 {
7474
errs = errs.Also(apis.ErrMissingOneOf())
7575
}
@@ -89,7 +89,7 @@ func (in *SubnetSelectorTerm) validate() (errs *apis.FieldError) {
8989
return errs
9090
}
9191

92-
func (in *NodeClassSpec) validateSecurityGroupSelectorTerms() (errs *apis.FieldError) {
92+
func (in *EC2NodeClassSpec) validateSecurityGroupSelectorTerms() (errs *apis.FieldError) {
9393
if len(in.SecurityGroupSelectorTerms) == 0 {
9494
errs = errs.Also(apis.ErrMissingOneOf())
9595
}
@@ -112,7 +112,7 @@ func (in *SecurityGroupSelectorTerm) validate() (errs *apis.FieldError) {
112112
return errs
113113
}
114114

115-
func (in *NodeClassSpec) validateAMISelectorTerms() (errs *apis.FieldError) {
115+
func (in *EC2NodeClassSpec) validateAMISelectorTerms() (errs *apis.FieldError) {
116116
for _, term := range in.AMISelectorTerms {
117117
errs = errs.Also(term.validate())
118118
}
@@ -122,9 +122,9 @@ func (in *NodeClassSpec) validateAMISelectorTerms() (errs *apis.FieldError) {
122122
//nolint:gocyclo
123123
func (in *AMISelectorTerm) validate() (errs *apis.FieldError) {
124124
errs = errs.Also(validateTags(in.Tags).ViaField("tags"))
125-
if len(in.Tags) == 0 && in.ID == "" && in.Name == "" && in.SSM == "" {
126-
errs = errs.Also(apis.ErrGeneric("expect at least one, got none", "tags", "id", "name", "ssm"))
127-
} else if in.ID != "" && (len(in.Tags) > 0 || in.Name != "" || in.SSM != "" || in.Owner != "") {
125+
if len(in.Tags) == 0 && in.ID == "" && in.Name == "" {
126+
errs = errs.Also(apis.ErrGeneric("expect at least one, got none", "tags", "id", "name"))
127+
} else if in.ID != "" && (len(in.Tags) > 0 || in.Name != "" || in.Owner != "") {
128128
errs = errs.Also(apis.ErrGeneric(`"id" is mutually exclusive, cannot be set with a combination of other fields in`))
129129
}
130130
return errs
@@ -142,7 +142,7 @@ func validateTags(m map[string]string) (errs *apis.FieldError) {
142142
return errs
143143
}
144144

145-
func (in *NodeClassSpec) validateMetadataOptions() (errs *apis.FieldError) {
145+
func (in *EC2NodeClassSpec) validateMetadataOptions() (errs *apis.FieldError) {
146146
if in.MetadataOptions == nil {
147147
return nil
148148
}
@@ -154,21 +154,21 @@ func (in *NodeClassSpec) validateMetadataOptions() (errs *apis.FieldError) {
154154
)
155155
}
156156

157-
func (in *NodeClassSpec) validateHTTPEndpoint() *apis.FieldError {
157+
func (in *EC2NodeClassSpec) validateHTTPEndpoint() *apis.FieldError {
158158
if in.MetadataOptions.HTTPEndpoint == nil {
159159
return nil
160160
}
161161
return in.validateStringEnum(*in.MetadataOptions.HTTPEndpoint, "httpEndpoint", ec2.LaunchTemplateInstanceMetadataEndpointState_Values())
162162
}
163163

164-
func (in *NodeClassSpec) validateHTTPProtocolIpv6() *apis.FieldError {
164+
func (in *EC2NodeClassSpec) validateHTTPProtocolIpv6() *apis.FieldError {
165165
if in.MetadataOptions.HTTPProtocolIPv6 == nil {
166166
return nil
167167
}
168168
return in.validateStringEnum(*in.MetadataOptions.HTTPProtocolIPv6, "httpProtocolIPv6", ec2.LaunchTemplateInstanceMetadataProtocolIpv6_Values())
169169
}
170170

171-
func (in *NodeClassSpec) validateHTTPPutResponseHopLimit() *apis.FieldError {
171+
func (in *EC2NodeClassSpec) validateHTTPPutResponseHopLimit() *apis.FieldError {
172172
if in.MetadataOptions.HTTPPutResponseHopLimit == nil {
173173
return nil
174174
}
@@ -179,14 +179,14 @@ func (in *NodeClassSpec) validateHTTPPutResponseHopLimit() *apis.FieldError {
179179
return nil
180180
}
181181

182-
func (in *NodeClassSpec) validateHTTPTokens() *apis.FieldError {
182+
func (in *EC2NodeClassSpec) validateHTTPTokens() *apis.FieldError {
183183
if in.MetadataOptions.HTTPTokens == nil {
184184
return nil
185185
}
186186
return in.validateStringEnum(*in.MetadataOptions.HTTPTokens, "httpTokens", ec2.LaunchTemplateHttpTokensState_Values())
187187
}
188188

189-
func (in *NodeClassSpec) validateStringEnum(value, field string, validValues []string) *apis.FieldError {
189+
func (in *EC2NodeClassSpec) validateStringEnum(value, field string, validValues []string) *apis.FieldError {
190190
for _, validValue := range validValues {
191191
if value == validValue {
192192
return nil
@@ -195,7 +195,7 @@ func (in *NodeClassSpec) validateStringEnum(value, field string, validValues []s
195195
return apis.ErrInvalidValue(fmt.Sprintf("%s not in %v", value, strings.Join(validValues, ", ")), field)
196196
}
197197

198-
func (in *NodeClassSpec) validateBlockDeviceMappings() (errs *apis.FieldError) {
198+
func (in *EC2NodeClassSpec) validateBlockDeviceMappings() (errs *apis.FieldError) {
199199
for i, blockDeviceMapping := range in.BlockDeviceMappings {
200200
if err := in.validateBlockDeviceMapping(blockDeviceMapping); err != nil {
201201
errs = errs.Also(err.ViaFieldIndex(blockDeviceMappingsPath, i))
@@ -204,18 +204,18 @@ func (in *NodeClassSpec) validateBlockDeviceMappings() (errs *apis.FieldError) {
204204
return errs
205205
}
206206

207-
func (in *NodeClassSpec) validateBlockDeviceMapping(blockDeviceMapping *BlockDeviceMapping) (errs *apis.FieldError) {
207+
func (in *EC2NodeClassSpec) validateBlockDeviceMapping(blockDeviceMapping *BlockDeviceMapping) (errs *apis.FieldError) {
208208
return errs.Also(in.validateDeviceName(blockDeviceMapping), in.validateEBS(blockDeviceMapping))
209209
}
210210

211-
func (in *NodeClassSpec) validateDeviceName(blockDeviceMapping *BlockDeviceMapping) *apis.FieldError {
211+
func (in *EC2NodeClassSpec) validateDeviceName(blockDeviceMapping *BlockDeviceMapping) *apis.FieldError {
212212
if blockDeviceMapping.DeviceName == nil {
213213
return apis.ErrMissingField("deviceName")
214214
}
215215
return nil
216216
}
217217

218-
func (in *NodeClassSpec) validateEBS(blockDeviceMapping *BlockDeviceMapping) (errs *apis.FieldError) {
218+
func (in *EC2NodeClassSpec) validateEBS(blockDeviceMapping *BlockDeviceMapping) (errs *apis.FieldError) {
219219
if blockDeviceMapping.EBS == nil {
220220
return apis.ErrMissingField("ebs")
221221
}
@@ -230,14 +230,14 @@ func (in *NodeClassSpec) validateEBS(blockDeviceMapping *BlockDeviceMapping) (er
230230
return errs
231231
}
232232

233-
func (in *NodeClassSpec) validateVolumeType(blockDeviceMapping *BlockDeviceMapping) *apis.FieldError {
233+
func (in *EC2NodeClassSpec) validateVolumeType(blockDeviceMapping *BlockDeviceMapping) *apis.FieldError {
234234
if blockDeviceMapping.EBS.VolumeType != nil {
235235
return in.validateStringEnum(*blockDeviceMapping.EBS.VolumeType, "volumeType", ec2.VolumeType_Values())
236236
}
237237
return nil
238238
}
239239

240-
func (in *NodeClassSpec) validateVolumeSize(blockDeviceMapping *BlockDeviceMapping) *apis.FieldError {
240+
func (in *EC2NodeClassSpec) validateVolumeSize(blockDeviceMapping *BlockDeviceMapping) *apis.FieldError {
241241
// If an EBS mapping is present, one of volumeSize or snapshotID must be present
242242
if blockDeviceMapping.EBS.SnapshotID != nil && blockDeviceMapping.EBS.VolumeSize == nil {
243243
return nil
@@ -249,7 +249,7 @@ func (in *NodeClassSpec) validateVolumeSize(blockDeviceMapping *BlockDeviceMappi
249249
return nil
250250
}
251251

252-
func (in *NodeClassSpec) validateUserData() (errs *apis.FieldError) {
252+
func (in *EC2NodeClassSpec) validateUserData() (errs *apis.FieldError) {
253253
if in.UserData == nil {
254254
return nil
255255
}
@@ -259,7 +259,7 @@ func (in *NodeClassSpec) validateUserData() (errs *apis.FieldError) {
259259
return errs
260260
}
261261

262-
func (in *NodeClassSpec) validateAMIFamily() (errs *apis.FieldError) {
262+
func (in *EC2NodeClassSpec) validateAMIFamily() (errs *apis.FieldError) {
263263
if in.AMIFamily == nil {
264264
return nil
265265
}
@@ -269,7 +269,7 @@ func (in *NodeClassSpec) validateAMIFamily() (errs *apis.FieldError) {
269269
return errs.Also(in.validateStringEnum(*in.AMIFamily, amiFamilyPath, SupportedAMIFamilies))
270270
}
271271

272-
func (in *NodeClassSpec) validateTags() (errs *apis.FieldError) {
272+
func (in *EC2NodeClassSpec) validateTags() (errs *apis.FieldError) {
273273
for k, v := range in.Tags {
274274
if k == "" {
275275
errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf(

pkg/apis/v1beta1/register.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import (
2020
"k8s.io/apimachinery/pkg/runtime/schema"
2121
)
2222

23-
const Group = "compute.k8s.aws"
23+
const Group = "karpenter.k8s.aws"
2424

2525
var (
2626
SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: "v1beta1"}
2727
SchemeBuilder = runtime.NewSchemeBuilder(func(scheme *runtime.Scheme) error {
2828
scheme.AddKnownTypes(SchemeGroupVersion,
29-
&NodeClass{},
30-
&NodeClassList{},
29+
&EC2NodeClass{},
30+
&EC2NodeClassList{},
3131
)
3232
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
3333
return nil

0 commit comments

Comments
 (0)