Skip to content

Commit b932828

Browse files
committed
ROSAMachinePool: support for capacity reservations
1 parent 60649f3 commit b932828

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

config/crd/bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ spec:
8888
AvailabilityZone is an optinal field specifying the availability zone where instances of this machine pool should run
8989
For Multi-AZ clusters, you can create a machine pool in a Single-AZ of your choice.
9090
type: string
91+
capacityReservationID:
92+
description: |-
93+
CapacityReservationId specifies the ID of an AWS On-Demand Capacity Reservation.
94+
The CapacityReservationId must be pre-created in advance, before creating a NodePool.
95+
type: string
9196
instanceType:
9297
description: InstanceType specifies the AWS instance type
9398
type: string

exp/api/v1beta2/rosamachinepool_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ type RosaMachinePoolSpec struct {
118118
//
119119
// +optional
120120
UpdateConfig *RosaUpdateConfig `json:"updateConfig,omitempty"`
121+
122+
// CapacityReservationId specifies the ID of an AWS On-Demand Capacity Reservation.
123+
// The CapacityReservationId must be pre-created in advance, before creating a NodePool.
124+
//
125+
// +optional
126+
CapacityReservationID string `json:"capacityReservationID,omitempty"`
121127
}
122128

123129
// RosaTaint represents a taint to be applied to a node.

exp/controllers/rosamachinepool_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,10 @@ func nodePoolBuilder(rosaMachinePoolSpec expinfrav1.RosaMachinePoolSpec, machine
492492
if rosaMachinePoolSpec.VolumeSize > 75 {
493493
awsNodePool = awsNodePool.RootVolume(cmv1.NewAWSVolume().Size(rosaMachinePoolSpec.VolumeSize))
494494
}
495+
if rosaMachinePoolSpec.CapacityReservationID != "" {
496+
capacityReservation := cmv1.NewAWSCapacityReservation().Id(rosaMachinePoolSpec.CapacityReservationID)
497+
awsNodePool = awsNodePool.CapacityReservation(capacityReservation)
498+
}
495499
npBuilder.AWSNodePool(awsNodePool)
496500

497501
if rosaMachinePoolSpec.Version != "" {
@@ -533,6 +537,7 @@ func nodePoolToRosaMachinePoolSpec(nodePool *cmv1.NodePool) expinfrav1.RosaMachi
533537
TuningConfigs: nodePool.TuningConfigs(),
534538
AdditionalSecurityGroups: nodePool.AWSNodePool().AdditionalSecurityGroupIds(),
535539
VolumeSize: nodePool.AWSNodePool().RootVolume().Size(),
540+
CapacityReservationID: nodePool.AWSNodePool().CapacityReservation().Id(),
536541
// nodePool.AWSNodePool().Tags() returns all tags including "system" tags if "fetchUserTagsOnly" parameter is not specified.
537542
// TODO: enable when AdditionalTags day2 changes is supported.
538543
// AdditionalTags: nodePool.AWSNodePool().Tags(),

exp/controllers/rosamachinepool_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func TestNodePoolToRosaMachinePoolSpec(t *testing.T) {
7070
Effect: corev1.TaintEffectNoExecute,
7171
},
7272
},
73+
CapacityReservationID: "capacity-reservation-id",
7374
}
7475

7576
machinePoolSpec := expclusterv1.MachinePoolSpec{

go.mod

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ require (
3939
github.com/google/gofuzz v1.2.0
4040
github.com/onsi/ginkgo/v2 v2.23.3
4141
github.com/onsi/gomega v1.36.3
42+
github.com/openshift-online/ocm-api-model/clientapi v0.0.431
4243
github.com/openshift-online/ocm-common v0.0.29
43-
github.com/openshift-online/ocm-sdk-go v0.1.465
44+
github.com/openshift-online/ocm-sdk-go v0.1.476
4445
github.com/openshift/rosa v1.2.55
4546
github.com/pkg/errors v0.9.1
4647
github.com/prometheus/client_golang v1.19.1
@@ -70,7 +71,10 @@ require (
7071
sigs.k8s.io/yaml v1.4.0
7172
)
7273

73-
require github.com/aws/aws-sdk-go v1.55.7 // indirect
74+
require (
75+
github.com/aws/aws-sdk-go v1.55.7 // indirect
76+
github.com/openshift-online/ocm-api-model/model v0.0.431 // indirect
77+
)
7478

7579
require (
7680
al.essio.dev/pkg/shellescape v1.5.1 // indirect

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,14 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
429429
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
430430
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
431431
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
432+
github.com/openshift-online/ocm-api-model/clientapi v0.0.431 h1:oGyJaX7ERZZVqVQBQD2OtmUcArsWl+97tXMcLTerbPo=
433+
github.com/openshift-online/ocm-api-model/clientapi v0.0.431/go.mod h1:fZwy5HY2URG9nrExvQeXrDU/08TGqZ16f8oymVEN5lo=
434+
github.com/openshift-online/ocm-api-model/model v0.0.431 h1:vIuELb0uH2AkN5LMQLYbLrdYIULMEK6ctQkbdoNbEZQ=
435+
github.com/openshift-online/ocm-api-model/model v0.0.431/go.mod h1:PQIoq6P8Vlb7goOdRMLK8nJY+B7HH0RTqYAa4kyidTE=
432436
github.com/openshift-online/ocm-common v0.0.29 h1:EyKoLvQXKOa3UpoWHT3cMyNHBbhSZURC8Ws/cxTaT1U=
433437
github.com/openshift-online/ocm-common v0.0.29/go.mod h1:VEkuZp9aqbXtetZ5ycND6QpvhykvTuBF3oPsVM1X3vI=
434-
github.com/openshift-online/ocm-sdk-go v0.1.465 h1:RZr92sdcAKyLVcL19/RYOn6KVtspDUH1wc3UuO4LgiE=
435-
github.com/openshift-online/ocm-sdk-go v0.1.465/go.mod h1:EOkylgH0bafd+SlU9YvMrIIxHJw0Hk1EnC7W1VZeW8I=
438+
github.com/openshift-online/ocm-sdk-go v0.1.476 h1:l5gp/QEqnocqM02m7pDeS9ndXcCTBamewVSGaymd88Y=
439+
github.com/openshift-online/ocm-sdk-go v0.1.476/go.mod h1:ds+aOAlQbiK0ubZP3CwXkzd7m48v6fMQ1ef9UCrjzBY=
436440
github.com/openshift/rosa v1.2.55 h1:Y6UD1474aExF4bZSh2KH4zE+Xl2NVsiuj3TLQGT9U+Y=
437441
github.com/openshift/rosa v1.2.55/go.mod h1:EE0yTEjbwxfnH/9YbQZaUXUVbIzfPa9KCRNw19QdLsw=
438442
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=

test/mocks/ocm_client_mock.go

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

0 commit comments

Comments
 (0)