Skip to content

Commit 4e28426

Browse files
authored
feat: Add EKS handlers (#1254)
Reusing as much as possible of the AWS handlers, with slight tweaks. **What problem does this PR solve?**: **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. --> Requires #1253.
1 parent e644570 commit 4e28426

File tree

60 files changed

+2504
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2504
-40
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ var (
3434
nutanixClusterConfigCRDDefinition []byte
3535
//go:embed crds/caren.nutanix.com_genericclusterconfigs.yaml
3636
genericClusterConfigCRDDefinition []byte
37+
//go:embed crds/caren.nutanix.com_eksclusterconfigs.yaml
38+
eksClusterConfigCRDDefinition []byte
3739

3840
dockerClusterConfigVariableSchema = variables.MustSchemaFromCRDYAML(
3941
dockerClusterConfigCRDDefinition,
@@ -47,6 +49,9 @@ var (
4749
genericClusterConfigVariableSchema = variables.MustSchemaFromCRDYAML(
4850
genericClusterConfigCRDDefinition,
4951
)
52+
eksClusterConfigVariableSchema = variables.MustSchemaFromCRDYAML(
53+
eksClusterConfigCRDDefinition,
54+
)
5055
)
5156

5257
// +kubebuilder:object:root=true
@@ -234,6 +239,31 @@ type GenericClusterConfigSpec struct {
234239
NTP *NTP `json:"ntp,omitempty"`
235240
}
236241

242+
// +kubebuilder:object:root=true
243+
244+
// EKSClusterConfig is the Schema for the eksclusterconfigs API.
245+
type EKSClusterConfig struct {
246+
metav1.TypeMeta `json:",inline"`
247+
metav1.ObjectMeta `json:"metadata,omitempty"`
248+
249+
// +kubebuilder:validation:Optional
250+
Spec EKSClusterConfigSpec `json:"spec,omitempty"`
251+
}
252+
253+
func (s EKSClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
254+
return eksClusterConfigVariableSchema
255+
}
256+
257+
// EKSClusterConfigSpec defines the desired state of ClusterConfig.
258+
type EKSClusterConfigSpec struct {
259+
// EKS cluster configuration.
260+
// +kubebuilder:validation:Optional
261+
EKS *EKSSpec `json:"eks,omitempty"`
262+
263+
// +kubebuilder:validation:Optional
264+
Addons *AWSAddons `json:"addons,omitempty"`
265+
}
266+
237267
type Image struct {
238268
// Repository is used to override the image repository to pull from.
239269
// +kubebuilder:validation:Optional

api/v1alpha1/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const (
1717
DockerVariableName = "docker"
1818
// NutanixVariableName is the Nutanix config patch variable name.
1919
NutanixVariableName = "nutanix"
20+
// AWSVariableName is the EKS config patch variable name.
21+
EKSVariableName = "eks"
2022

2123
// CNIVariableName is the CNI external patch variable name.
2224
CNIVariableName = "cni"

api/v1alpha1/crds/caren.nutanix.com_eksclusterconfigs.yaml

Lines changed: 355 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
---
4+
apiVersion: apiextensions.k8s.io/v1
5+
kind: CustomResourceDefinition
6+
metadata:
7+
annotations:
8+
controller-gen.kubebuilder.io/version: v0.18.0
9+
name: eksworkernodeconfigs.caren.nutanix.com
10+
spec:
11+
group: caren.nutanix.com
12+
names:
13+
kind: EKSWorkerNodeConfig
14+
listKind: EKSWorkerNodeConfigList
15+
plural: eksworkernodeconfigs
16+
singular: eksworkernodeconfig
17+
scope: Namespaced
18+
versions:
19+
- name: v1alpha1
20+
schema:
21+
openAPIV3Schema:
22+
description: EKSWorkerNodeConfig is the Schema for the eksnodeconfigs API.
23+
properties:
24+
apiVersion:
25+
description: |-
26+
APIVersion defines the versioned schema of this representation of an object.
27+
Servers should convert recognized schemas to the latest internal value, and
28+
may reject unrecognized values.
29+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
30+
type: string
31+
kind:
32+
description: |-
33+
Kind is a string value representing the REST resource this object represents.
34+
Servers may infer this from the endpoint the client submits requests to.
35+
Cannot be updated.
36+
In CamelCase.
37+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
38+
type: string
39+
metadata:
40+
type: object
41+
spec:
42+
description: |-
43+
EKSWorkerNodeConfigSpec defines the desired state of EKSNodeConfig.
44+
Place any configuration that can be applied to individual Nodes here.
45+
Otherwise, it should go into the ClusterConfigSpec.
46+
properties:
47+
eks:
48+
properties:
49+
additionalSecurityGroups:
50+
items:
51+
properties:
52+
id:
53+
description: ID is the id of the security group
54+
format: ^sg-[0-9a-f]{8}(?:[0-9a-f]{9})?$
55+
minLength: 1
56+
type: string
57+
type: object
58+
maxItems: 32
59+
type: array
60+
ami:
61+
description: |-
62+
AMI or AMI Lookup arguments for machine image of a AWS machine.
63+
If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence
64+
properties:
65+
id:
66+
description: AMI ID is the reference to the AMI from which
67+
to create the machine instance.
68+
format: ^ami-[0-9a-f]{8}(?:[0-9a-f]{9})?$
69+
minLength: 1
70+
type: string
71+
lookup:
72+
description: Lookup is the lookup arguments for the AMI.
73+
properties:
74+
baseOS:
75+
description: The name of the base os for image lookup
76+
maxLength: 32
77+
minLength: 1
78+
type: string
79+
format:
80+
description: |-
81+
AMI naming format. Supports substitutions for {{.BaseOS}} and {{.K8sVersion}} with the
82+
base OS and kubernetes version.
83+
example: capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*
84+
maxLength: 128
85+
minLength: 1
86+
type: string
87+
org:
88+
description: The AWS Organization ID to use for image
89+
lookup.
90+
format: ^o-[0-9a-z]{10,32}$
91+
maxLength: 34
92+
minLength: 12
93+
type: string
94+
type: object
95+
type: object
96+
iamInstanceProfile:
97+
default: nodes.cluster-api-provider-aws.sigs.k8s.io
98+
description: The IAM instance profile to use for the cluster Machines.
99+
maxLength: 128
100+
minLength: 1
101+
type: string
102+
instanceType:
103+
default: m5.2xlarge
104+
description: The AWS instance type to use for the cluster Machines.
105+
maxLength: 32
106+
minLength: 1
107+
type: string
108+
placementGroup:
109+
description: PlacementGroup specifies the placement group in which
110+
to launch the instance.
111+
properties:
112+
name:
113+
description: Name is the name of the placement group.
114+
maxLength: 255
115+
minLength: 1
116+
type: string
117+
required:
118+
- name
119+
type: object
120+
type: object
121+
taints:
122+
description: Taints specifies the taints the Node API object should
123+
be registered with.
124+
items:
125+
description: |-
126+
The node this Taint is attached to has the "effect" on
127+
any pod that does not tolerate the Taint.
128+
properties:
129+
effect:
130+
default: NoSchedule
131+
description: |-
132+
The effect of the taint on pods that do not tolerate the taint.
133+
Valid effects are NoSchedule, PreferNoSchedule and NoExecute.
134+
enum:
135+
- NoSchedule
136+
- PreferNoSchedule
137+
- NoExecute
138+
type: string
139+
key:
140+
description: The taint key to be applied to a node.
141+
maxLength: 253
142+
type: string
143+
value:
144+
description: The taint value corresponding to the taint key.
145+
maxLength: 63
146+
minLength: 1
147+
type: string
148+
required:
149+
- effect
150+
- key
151+
type: object
152+
type: array
153+
type: object
154+
type: object
155+
served: true
156+
storage: true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2023 Nutanix. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
type EKSSpec struct {
7+
// AWS region to create cluster in.
8+
// +kubebuilder:validation:Optional
9+
Region *Region `json:"region,omitempty"`
10+
11+
// AWS network configuration.
12+
// +kubebuilder:validation:Optional
13+
Network *AWSNetwork `json:"network,omitempty"`
14+
}

api/v1alpha1/nodeconfig_types.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ var (
1919
awsNodeConfigCRDDefinition []byte
2020
//go:embed crds/caren.nutanix.com_nutanixworkernodeconfigs.yaml
2121
nutanixNodeConfigCRDDefinition []byte
22+
//go:embed crds/caren.nutanix.com_eksworkernodeconfigs.yaml
23+
eksNodeConfigCRDDefinition []byte
2224

2325
dockerNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML(
2426
dockerNodeConfigCRDDefinition,
2527
)
26-
awsWorkerNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML(awsNodeConfigCRDDefinition)
27-
nutanixNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML(
28+
awsNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML(awsNodeConfigCRDDefinition)
29+
nutanixNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML(
2830
nutanixNodeConfigCRDDefinition,
2931
)
32+
eksNodeConfigVariableSchema = variables.MustSchemaFromCRDYAML(eksNodeConfigCRDDefinition)
3033
)
3134

3235
// +kubebuilder:object:root=true
@@ -41,7 +44,7 @@ type AWSWorkerNodeConfig struct {
4144
}
4245

4346
func (s AWSWorkerNodeConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
44-
return awsWorkerNodeConfigVariableSchema
47+
return awsNodeConfigVariableSchema
4548
}
4649

4750
// AWSWorkerNodeConfigSpec defines the desired state of AWSNodeConfig.
@@ -114,6 +117,37 @@ type GenericNodeSpec struct {
114117
NodeRegistration *NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
115118
}
116119

120+
// +kubebuilder:object:root=true
121+
122+
// EKSWorkerNodeConfig is the Schema for the eksnodeconfigs API.
123+
type EKSWorkerNodeConfig struct {
124+
metav1.TypeMeta `json:",inline"`
125+
metav1.ObjectMeta `json:"metadata,omitempty"`
126+
127+
// +kubebuilder:validation:Optional
128+
Spec EKSWorkerNodeConfigSpec `json:"spec,omitempty"`
129+
}
130+
131+
func (s EKSWorkerNodeConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
132+
return eksNodeConfigVariableSchema
133+
}
134+
135+
// EKSWorkerNodeConfigSpec defines the desired state of EKSNodeConfig.
136+
// Place any configuration that can be applied to individual Nodes here.
137+
// Otherwise, it should go into the ClusterConfigSpec.
138+
type EKSWorkerNodeConfigSpec struct {
139+
// +kubebuilder:validation:Optional
140+
EKS *AWSWorkerNodeSpec `json:"eks,omitempty"`
141+
142+
EKSNodeSpec `json:",inline"`
143+
}
144+
145+
type EKSNodeSpec struct {
146+
// Taints specifies the taints the Node API object should be registered with.
147+
// +kubebuilder:validation:Optional
148+
Taints []Taint `json:"taints,omitempty"`
149+
}
150+
117151
// The node this Taint is attached to has the "effect" on
118152
// any pod that does not tolerate the Taint.
119153
type Taint struct {
@@ -174,5 +208,6 @@ func init() {
174208
&AWSWorkerNodeConfig{},
175209
&DockerWorkerNodeConfig{},
176210
&NutanixWorkerNodeConfig{},
211+
&EKSWorkerNodeConfig{},
177212
)
178213
}

0 commit comments

Comments
 (0)