Skip to content

Commit f0a29d1

Browse files
committed
Add EKS ClusterClass example
1 parent a1e5677 commit f0a29d1

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: ClusterClass
3+
metadata:
4+
name: aws-eks-example
5+
spec:
6+
controlPlane:
7+
ref:
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
9+
kind: AWSManagedControlPlaneTemplate
10+
name: "eks-control-plane"
11+
infrastructure:
12+
ref:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
14+
kind: AWSManagedClusterTemplate
15+
name: "eks-cluster"
16+
workers:
17+
machineDeployments:
18+
- class: default-worker
19+
template:
20+
bootstrap:
21+
ref:
22+
name: "eks-md-0"
23+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
24+
kind: EKSConfigTemplate
25+
infrastructure:
26+
ref:
27+
name: "eks-md-0"
28+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
29+
kind: AWSMachineTemplate
30+
variables:
31+
- name: region
32+
required: true
33+
schema:
34+
openAPIV3Schema:
35+
description: "The AWS region where the Cluster will be created"
36+
type: string
37+
- name: sshKeyName
38+
required: false
39+
schema:
40+
openAPIV3Schema:
41+
description: "AWS SSH key name to use"
42+
type: string
43+
default: ''
44+
- name: instanceType
45+
required: false
46+
schema:
47+
openAPIV3Schema:
48+
description: "AWS instance type to use"
49+
type: string
50+
default: "t3.xlarge"
51+
- name: eksClusterName
52+
required: false
53+
schema:
54+
openAPIV3Schema:
55+
description: "EKS cluster name"
56+
type: string
57+
default: ''
58+
patches:
59+
- name: awsManagedControlPlaneTemplate
60+
definitions:
61+
- selector:
62+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
63+
kind: AWSManagedControlPlaneTemplate
64+
matchResources:
65+
controlPlane: true
66+
jsonPatches:
67+
- op: add
68+
enabledIf: '{{ ne .eksClusterName }}'
69+
path: /spec/template/spec/eksClusterName
70+
valueFrom:
71+
variable: eksClusterName
72+
- op: add
73+
path: /spec/template/spec/region
74+
valueFrom:
75+
variable: region
76+
- op: add
77+
enabledIf: '{{ ne .sshKeyName }}'
78+
path: /spec/template/spec/sshKeyName
79+
valueFrom:
80+
variable: sshKeyName
81+
# Builtins
82+
- op: add
83+
path: "/spec/template/spec/version"
84+
valueFrom:
85+
variable: builtin.cluster.topology.version
86+
- name: awsMachineTemplate
87+
definitions:
88+
- selector:
89+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
90+
kind: AWSMachineTemplate
91+
matchResources:
92+
machineDeploymentClass:
93+
names:
94+
- default-worker
95+
jsonPatches:
96+
- op: add
97+
enabledIf: '{{ ne .sshKeyName }}'
98+
path: /spec/template/spec/sshKeyName
99+
valueFrom:
100+
variable: sshKeyName
101+
- op: add
102+
path: /spec/template/spec/instanceType
103+
valueFrom:
104+
variable: instanceType
105+
---
106+
kind: AWSManagedClusterTemplate
107+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
108+
metadata:
109+
name: "eks-cluster"
110+
spec:
111+
template:
112+
spec: {}
113+
---
114+
kind: AWSManagedControlPlaneTemplate
115+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
116+
metadata:
117+
name: "eks-control-plane"
118+
spec:
119+
template:
120+
spec:
121+
region: "replaced_by_patch"
122+
version: "v0.0.0" # To be replaced by patch
123+
---
124+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
125+
kind: AWSMachineTemplate
126+
metadata:
127+
name: "eks-md-0"
128+
spec:
129+
template:
130+
spec:
131+
instanceType: "replaced_by_patch"
132+
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
133+
---
134+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
135+
kind: EKSConfigTemplate
136+
metadata:
137+
name: "eks-md-0"
138+
spec:
139+
template:
140+
spec: {}

0 commit comments

Comments
 (0)