Skip to content

Commit c278953

Browse files
authored
ROSAMachinePool: support for capacity reservations (#5649)
1 parent 8607e3a commit c278953

File tree

8 files changed

+30
-5
lines changed

8 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 and Capacity Blocks for ML.
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
@@ -119,6 +119,12 @@ type RosaMachinePoolSpec struct {
119119
//
120120
// +optional
121121
UpdateConfig *RosaUpdateConfig `json:"updateConfig,omitempty"`
122+
123+
// CapacityReservationID specifies the ID of an AWS On-Demand Capacity Reservation and Capacity Blocks for ML.
124+
// The CapacityReservationID must be pre-created in advance, before creating a NodePool.
125+
//
126+
// +optional
127+
CapacityReservationID string `json:"capacityReservationID,omitempty"`
122128
}
123129

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

exp/controllers/rosamachinepool_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ func nodePoolBuilder(rosaMachinePoolSpec expinfrav1.RosaMachinePoolSpec, machine
504504
if rosaMachinePoolSpec.VolumeSize > 75 {
505505
awsNodePool = awsNodePool.RootVolume(cmv1.NewAWSVolume().Size(rosaMachinePoolSpec.VolumeSize))
506506
}
507+
if rosaMachinePoolSpec.CapacityReservationID != "" {
508+
capacityReservation := cmv1.NewAWSCapacityReservation().Id(rosaMachinePoolSpec.CapacityReservationID)
509+
awsNodePool = awsNodePool.CapacityReservation(capacityReservation)
510+
}
507511
npBuilder.AWSNodePool(awsNodePool)
508512

509513
if rosaMachinePoolSpec.Version != "" {

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{

exp/utils/rosa_helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func NodePoolToRosaMachinePoolSpec(nodePool *cmv1.NodePool) expinfrav1.RosaMachi
4444
TuningConfigs: nodePool.TuningConfigs(),
4545
AdditionalSecurityGroups: nodePool.AWSNodePool().AdditionalSecurityGroupIds(),
4646
VolumeSize: nodePool.AWSNodePool().RootVolume().Size(),
47+
CapacityReservationID: nodePool.AWSNodePool().CapacityReservation().Id(),
4748
// nodePool.AWSNodePool().Tags() returns all tags including "system" tags if "fetchUserTagsOnly" parameter is not specified.
4849
// TODO: enable when AdditionalTags day2 changes is supported.
4950
// AdditionalTags: nodePool.AWSNodePool().Tags(),

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
@@ -495,10 +495,14 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
495495
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
496496
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
497497
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
498+
github.com/openshift-online/ocm-api-model/clientapi v0.0.431 h1:oGyJaX7ERZZVqVQBQD2OtmUcArsWl+97tXMcLTerbPo=
499+
github.com/openshift-online/ocm-api-model/clientapi v0.0.431/go.mod h1:fZwy5HY2URG9nrExvQeXrDU/08TGqZ16f8oymVEN5lo=
500+
github.com/openshift-online/ocm-api-model/model v0.0.431 h1:vIuELb0uH2AkN5LMQLYbLrdYIULMEK6ctQkbdoNbEZQ=
501+
github.com/openshift-online/ocm-api-model/model v0.0.431/go.mod h1:PQIoq6P8Vlb7goOdRMLK8nJY+B7HH0RTqYAa4kyidTE=
498502
github.com/openshift-online/ocm-common v0.0.29 h1:EyKoLvQXKOa3UpoWHT3cMyNHBbhSZURC8Ws/cxTaT1U=
499503
github.com/openshift-online/ocm-common v0.0.29/go.mod h1:VEkuZp9aqbXtetZ5ycND6QpvhykvTuBF3oPsVM1X3vI=
500-
github.com/openshift-online/ocm-sdk-go v0.1.465 h1:RZr92sdcAKyLVcL19/RYOn6KVtspDUH1wc3UuO4LgiE=
501-
github.com/openshift-online/ocm-sdk-go v0.1.465/go.mod h1:EOkylgH0bafd+SlU9YvMrIIxHJw0Hk1EnC7W1VZeW8I=
504+
github.com/openshift-online/ocm-sdk-go v0.1.476 h1:l5gp/QEqnocqM02m7pDeS9ndXcCTBamewVSGaymd88Y=
505+
github.com/openshift-online/ocm-sdk-go v0.1.476/go.mod h1:ds+aOAlQbiK0ubZP3CwXkzd7m48v6fMQ1ef9UCrjzBY=
502506
github.com/openshift/rosa v1.2.55 h1:Y6UD1474aExF4bZSh2KH4zE+Xl2NVsiuj3TLQGT9U+Y=
503507
github.com/openshift/rosa v1.2.55/go.mod h1:EE0yTEjbwxfnH/9YbQZaUXUVbIzfPa9KCRNw19QdLsw=
504508
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)