Skip to content

Commit

Permalink
Merge pull request #1351 from salasberryfin/add-clusterclass-sample-t…
Browse files Browse the repository at this point in the history
…emplate

chore: add clusterclass sample template
  • Loading branch information
k8s-ci-robot authored Nov 5, 2024
2 parents 47ba457 + a05e175 commit 902e324
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 0 deletions.
167 changes: 167 additions & 0 deletions templates/cluster-template-clusterclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
metadata:
name: ${CLUSTER_CLASS_NAME}
spec:
controlPlane:
ref:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
name: ${CLUSTER_CLASS_NAME}-control-plane
machineInfrastructure:
ref:
kind: GCPMachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
name: ${CLUSTER_CLASS_NAME}-control-plane
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPClusterTemplate
name: ${CLUSTER_CLASS_NAME}
workers:
machineDeployments:
- class: default-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: ${CLUSTER_CLASS_NAME}-worker-bootstraptemplate
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
name: ${CLUSTER_CLASS_NAME}-worker-machinetemplate
variables:
- name: region
required: true
schema:
openAPIV3Schema:
type: string
default: us-west1
- name: controlPlaneMachineType
required: true
schema:
openAPIV3Schema:
type: string
default: n1-standard-2
- name: workerMachineType
required: true
schema:
openAPIV3Schema:
type: string
default: n1-standard-2
patches:
- name: region
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPClusterTemplate
matchResources:
infrastructureCluster: true
jsonPatches:
- op: add
path: /spec/template/spec/region
valueFrom:
variable: region
- name: controlPlaneMachineType
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
matchResources:
controlPlane: true
jsonPatches:
- op: replace
path: /spec/template/spec/instanceType
valueFrom:
variable: controlPlaneMachineType
- name: workerMachineType
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
matchResources:
machineDeploymentClass:
names:
- default-worker
jsonPatches:
- op: replace
path: /spec/template/spec/instanceType
valueFrom:
variable: workerMachineType
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPClusterTemplate
metadata:
name: ${CLUSTER_CLASS_NAME}
spec:
template:
spec:
project: "${GCP_PROJECT}"
region: "${GCP_REGION}"
network:
name: "${GCP_NETWORK_NAME}"
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
metadata:
name: ${CLUSTER_CLASS_NAME}-control-plane
spec:
template:
spec:
kubeadmConfigSpec:
useExperimentalRetryJoin: true
initConfiguration:
nodeRegistration:
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
kubeletExtraArgs:
cloud-provider: gce
clusterConfiguration:
apiServer:
timeoutForControlPlane: 20m
extraArgs:
cloud-provider: gce
controllerManager:
extraArgs:
cloud-provider: gce
allocate-node-cidrs: "false"
joinConfiguration:
nodeRegistration:
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
kubeletExtraArgs:
cloud-provider: gce
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
metadata:
name: ${CLUSTER_CLASS_NAME}-control-plane
spec:
template:
spec:
instanceType: REPLACEME
image: "${IMAGE_ID}"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
metadata:
name: ${CLUSTER_CLASS_NAME}-worker-machinetemplate
spec:
template:
spec:
instanceType: REPLACEME
image: "${IMAGE_ID}"
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: ${CLUSTER_CLASS_NAME}-worker-bootstraptemplate
spec:
template:
spec:
joinConfiguration:
nodeRegistration:
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
kubeletExtraArgs:
cloud-provider: gce
47 changes: 47 additions & 0 deletions templates/cluster-template-topology.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: "${CLUSTER_NAME}"
labels:
cni: "${CLUSTER_NAME}-crs-cni"
spec:
clusterNetwork:
pods:
cidrBlocks: ["192.168.0.0/16"]
topology:
class: ${CLUSTER_CLASS_NAME}
version: "${KUBERNETES_VERSION}"
controlPlane:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
workers:
machineDeployments:
- class: "default-worker"
name: "md-0"
replicas: ${WORKER_MACHINE_COUNT}
variables:
- name: region
value: ${GCP_REGION}
- name: controlPlaneMachineType
value: ${GCP_CONTROL_PLANE_MACHINE_TYPE}
- name: workerMachineType
value: ${GCP_NODE_MACHINE_TYPE}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: "${CLUSTER_NAME}-crs-cni"
data: ${CNI_RESOURCES}
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: "${CLUSTER_NAME}-crs-cni"
spec:
strategy: ApplyOnce
clusterSelector:
matchLabels:
cni: "${CLUSTER_NAME}-crs-cni"
resources:
- name: "${CLUSTER_NAME}-crs-cni"
kind: ConfigMap

0 comments on commit 902e324

Please sign in to comment.