Skip to content

Commit a05e175

Browse files
committed
chore: add clusterclass sample template
Signed-off-by: Carlos Salas <[email protected]>
1 parent 47ba457 commit a05e175

File tree

2 files changed

+214
-0
lines changed

2 files changed

+214
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: ClusterClass
4+
metadata:
5+
name: ${CLUSTER_CLASS_NAME}
6+
spec:
7+
controlPlane:
8+
ref:
9+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
10+
kind: KubeadmControlPlaneTemplate
11+
name: ${CLUSTER_CLASS_NAME}-control-plane
12+
machineInfrastructure:
13+
ref:
14+
kind: GCPMachineTemplate
15+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
16+
name: ${CLUSTER_CLASS_NAME}-control-plane
17+
infrastructure:
18+
ref:
19+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
20+
kind: GCPClusterTemplate
21+
name: ${CLUSTER_CLASS_NAME}
22+
workers:
23+
machineDeployments:
24+
- class: default-worker
25+
template:
26+
bootstrap:
27+
ref:
28+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
29+
kind: KubeadmConfigTemplate
30+
name: ${CLUSTER_CLASS_NAME}-worker-bootstraptemplate
31+
infrastructure:
32+
ref:
33+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
34+
kind: GCPMachineTemplate
35+
name: ${CLUSTER_CLASS_NAME}-worker-machinetemplate
36+
variables:
37+
- name: region
38+
required: true
39+
schema:
40+
openAPIV3Schema:
41+
type: string
42+
default: us-west1
43+
- name: controlPlaneMachineType
44+
required: true
45+
schema:
46+
openAPIV3Schema:
47+
type: string
48+
default: n1-standard-2
49+
- name: workerMachineType
50+
required: true
51+
schema:
52+
openAPIV3Schema:
53+
type: string
54+
default: n1-standard-2
55+
patches:
56+
- name: region
57+
definitions:
58+
- selector:
59+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
60+
kind: GCPClusterTemplate
61+
matchResources:
62+
infrastructureCluster: true
63+
jsonPatches:
64+
- op: add
65+
path: /spec/template/spec/region
66+
valueFrom:
67+
variable: region
68+
- name: controlPlaneMachineType
69+
definitions:
70+
- selector:
71+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
72+
kind: GCPMachineTemplate
73+
matchResources:
74+
controlPlane: true
75+
jsonPatches:
76+
- op: replace
77+
path: /spec/template/spec/instanceType
78+
valueFrom:
79+
variable: controlPlaneMachineType
80+
- name: workerMachineType
81+
definitions:
82+
- selector:
83+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
84+
kind: GCPMachineTemplate
85+
matchResources:
86+
machineDeploymentClass:
87+
names:
88+
- default-worker
89+
jsonPatches:
90+
- op: replace
91+
path: /spec/template/spec/instanceType
92+
valueFrom:
93+
variable: workerMachineType
94+
---
95+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
96+
kind: GCPClusterTemplate
97+
metadata:
98+
name: ${CLUSTER_CLASS_NAME}
99+
spec:
100+
template:
101+
spec:
102+
project: "${GCP_PROJECT}"
103+
region: "${GCP_REGION}"
104+
network:
105+
name: "${GCP_NETWORK_NAME}"
106+
---
107+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
108+
kind: KubeadmControlPlaneTemplate
109+
metadata:
110+
name: ${CLUSTER_CLASS_NAME}-control-plane
111+
spec:
112+
template:
113+
spec:
114+
kubeadmConfigSpec:
115+
useExperimentalRetryJoin: true
116+
initConfiguration:
117+
nodeRegistration:
118+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
119+
kubeletExtraArgs:
120+
cloud-provider: gce
121+
clusterConfiguration:
122+
apiServer:
123+
timeoutForControlPlane: 20m
124+
extraArgs:
125+
cloud-provider: gce
126+
controllerManager:
127+
extraArgs:
128+
cloud-provider: gce
129+
allocate-node-cidrs: "false"
130+
joinConfiguration:
131+
nodeRegistration:
132+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
133+
kubeletExtraArgs:
134+
cloud-provider: gce
135+
---
136+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
137+
kind: GCPMachineTemplate
138+
metadata:
139+
name: ${CLUSTER_CLASS_NAME}-control-plane
140+
spec:
141+
template:
142+
spec:
143+
instanceType: REPLACEME
144+
image: "${IMAGE_ID}"
145+
---
146+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
147+
kind: GCPMachineTemplate
148+
metadata:
149+
name: ${CLUSTER_CLASS_NAME}-worker-machinetemplate
150+
spec:
151+
template:
152+
spec:
153+
instanceType: REPLACEME
154+
image: "${IMAGE_ID}"
155+
---
156+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
157+
kind: KubeadmConfigTemplate
158+
metadata:
159+
name: ${CLUSTER_CLASS_NAME}-worker-bootstraptemplate
160+
spec:
161+
template:
162+
spec:
163+
joinConfiguration:
164+
nodeRegistration:
165+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
166+
kubeletExtraArgs:
167+
cloud-provider: gce
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: "${CLUSTER_NAME}"
6+
labels:
7+
cni: "${CLUSTER_NAME}-crs-cni"
8+
spec:
9+
clusterNetwork:
10+
pods:
11+
cidrBlocks: ["192.168.0.0/16"]
12+
topology:
13+
class: ${CLUSTER_CLASS_NAME}
14+
version: "${KUBERNETES_VERSION}"
15+
controlPlane:
16+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
17+
workers:
18+
machineDeployments:
19+
- class: "default-worker"
20+
name: "md-0"
21+
replicas: ${WORKER_MACHINE_COUNT}
22+
variables:
23+
- name: region
24+
value: ${GCP_REGION}
25+
- name: controlPlaneMachineType
26+
value: ${GCP_CONTROL_PLANE_MACHINE_TYPE}
27+
- name: workerMachineType
28+
value: ${GCP_NODE_MACHINE_TYPE}
29+
---
30+
apiVersion: v1
31+
kind: ConfigMap
32+
metadata:
33+
name: "${CLUSTER_NAME}-crs-cni"
34+
data: ${CNI_RESOURCES}
35+
---
36+
apiVersion: addons.cluster.x-k8s.io/v1beta1
37+
kind: ClusterResourceSet
38+
metadata:
39+
name: "${CLUSTER_NAME}-crs-cni"
40+
spec:
41+
strategy: ApplyOnce
42+
clusterSelector:
43+
matchLabels:
44+
cni: "${CLUSTER_NAME}-crs-cni"
45+
resources:
46+
- name: "${CLUSTER_NAME}-crs-cni"
47+
kind: ConfigMap

0 commit comments

Comments
 (0)