Skip to content
Merged
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
24 changes: 24 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ type ObjectReference struct {
Name string `json:"name"`
}

// InternalAccess defines the access for the Internal Passthrough Load Balancer.
type InternalAccess string

const (
// InternalAccessRegional restricts traffic to clients within the same region as the internal load balancer.
InternalAccessRegional = InternalAccess("Regional")

// InternalAccessGlobal allows traffic from any region to access the internal load balancer.
InternalAccessGlobal = InternalAccess("Global")
)

// LoadBalancer specifies the configuration of a LoadBalancer.
type LoadBalancer struct {
// Name is the name of the Load Balancer. If not set a default name
Expand All @@ -371,4 +382,17 @@ type LoadBalancer struct {
// required for the Load Balancer, if not defined the first configured subnet will be
// used.
Subnet *string `json:"subnet,omitempty"`

// InternalAccess defines the access for the Internal Passthrough Load Balancer.
// It determines whether the load balancer allows global access,
// or restricts traffic to clients within the same region as the load balancer.
// If unspecified, the value defaults to "Regional".
//
// Possible values:
// "Regional" - Only clients in the same region as the load balancer can access it.
// "Global" - Clients from any region can access the load balancer.
// +kubebuilder:validation:Enum=Regional;Global
// +kubebuilder:default=Regional
// +optional
InternalAccess InternalAccess `json:"internalAccess,omitempty"`
}
4 changes: 4 additions & 0 deletions cloud/services/compute/loadbalancers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ func (s *Service) createOrGetRegionalForwardingRule(ctx context.Context, lbname
spec.LoadBalancingScheme = string(loadBalanceTrafficInternal)
spec.Region = s.scope.Region()
spec.BackendService = backendSvc.SelfLink
lbSpec := s.scope.LoadBalancer()
if lbSpec.InternalLoadBalancer != nil && lbSpec.InternalLoadBalancer.InternalAccess == infrav1.InternalAccessGlobal {
spec.AllowGlobalAccess = true
}
// Ports is used instead or PortRange for passthrough Load Balancer
// Configure ports for k8s API to match the external API which is the first port of range
var ports []string
Expand Down
1 change: 1 addition & 0 deletions cloud/services/compute/loadbalancers/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ func TestService_createOrGetRegionalForwardingRule(t *testing.T) {
Region: "us-central1",
Name: "my-cluster-api-internal",
SelfLink: "https://www.googleapis.com/compute/v1/projects/proj-id/regions/us-central1/forwardingRules/my-cluster-api-internal",
AllowGlobalAccess: false,
},
},
}
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ spec:
description: InternalLoadBalancer is the configuration for an
Internal Passthrough Network Load Balancer.
properties:
internalAccess:
default: Regional
description: |-
InternalAccess defines the access for the Internal Passthrough Load Balancer.
It determines whether the load balancer allows global access,
or restricts traffic to clients within the same region as the load balancer.
If unspecified, the value defaults to "Regional".

Possible values:
"Regional" - Only clients in the same region as the load balancer can access it.
"Global" - Clients from any region can access the load balancer.
enum:
- Regional
- Global
type: string
name:
description: |-
Name is the name of the Load Balancer. If not set a default name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ spec:
description: InternalLoadBalancer is the configuration
for an Internal Passthrough Network Load Balancer.
properties:
internalAccess:
default: Regional
description: |-
InternalAccess defines the access for the Internal Passthrough Load Balancer.
It determines whether the load balancer allows global access,
or restricts traffic to clients within the same region as the load balancer.
If unspecified, the value defaults to "Regional".

Possible values:
"Regional" - Only clients in the same region as the load balancer can access it.
"Global" - Clients from any region can access the load balancer.
enum:
- Regional
- Global
type: string
name:
description: |-
Name is the name of the Load Balancer. If not set a default name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ spec:
description: InternalLoadBalancer is the configuration for an
Internal Passthrough Network Load Balancer.
properties:
internalAccess:
default: Regional
description: |-
InternalAccess defines the access for the Internal Passthrough Load Balancer.
It determines whether the load balancer allows global access,
or restricts traffic to clients within the same region as the load balancer.
If unspecified, the value defaults to "Regional".

Possible values:
"Regional" - Only clients in the same region as the load balancer can access it.
"Global" - Clients from any region can access the load balancer.
enum:
- Regional
- Global
type: string
name:
description: |-
Name is the name of the Load Balancer. If not set a default name
Expand Down