Closed farodin91 closed 4 months ago
Check out this example from Cluster API
You seem to be missing a couple of things, e.g. clusterclass.spec.workers
Have you been able to create different cluster with different configurations from your ClusterClass template? If yes can you maybe provide some docs on how you did it?
I've checked out your branch, because I have never used ClusterClass before and wanted to test it. I couldn't really figure out how to do it, therefore I dived a bit into the documentation.
If I'm not wrong here, you are mixing up multiple things. We need to work with JSON patches.
jsonPatches:
- op: add
path: /spec/template....
valueFrom:
variable: xxxx
Therefore, you cannot have environment variables in the clusterclass template
(except for maybe CLUSTER_CLASS_NAME and NAMESPACE, used with clusterctl generate yaml
)
e.g.
Instead of:
kind: IonosCloudMachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
metadata:
name: "${CLUSTER_CLASS_NAME}-template"
namespace: '${NAMESPACE}'
spec:
template:
spec:
numCores: ${IONOSCLOUD_MACHINE_NUM_CORES}
memoryMB: ${IONOSCLOUD_MACHINE_MEMORY_MB}
disk:
image:
id: ${IONOSCLOUD_MACHINE_IMAGE_ID}
You would then need a patch for that. Something like
kind: IonosCloudMachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
metadata:
name: "${CLUSTER_CLASS_NAME}-template"
namespace: '${NAMESPACE}'
spec:
template: {}
...
patches:
- name: workerMachineType
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: IonosCloudMachineTemplate
matchResources:
machineDeploymentClass:
names:
- XXXX
jsonPatches:
- op: add
path: /spec/template/spec/numCores
valueFrom:
variable: numCPUs
- op: add
path: /spec/template/spec/memoryMB
valueFrom:
variable: memoryMB
- op: add
path: /spec/template/spec/disk/image/id
valueFrom:
variable: imageID
...
I've added a fixed some values and added a bash script for basic testing.
Followup PRs can add:
@lubedacht Everything should be fixed.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
1.5% Duplication on New Code
What is the purpose of this pull request/Why do we need it?
Issue #, if available:
Description of changes:
Special notes for your reviewer:
Checklist: