Skip to content

Commit 4cfc105

Browse files
authored
Merge pull request #10701 from k8s-infra-cherrypick-robot/cherry-pick-10682-to-release-1.7
[release-1.7] ✨ Support ControlPlane variable overrides
2 parents a4b7cc3 + c6d1ef8 commit 4cfc105

16 files changed

+557
-42
lines changed

api/v1beta1/cluster_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ type ControlPlaneTopology struct {
142142
// Defaults to 10 seconds.
143143
// +optional
144144
NodeDeletionTimeout *metav1.Duration `json:"nodeDeletionTimeout,omitempty"`
145+
146+
// Variables can be used to customize the ControlPlane through patches.
147+
// +optional
148+
Variables *ControlPlaneVariables `json:"variables,omitempty"`
145149
}
146150

147151
// WorkersTopology represents the different sets of worker nodes in the cluster.
@@ -327,6 +331,13 @@ type ClusterVariable struct {
327331
Value apiextensionsv1.JSON `json:"value"`
328332
}
329333

334+
// ControlPlaneVariables can be used to provide variables for the ControlPlane.
335+
type ControlPlaneVariables struct {
336+
// Overrides can be used to override Cluster level variables.
337+
// +optional
338+
Overrides []ClusterVariable `json:"overrides,omitempty"`
339+
}
340+
330341
// MachineDeploymentVariables can be used to provide variables for a specific MachineDeployment.
331342
type MachineDeploymentVariables struct {
332343
// Overrides can be used to override Cluster level variables.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.openapi.go

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_clusters.yaml

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/apis/core/v1alpha4/conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error {
4242
dst.Spec.Topology = &clusterv1.Topology{}
4343
}
4444
dst.Spec.Topology.Variables = restored.Spec.Topology.Variables
45+
dst.Spec.Topology.ControlPlane.Variables = restored.Spec.Topology.ControlPlane.Variables
4546

4647
if restored.Spec.Topology.ControlPlane.MachineHealthCheck != nil {
4748
dst.Spec.Topology.ControlPlane.MachineHealthCheck = restored.Spec.Topology.ControlPlane.MachineHealthCheck

internal/apis/core/v1alpha4/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controllers/topology/cluster/cluster_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,9 @@ func TestReconciler_DefaultCluster(t *testing.T) {
13711371
WithVariables(
13721372
clusterv1.ClusterVariable{Name: "location", Value: apiextensionsv1.JSON{Raw: []byte(`"us-west"`)}},
13731373
clusterv1.ClusterVariable{Name: "httpProxy", Value: apiextensionsv1.JSON{Raw: []byte(`{"enabled":true}`)}}).
1374+
WithControlPlaneVariables(
1375+
clusterv1.ClusterVariable{Name: "location", Value: apiextensionsv1.JSON{Raw: []byte(`"us-west"`)}},
1376+
clusterv1.ClusterVariable{Name: "httpProxy", Value: apiextensionsv1.JSON{Raw: []byte(`{"enabled":true}`)}}).
13741377
WithMachineDeployment(mdTopologyBase.DeepCopy().
13751378
WithVariables(clusterv1.ClusterVariable{
13761379
Name: "httpProxy",
@@ -1388,6 +1391,9 @@ func TestReconciler_DefaultCluster(t *testing.T) {
13881391
WithVariables(
13891392
clusterv1.ClusterVariable{Name: "location", Value: apiextensionsv1.JSON{Raw: []byte(`"us-west"`)}},
13901393
clusterv1.ClusterVariable{Name: "httpProxy", Value: apiextensionsv1.JSON{Raw: []byte(`{"enabled":true,"url":"http://localhost:3128"}`)}}).
1394+
WithControlPlaneVariables(
1395+
clusterv1.ClusterVariable{Name: "location", Value: apiextensionsv1.JSON{Raw: []byte(`"us-west"`)}},
1396+
clusterv1.ClusterVariable{Name: "httpProxy", Value: apiextensionsv1.JSON{Raw: []byte(`{"enabled":true,"url":"http://localhost:3128"}`)}}).
13911397
WithMachineDeployment(
13921398
mdTopologyBase.DeepCopy().WithVariables(
13931399
clusterv1.ClusterVariable{

internal/controllers/topology/cluster/patches/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func addVariablesForPatch(blueprint *scope.ClusterBlueprint, desired *scope.Clus
165165
req.Variables = globalVariables
166166

167167
// Calculate the Control Plane variables.
168-
controlPlaneVariables, err := variables.ControlPlane(&blueprint.Topology.ControlPlane, desired.ControlPlane.Object, desired.ControlPlane.InfrastructureMachineTemplate)
168+
controlPlaneVariables, err := variables.ControlPlane(&blueprint.Topology.ControlPlane, desired.ControlPlane.Object, desired.ControlPlane.InfrastructureMachineTemplate, definitionFrom, patchVariableDefinitions)
169169
if err != nil {
170170
return errors.Wrapf(err, "failed to calculate ControlPlane variables")
171171
}

0 commit comments

Comments
 (0)