Skip to content

Commit

Permalink
Add Azure ClusterClass
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Mazzotti <[email protected]>
  • Loading branch information
anmazzotti committed Feb 27, 2025
1 parent 35df666 commit 311a78a
Show file tree
Hide file tree
Showing 2 changed files with 801 additions and 0 deletions.
338 changes: 338 additions & 0 deletions examples/clusterclasses/clusterclass-azure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
metadata:
name: azure-example
spec:
controlPlane:
ref:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: RKE2ControlPlaneTemplate
name: rke2-control-plane
machineInfrastructure:
ref:
kind: AzureMachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
name: rke2-control-plane
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterTemplate
name: azure-cluster
workers:
machineDeployments:
- class: rke2-default-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
name: rke2-default-worker-bootstrap
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: rke2-default-worker
machinePools:
- class: rke2-default-machinepool-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
name: rke2-default-worker-bootstrap
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachinePool
name: rke2-default-machinepool-worker
variables:
- name: subscriptionID
required: true
schema:
openAPIV3Schema:
description: "The Azure Subscription ID where the Cluster will be created."
type: string
- name: location
required: true
schema:
openAPIV3Schema:
description: "The Azure location where the Cluster will be created."
type: string
enum:
- eastus
- eastus2
- southcentralus
- westus2
- westus3
- australiaeast
- southeastasia
- northeurope
- swedencentral
- uksouth
- westeurope
- centralus
- southafricanorth
- centralindia
- eastasia
- japaneast
- koreacentral
- canadacentral
- francecentral
- germanywestcentral
- italynorth
- norwayeast
- polandcentral
- spaincentral
- switzerlandnorth
- mexicocentral
- uaenorth
- brazilsouth
- israelcentral
- qatarcentral
- name: resourceGroup
required: true
schema:
openAPIV3Schema:
description: "The Azure Resource Group where the Cluster will be created."
type: string
- name: azureClusterIdentityName
required: true
schema:
openAPIV3Schema:
description: "The AzureClusterIdentity resource name referencing the credentials to create the Cluster."
type: string
- name: imageGallery
required: true
schema:
openAPIV3Schema:
description: "The image Public gallery name."
type: string
default: "ClusterAPI-f72ceb4f-5159-4c26-a0fe-2ea738f0d019"
- name: imageName
required: true
schema:
openAPIV3Schema:
description: "The image name"
type: string
default: "capi-ubun2-2404"
- name: imageVersion
required: true
schema:
openAPIV3Schema:
description: "The version of the image."
type: string
default: "1.31.1"
example: "latest"
- name: vmSize
required: true
schema:
openAPIV3Schema:
description: "The VM size used by machines."
type: string
default: "Standard_D2s_v3"
patches:
- name: azureClusterTemplate
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterTemplate
matchResources:
infrastructureCluster: true
jsonPatches:
- op: add
path: "/spec/template/spec/subscriptionID"
valueFrom:
variable: subscriptionID
- op: add
path: "/spec/template/spec/location"
valueFrom:
variable: location
- op: add
path: "/spec/template/spec/resourceGroup"
valueFrom:
variable: resourceGroup
- op: add
path: "/spec/template/spec/identityRef/name"
valueFrom:
variable: azureClusterIdentityName
# Builtins
- op: add
path: "/spec/template/spec/vnet/name"
valueFrom:
variable: builtin.cluster.name
- name: azureClusterTemplate
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterTemplate
matchResources:
infrastructureCluster: true
jsonPatches:
- op: add
path: "/spec/template/spec/subscriptionID"
valueFrom:
variable: subscriptionID
- op: add
path: "/spec/template/spec/location"
valueFrom:
variable: location
- op: add
path: "/spec/template/spec/resourceGroup"
valueFrom:
variable: resourceGroup
- op: add
path: "/spec/template/spec/identityRef/name"
valueFrom:
variable: azureClusterIdentityName
# Builtins
- op: add
path: "/spec/template/spec/vnet/name"
valueFrom:
variable: builtin.cluster.name
- name: azureMachineTemplate
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
matchResources:
controlPlane: true
machineDeploymentClass:
names:
- rke2-default-worker
jsonPatches:
- op: add
path: "/spec/template/spec/image/computeGallery/gallery"
valueFrom:
variable: imageGallery
- op: add
path: "/spec/template/spec/image/computeGallery/name"
valueFrom:
variable: imageName
- op: add
path: "/spec/template/spec/image/computeGallery/version"
valueFrom:
variable: imageVersion
- op: add
path: "/spec/template/spec/vmSize"
valueFrom:
variable: vmSize
- name: azureMachinePool
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachinePool
matchResources:
machinePoolClass:
names:
- rke2-default-machinepool-worker
jsonPatches:
- op: add
path: "/spec/template/image/computeGallery/gallery"
valueFrom:
variable: imageGallery
- op: add
path: "/spec/template/image/computeGallery/name"
valueFrom:
variable: imageName
- op: add
path: "/spec/template/image/computeGallery/version"
valueFrom:
variable: imageVersion
- op: add
path: "/spec/template/vmSize"
valueFrom:
variable: vmSize
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
metadata:
name: rke2-default-worker-bootstrap
spec:
template:
spec: {}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterTemplate
metadata:
name: azure-cluster
spec:
template:
spec:
identityRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
name: cluster-identity
networkSpec:
subnets:
- name: control-plane-subnet
role: control-plane
- name: node-subnet
role: node
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: RKE2ControlPlaneTemplate
metadata:
name: rke2-control-plane
namespace: default
spec:
template:
spec:
registrationMethod: internal-first
rolloutStrategy:
type: "RollingUpdate"
rollingUpdate:
maxSurge: 1
agentConfig: {}
serverConfig:
cloudProviderName: external
disableComponents:
kubernetesComponents:
- cloudController
kubeAPIServer:
extraArgs:
- --anonymous-auth=true
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: rke2-control-plane
namespace: default
spec:
template:
spec:
image:
computeGallery: {}
osDisk:
diskSizeGB: 128
osType: Linux
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: rke2-default-worker
spec:
template:
spec:
image:
computeGallery: {}
osDisk:
diskSizeGB: 30
osType: Linux
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachinePool
metadata:
name: rke2-default-machinepool-worker
spec:
strategy:
rollingUpdate:
deletePolicy: Oldest
maxSurge: 25%
maxUnavailable: 1
type: RollingUpdate
template:
image:
computeGallery: {}
osDisk:
diskSizeGB: 30
osType: Linux
Loading

0 comments on commit 311a78a

Please sign in to comment.