@@ -3,9 +3,10 @@ package register
33import (
44 "context"
55 "fmt"
6- "github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/openshift-cluster/openshiftclustercmdutil"
76 "strings"
87
8+ "github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/openshift-cluster/openshiftclustercmdutil"
9+
910 "github.com/redhat-developer/app-services-cli/internal/build"
1011 "github.com/redhat-developer/app-services-cli/pkg/core/cmdutil"
1112 "github.com/redhat-developer/app-services-cli/pkg/core/config"
@@ -37,19 +38,25 @@ type options struct {
3738
3839// list of consts should come from KFM
3940const (
40- machinePoolId = "kafka-standard"
41- machinePoolTaintKey = "bf2.org/kafkaInstanceProfileType"
42- machinePoolTaintEffect = "NoExecute"
43- machinePoolTaintValue = "standard"
44- machinePoolInstanceType = "r5.xlarge"
45- machinePoolLabelKey = "bf2.org/kafkaInstanceProfileType"
46- machinePoolLabelValue = "standard"
47- fleetshardAddonId = "kas-fleetshard-operator"
48- strimziAddonId = "managed-kafka"
49- fleetshardAddonIdQE = "kas-fleetshard-operator-qe"
50- strimziAddonIdQE = "managed-kafka-qe"
41+ aws = "aws"
42+ gcp = "gcp"
43+ machinePoolId = "kafka-standard"
44+ machinePoolTaintKey = "bf2.org/kafkaInstanceProfileType"
45+ machinePoolTaintEffect = "NoExecute"
46+ machinePoolTaintValue = "standard"
47+ machinePoolLabelKey = "bf2.org/kafkaInstanceProfileType"
48+ machinePoolLabelValue = "standard"
49+ fleetshardAddonId = "kas-fleetshard-operator"
50+ strimziAddonId = "managed-kafka"
51+ fleetshardAddonIdQE = "kas-fleetshard-operator-qe"
52+ strimziAddonIdQE = "managed-kafka-qe"
5153)
5254
55+ var kafkaMachinePoolMachineTypesPerCloudProvider = map [string ]string {
56+ aws : "r5.xlarge" ,
57+ gcp : "custom-4-32768-ext" ,
58+ }
59+
5360func NewRegisterClusterCommand (f * factory.Factory ) * cobra.Command {
5461 opts := & options {
5562 f : f ,
@@ -174,9 +181,7 @@ func setOrCreateMachinePoolList(opts *options) error {
174181 return err
175182 }
176183 } else {
177- for _ , machinePool := range response .Items ().Slice () {
178- opts .existingMachinePoolList = append (opts .existingMachinePoolList , machinePool )
179- }
184+ opts .existingMachinePoolList = append (opts .existingMachinePoolList , response .Items ().Slice ()... )
180185 err = validateMachinePoolNodes (opts )
181186 if err != nil {
182187 return err
@@ -228,11 +233,16 @@ func createNewMachinePoolLabelsDedicated() map[string]string {
228233}
229234
230235// TO-DO create an autoscaling machine pool
231- func createMachinePoolRequestForDedicated (machinePoolNodeCount int ) (* clustersmgmtv1.MachinePool , error ) {
236+ func createMachinePoolRequestForDedicated (machinePoolNodeCount int , cloudProvider string ) (* clustersmgmtv1.MachinePool , error ) {
237+ machineType , ok := kafkaMachinePoolMachineTypesPerCloudProvider [cloudProvider ]
238+ if ! ok {
239+ return nil , fmt .Errorf ("unsupported %q cloud provider" , cloudProvider )
240+ }
241+
232242 mp := clustersmgmtv1 .NewMachinePool ()
233243 mp .ID (machinePoolId ).
234244 Replicas (machinePoolNodeCount ).
235- InstanceType (machinePoolInstanceType ).
245+ InstanceType (machineType ).
236246 Labels (createNewMachinePoolLabelsDedicated ()).
237247 Taints (createNewMachinePoolTaintsDedicated ())
238248 machinePool , err := mp .Build ()
@@ -258,7 +268,8 @@ func createMachinePoolInteractivePrompt(opts *options) error {
258268 return err
259269 }
260270 opts .requestedMachinePoolNodeCount = nodeCount
261- dedicatedMachinePool , err := createMachinePoolRequestForDedicated (nodeCount )
271+ cloudProvider := opts .selectedCluster .CloudProvider ().ID ()
272+ dedicatedMachinePool , err := createMachinePoolRequestForDedicated (nodeCount , cloudProvider )
262273 if err != nil {
263274 return err
264275 }
0 commit comments