diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml index e6a27a9ddf..ac3b271d8a 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml @@ -88,6 +88,11 @@ spec: AvailabilityZone is an optinal field specifying the availability zone where instances of this machine pool should run For Multi-AZ clusters, you can create a machine pool in a Single-AZ of your choice. type: string + capacityReservationID: + description: |- + CapacityReservationID specifies the ID of an AWS On-Demand Capacity Reservation. + The CapacityReservationID must be pre-created in advance, before creating a NodePool. + type: string instanceType: description: InstanceType specifies the AWS instance type type: string diff --git a/exp/api/v1beta2/rosamachinepool_types.go b/exp/api/v1beta2/rosamachinepool_types.go index 0dc3af30ed..cae6f32f43 100644 --- a/exp/api/v1beta2/rosamachinepool_types.go +++ b/exp/api/v1beta2/rosamachinepool_types.go @@ -118,6 +118,12 @@ type RosaMachinePoolSpec struct { // // +optional UpdateConfig *RosaUpdateConfig `json:"updateConfig,omitempty"` + + // CapacityReservationID specifies the ID of an AWS On-Demand Capacity Reservation. + // The CapacityReservationID must be pre-created in advance, before creating a NodePool. + // + // +optional + CapacityReservationID string `json:"capacityReservationID,omitempty"` } // RosaTaint represents a taint to be applied to a node. diff --git a/exp/controllers/rosamachinepool_controller.go b/exp/controllers/rosamachinepool_controller.go index 9aebd92622..f02110050b 100644 --- a/exp/controllers/rosamachinepool_controller.go +++ b/exp/controllers/rosamachinepool_controller.go @@ -504,6 +504,10 @@ func nodePoolBuilder(rosaMachinePoolSpec expinfrav1.RosaMachinePoolSpec, machine if rosaMachinePoolSpec.VolumeSize > 75 { awsNodePool = awsNodePool.RootVolume(cmv1.NewAWSVolume().Size(rosaMachinePoolSpec.VolumeSize)) } + if rosaMachinePoolSpec.CapacityReservationID != "" { + capacityReservation := cmv1.NewAWSCapacityReservation().Id(rosaMachinePoolSpec.CapacityReservationID) + awsNodePool = awsNodePool.CapacityReservation(capacityReservation) + } npBuilder.AWSNodePool(awsNodePool) if rosaMachinePoolSpec.Version != "" { diff --git a/exp/controllers/rosamachinepool_controller_test.go b/exp/controllers/rosamachinepool_controller_test.go index 553cc38922..18a297a9bd 100644 --- a/exp/controllers/rosamachinepool_controller_test.go +++ b/exp/controllers/rosamachinepool_controller_test.go @@ -70,6 +70,7 @@ func TestNodePoolToRosaMachinePoolSpec(t *testing.T) { Effect: corev1.TaintEffectNoExecute, }, }, + CapacityReservationID: "capacity-reservation-id", } machinePoolSpec := expclusterv1.MachinePoolSpec{ diff --git a/exp/utils/rosa_helper.go b/exp/utils/rosa_helper.go index fc08747874..c46497654d 100644 --- a/exp/utils/rosa_helper.go +++ b/exp/utils/rosa_helper.go @@ -43,6 +43,7 @@ func NodePoolToRosaMachinePoolSpec(nodePool *cmv1.NodePool) expinfrav1.RosaMachi TuningConfigs: nodePool.TuningConfigs(), AdditionalSecurityGroups: nodePool.AWSNodePool().AdditionalSecurityGroupIds(), VolumeSize: nodePool.AWSNodePool().RootVolume().Size(), + CapacityReservationID: nodePool.AWSNodePool().CapacityReservation().Id(), // nodePool.AWSNodePool().Tags() returns all tags including "system" tags if "fetchUserTagsOnly" parameter is not specified. // TODO: enable when AdditionalTags day2 changes is supported. // AdditionalTags: nodePool.AWSNodePool().Tags(), diff --git a/go.mod b/go.mod index 1ffc472259..0aec94db6a 100644 --- a/go.mod +++ b/go.mod @@ -39,8 +39,9 @@ require ( github.com/google/gofuzz v1.2.0 github.com/onsi/ginkgo/v2 v2.23.3 github.com/onsi/gomega v1.36.3 + github.com/openshift-online/ocm-api-model/clientapi v0.0.431 github.com/openshift-online/ocm-common v0.0.29 - github.com/openshift-online/ocm-sdk-go v0.1.465 + github.com/openshift-online/ocm-sdk-go v0.1.476 github.com/openshift/rosa v1.2.55 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.19.1 @@ -70,7 +71,10 @@ require ( sigs.k8s.io/yaml v1.4.0 ) -require github.com/aws/aws-sdk-go v1.55.7 // indirect +require ( + github.com/aws/aws-sdk-go v1.55.7 // indirect + github.com/openshift-online/ocm-api-model/model v0.0.431 // indirect +) require ( al.essio.dev/pkg/shellescape v1.5.1 // indirect diff --git a/go.sum b/go.sum index 61860ee4e4..345cfe8cb2 100644 --- a/go.sum +++ b/go.sum @@ -429,10 +429,14 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/openshift-online/ocm-api-model/clientapi v0.0.431 h1:oGyJaX7ERZZVqVQBQD2OtmUcArsWl+97tXMcLTerbPo= +github.com/openshift-online/ocm-api-model/clientapi v0.0.431/go.mod h1:fZwy5HY2URG9nrExvQeXrDU/08TGqZ16f8oymVEN5lo= +github.com/openshift-online/ocm-api-model/model v0.0.431 h1:vIuELb0uH2AkN5LMQLYbLrdYIULMEK6ctQkbdoNbEZQ= +github.com/openshift-online/ocm-api-model/model v0.0.431/go.mod h1:PQIoq6P8Vlb7goOdRMLK8nJY+B7HH0RTqYAa4kyidTE= github.com/openshift-online/ocm-common v0.0.29 h1:EyKoLvQXKOa3UpoWHT3cMyNHBbhSZURC8Ws/cxTaT1U= github.com/openshift-online/ocm-common v0.0.29/go.mod h1:VEkuZp9aqbXtetZ5ycND6QpvhykvTuBF3oPsVM1X3vI= -github.com/openshift-online/ocm-sdk-go v0.1.465 h1:RZr92sdcAKyLVcL19/RYOn6KVtspDUH1wc3UuO4LgiE= -github.com/openshift-online/ocm-sdk-go v0.1.465/go.mod h1:EOkylgH0bafd+SlU9YvMrIIxHJw0Hk1EnC7W1VZeW8I= +github.com/openshift-online/ocm-sdk-go v0.1.476 h1:l5gp/QEqnocqM02m7pDeS9ndXcCTBamewVSGaymd88Y= +github.com/openshift-online/ocm-sdk-go v0.1.476/go.mod h1:ds+aOAlQbiK0ubZP3CwXkzd7m48v6fMQ1ef9UCrjzBY= github.com/openshift/rosa v1.2.55 h1:Y6UD1474aExF4bZSh2KH4zE+Xl2NVsiuj3TLQGT9U+Y= github.com/openshift/rosa v1.2.55/go.mod h1:EE0yTEjbwxfnH/9YbQZaUXUVbIzfPa9KCRNw19QdLsw= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= diff --git a/test/mocks/ocm_client_mock.go b/test/mocks/ocm_client_mock.go index 38da1767aa..5e0e17f12a 100644 --- a/test/mocks/ocm_client_mock.go +++ b/test/mocks/ocm_client_mock.go @@ -24,7 +24,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1" + v1 "github.com/openshift-online/ocm-api-model/clientapi/clustersmgmt/v1" aws "github.com/openshift/rosa/pkg/aws" ocm "github.com/openshift/rosa/pkg/ocm" )