diff --git a/cloud/scope/cluster.go b/cloud/scope/cluster.go index be52150398..e4f0b20351 100644 --- a/cloud/scope/cluster.go +++ b/cloud/scope/cluster.go @@ -221,10 +221,13 @@ func (s *ClusterScope) CreateSubnet() (*vpcv1.Subnet, error) { Zone: &vpcv1.ZoneIdentity{ Name: &s.IBMVPCCluster.Spec.Zone, }, + ResourceGroup: &vpcv1.ResourceGroupIdentity{ + ID: &s.IBMVPCCluster.Spec.ResourceGroup, + }, }) subnet, _, err := s.IBMVPCClients.VPCService.CreateSubnet(options) if subnet != nil { - pgw, err := s.createPublicGateWay(s.IBMVPCCluster.Status.VPC.ID, s.IBMVPCCluster.Spec.Zone) + pgw, err := s.createPublicGateWay(s.IBMVPCCluster.Status.VPC.ID, s.IBMVPCCluster.Spec.Zone, s.IBMVPCCluster.Spec.ResourceGroup) if err != nil { return subnet, err } @@ -295,7 +298,7 @@ func (s *ClusterScope) DeleteSubnet() error { return err } -func (s *ClusterScope) createPublicGateWay(vpcID string, zoneName string) (*vpcv1.PublicGateway, error) { +func (s *ClusterScope) createPublicGateWay(vpcID string, zoneName string, resourceGroupID string) (*vpcv1.PublicGateway, error) { options := &vpcv1.CreatePublicGatewayOptions{} options.SetVPC(&vpcv1.VPCIdentity{ ID: &vpcID, @@ -303,6 +306,9 @@ func (s *ClusterScope) createPublicGateWay(vpcID string, zoneName string) (*vpcv options.SetZone(&vpcv1.ZoneIdentity{ Name: &zoneName, }) + options.SetResourceGroup(&vpcv1.ResourceGroupIdentity{ + ID: &resourceGroupID, + }) publicGateway, _, err := s.IBMVPCClients.VPCService.CreatePublicGateway(options) return publicGateway, err } diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index b3968ad3b1..ea22aa5f81 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -125,6 +125,9 @@ func (m *MachineScope) CreateMachine() (*vpcv1.Instance, error) { ID: &m.IBMVPCMachine.Spec.PrimaryNetworkInterface.Subnet, }, }, + ResourceGroup: &vpcv1.ResourceGroupIdentity{ + ID: &m.IBMVPCCluster.Spec.ResourceGroup, + }, UserData: &cloudInitData, } diff --git a/controllers/ibmvpccluster_controller.go b/controllers/ibmvpccluster_controller.go index 0081289213..8dbb666f2f 100644 --- a/controllers/ibmvpccluster_controller.go +++ b/controllers/ibmvpccluster_controller.go @@ -18,7 +18,6 @@ package controllers import ( "context" - "os" "github.com/IBM/vpc-go-sdk/vpcv1" "github.com/go-logr/logr" @@ -73,9 +72,8 @@ func (r *IBMVPCClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques return ctrl.Result{}, nil } - // Create the scope. - // TODO: Will be removed once we find a better way of overriding the service endpoint, generate via spec. - svcEndpoint := os.Getenv("SERVICE_ENDPOINT") + // Create the service endpoint. + svcEndpoint := "https://" + ibmCluster.Spec.Region + ".iaas.cloud.ibm.com/v1" authenticator, err := authenticator.GetAuthenticator() if err != nil { diff --git a/controllers/ibmvpcmachine_controller.go b/controllers/ibmvpcmachine_controller.go index 404f0da5d2..0445aa95bd 100644 --- a/controllers/ibmvpcmachine_controller.go +++ b/controllers/ibmvpcmachine_controller.go @@ -19,7 +19,6 @@ package controllers import ( "context" "fmt" - "os" "github.com/IBM/vpc-go-sdk/vpcv1" "github.com/go-logr/logr" @@ -95,8 +94,8 @@ func (r *IBMVPCMachineReconciler) Reconcile(ctx context.Context, req ctrl.Reques return ctrl.Result{}, nil } - // Create the cluster scope. - svcEndpoint := os.Getenv("SERVICE_ENDPOINT") + // Create the service endpoint. + svcEndpoint := "https://" + ibmCluster.Spec.Region + ".iaas.cloud.ibm.com/v1" authenticator, err := authenticator.GetAuthenticator() if err != nil { diff --git a/docs/book/src/getting-started.md b/docs/book/src/getting-started.md index 72052469d3..caf2d962c2 100644 --- a/docs/book/src/getting-started.md +++ b/docs/book/src/getting-started.md @@ -43,11 +43,10 @@ it into a management cluster using `clusterctl`. ``` - Additional varibles required for VPC - The sample `IAM_ENDPOINT` below points to Production and the `SERVICE_ENDPOINT` points to the `us-east` VPC region. + The sample `IAM_ENDPOINT` below points to Production. ```console export IAM_ENDPOINT=https://iam.cloud.ibm.com/identity/token - export SERVICE_ENDPOINT=https://us-south.iaas.cloud.ibm.com/v1 ``` > Note: Refer [Regions-Zones Mapping](/reference/regions-zones-mapping.html) for more information.