From c8067510b67eee39f4e4a813f69dd7d2c3d002ce Mon Sep 17 00:00:00 2001 From: Stephan Feurer Date: Wed, 19 Jun 2024 09:05:48 +0200 Subject: [PATCH 1/2] Use seperate defaultSpecs for ControlPlaneMachineSet --- class/defaults.yml | 37 +++++++++++++++++++ component/machine-sets.jsonnet | 12 +----- .../ROOT/pages/references/parameters.adoc | 11 ++++++ 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/class/defaults.yml b/class/defaults.yml index e498793..6969b14 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -4,6 +4,7 @@ parameters: projectName: none infrastructureID: none defaultSpecs: + vsphere: {} aws: {} azure: {} gcp: @@ -42,6 +43,42 @@ parameters: tags: [] userDataSecret: name: worker-user-data + cpDefaultSpecs: + vsphere: {} + aws: {} + azure: {} + gcp: + template: + machines_v1beta1_machine_openshift_io: + spec: + providerSpec: + value: + apiVersion: gcpprovider.openshift.io/v1beta1 + canIPForward: false + credentialsSecret: + name: gcp-cloud-credentials + deletionProtection: false + disks: + - autoDelete: true + boot: true + image: ${openshift4_nodes:infrastructureID}-rhcos-image + labels: null + sizeGb: 128 + type: pd-ssd + kind: GCPMachineProviderSpec + metadata: + creationTimestamp: null + networkInterfaces: + - network: ${openshift4_nodes:infrastructureID}-network + subnetwork: ${openshift4_nodes:infrastructureID}-worker-subnet + projectID: ${openshift4_nodes:projectName} + region: ${facts:region} + serviceAccounts: + - email: ${openshift4_nodes:infrastructureID}-w@${openshift4_nodes:projectName}.iam.gserviceaccount.com + scopes: + - https://www.googleapis.com/auth/cloud-platform + userDataSecret: + name: master-user-data nodeConfig: cgroupMode: v1 diff --git a/component/machine-sets.jsonnet b/component/machine-sets.jsonnet index 06084fc..bc8f700 100644 --- a/component/machine-sets.jsonnet +++ b/component/machine-sets.jsonnet @@ -58,17 +58,7 @@ local machineSetSpecs = function(name, set, role) local cpMachineSetSpecs = function(set) kube._Object('machine.openshift.io/v1', 'ControlPlaneMachineSet', 'cluster') { - spec+: { - template+: { - machines_v1beta1_machine_openshift_io: { - spec+: { - providerSpec+: { - value+: params.defaultSpecs[inv.parameters.facts.cloud].template.spec.providerSpec.value, - }, - }, - }, - }, - }, + spec+: params.cpDefaultSpecs[inv.parameters.facts.cloud], } + { metadata+: { annotations+: std.get(set, 'annotations', {}), diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index 5662932..22c73c4 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -39,6 +39,17 @@ A dictionary holding the default values applied to each `machinesets.machine.ope The top level keys are the names of cloud providers as reported by the cluster fact `${facts:cloud}`. The values can be everything that's accepted in the `spec` field of a `machinesets.machine.openshift.io` object. +== `cpDefaultSpecs` + +[horizontal] +type:: dictionary +default:: Sensible defaults for a growing number of cloud providers. + +A dictionary holding the default values applied to each `controlplanemachinesets.machine.openshift.io` object created by this component. + +The top level keys are the names of cloud providers as reported by the cluster fact `${facts:cloud}`. +The values can be everything that's accepted in the `spec` field of a `controlplanemachinesets.machine.openshift.io` object. + == `infrastructureID` [horizontal] From 88447b3a15514d1f23739ba2db43db2fee2a650e Mon Sep 17 00:00:00 2001 From: DebakelOrakel <78408921+DebakelOrakel@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:22:53 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Simon Gerber --- class/defaults.yml | 2 +- component/machine-sets.jsonnet | 2 +- docs/modules/ROOT/pages/references/parameters.adoc | 2 +- .../openshift4-nodes/openshift4-nodes/machineset-master.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/class/defaults.yml b/class/defaults.yml index 6969b14..650cef7 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -43,7 +43,7 @@ parameters: tags: [] userDataSecret: name: worker-user-data - cpDefaultSpecs: + controlPlaneDefaultSpecs: vsphere: {} aws: {} azure: {} diff --git a/component/machine-sets.jsonnet b/component/machine-sets.jsonnet index bc8f700..9eea1df 100644 --- a/component/machine-sets.jsonnet +++ b/component/machine-sets.jsonnet @@ -58,7 +58,7 @@ local machineSetSpecs = function(name, set, role) local cpMachineSetSpecs = function(set) kube._Object('machine.openshift.io/v1', 'ControlPlaneMachineSet', 'cluster') { - spec+: params.cpDefaultSpecs[inv.parameters.facts.cloud], + spec+: params.controlPlaneDefaultSpecs[inv.parameters.facts.cloud], } + { metadata+: { annotations+: std.get(set, 'annotations', {}), diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index 22c73c4..06c9b52 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -39,7 +39,7 @@ A dictionary holding the default values applied to each `machinesets.machine.ope The top level keys are the names of cloud providers as reported by the cluster fact `${facts:cloud}`. The values can be everything that's accepted in the `spec` field of a `machinesets.machine.openshift.io` object. -== `cpDefaultSpecs` +== `controlPlaneDefaultSpecs` [horizontal] type:: dictionary diff --git a/tests/golden/gcp/openshift4-nodes/openshift4-nodes/machineset-master.yaml b/tests/golden/gcp/openshift4-nodes/openshift4-nodes/machineset-master.yaml index 91966fd..38377f1 100644 --- a/tests/golden/gcp/openshift4-nodes/openshift4-nodes/machineset-master.yaml +++ b/tests/golden/gcp/openshift4-nodes/openshift4-nodes/machineset-master.yaml @@ -57,5 +57,5 @@ spec: tags: - infra-id-master userDataSecret: - name: worker-user-data + name: master-user-data zone: europe-west6-a