Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,10 @@ type NetworkSpec struct {
// VCNPeering configuration.
// +optional
VCNPeering *VCNPeering `json:"vcnPeering,omitempty"`

// CompartmentId where to provision network resources. Will default to cluster compartment if empty or not specified.
// +optional
CompartmentId string `json:"compartmentId,omitempty"`
}

// VCNPeering defines the VCN peering details of the workload cluster VCN.
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,10 @@ type NetworkSpec struct {
// VCNPeering configuration.
// +optional
VCNPeering *VCNPeering `json:"vcnPeering,omitempty"`

// CompartmentId where to provision network resources. Will default to cluster compartment if empty or not specified.
// +optional
CompartmentId string `json:"compartmentId,omitempty"`
}

// VCNPeering defines the VCN peering details of the workload cluster VCN.
Expand Down
8 changes: 8 additions & 0 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ func (s *ClusterScope) GetCompartmentId() string {
return s.OCIClusterAccessor.GetCompartmentId()
}

// GetNetworkCompartmentId returns the CompartmentId defined for the network otherwise returns the compartment defined in the OCICluster's spec
func (s *ClusterScope) GetNetworkCompartmentId() string {
if s.OCIClusterAccessor.GetNetworkCompartmentId() == "" {
return s.GetCompartmentId()
}
return s.OCIClusterAccessor.GetNetworkCompartmentId()
}

// APIServerPort returns the APIServerPort to use when creating the load balancer.
func (s *ClusterScope) APIServerPort() int32 {
if s.Cluster.Spec.ClusterNetwork != nil && s.Cluster.Spec.ClusterNetwork.APIServerPort != nil {
Expand Down
2 changes: 2 additions & 0 deletions cloud/scope/cluster_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type OCIClusterAccessor interface {
GetDefinedTags() map[string]map[string]string
// GetCompartmentId returns the compartment id of the cluster.
GetCompartmentId() string
// GetNetworkCompartmentId returns the compartment id where network resources are created
GetNetworkCompartmentId() string
// GetFreeformTags returns the free form tags of the cluster.
GetFreeformTags() map[string]string
// GetName returns the name of the cluster.
Expand Down
4 changes: 2 additions & 2 deletions cloud/scope/drg_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *ClusterScope) GetDRG(ctx context.Context) (*core.Drg, error) {

for {
response, err := s.VCNClient.ListDrgs(ctx, core.ListDrgsRequest{
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
Page: page,
})
if err != nil {
Expand Down Expand Up @@ -113,7 +113,7 @@ func (s *ClusterScope) GetDRG(ctx context.Context) (*core.Drg, error) {
func (s *ClusterScope) createDRG(ctx context.Context) (*core.Drg, error) {
response, err := s.VCNClient.CreateDrg(ctx, core.CreateDrgRequest{
CreateDrgDetails: core.CreateDrgDetails{
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
FreeformTags: s.GetFreeFormTags(),
DefinedTags: s.GetDefinedTags(),
DisplayName: common.String(s.GetDRGName()),
Expand Down
4 changes: 2 additions & 2 deletions cloud/scope/drg_rpc_attachment_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (s *ClusterScope) createRPC(ctx context.Context, drgId *string, displayName
DrgId: drgId,
FreeformTags: s.GetFreeFormTags(),
DefinedTags: s.GetDefinedTags(),
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
},
})
if err != nil {
Expand Down Expand Up @@ -176,7 +176,7 @@ func (s *ClusterScope) lookupRPC(ctx context.Context, drgId *string, rpcId *stri
var page *string
response, err := vcnClient.ListRemotePeeringConnections(ctx, core.ListRemotePeeringConnectionsRequest{
DrgId: drgId,
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
Page: page,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/drg_vcn_attachment_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *ClusterScope) GetDRGAttachment(ctx context.Context) (*core.DrgAttachmen
DisplayName: common.String(s.OCIClusterAccessor.GetName()),
DrgId: s.getDrgID(),
NetworkId: s.OCIClusterAccessor.GetNetworkSpec().Vcn.ID,
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
})

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cloud/scope/internet_gateway_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *ClusterScope) GetInternetGateway(ctx context.Context) (*core.InternetGa
}
}
igws, err := s.VCNClient.ListInternetGateways(ctx, core.ListInternetGatewaysRequest{
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
VcnId: s.getVcnId(),
DisplayName: common.String(InternetGatewayName),
})
Expand All @@ -95,7 +95,7 @@ func (s *ClusterScope) GetInternetGateway(ctx context.Context) (*core.InternetGa
// CreateInternetGateway creates the Internet Gateway for the cluster based on the ClusterScope
func (s *ClusterScope) CreateInternetGateway(ctx context.Context) (*string, error) {
igwDetails := core.CreateInternetGatewayDetails{
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
DisplayName: common.String(InternetGatewayName),
IsEnabled: common.Bool(true),
VcnId: s.getVcnId(),
Expand Down
4 changes: 2 additions & 2 deletions cloud/scope/load_balancer_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (s *ClusterScope) CreateLB(ctx context.Context, lb infrastructurev1beta2.Lo
}

lbDetails := loadbalancer.CreateLoadBalancerDetails{
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
DisplayName: common.String(lb.Name),
ShapeName: common.String("flexible"),
ShapeDetails: &loadbalancer.ShapeDetails{MinimumBandwidthInMbps: common.Int(10),
Expand Down Expand Up @@ -279,7 +279,7 @@ func (s *ClusterScope) GetLoadBalancers(ctx context.Context) (*loadbalancer.Load
var page *string
for {
lbs, err := s.LoadBalancerClient.ListLoadBalancers(ctx, loadbalancer.ListLoadBalancersRequest{
CompartmentId: common.String(s.GetCompartmentId()),
CompartmentId: common.String(s.GetNetworkCompartmentId()),
DisplayName: common.String(s.GetControlPlaneLoadBalancerName()),
Page: page,
})
Expand Down
Loading