Skip to content

Commit 48506cb

Browse files
Fix the label in CRD for versions and add more parameters to NLB spec
1 parent 046aede commit 48506cb

13 files changed

+592
-7
lines changed

api/v1beta1/types.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,35 @@ type LoadBalancer struct {
947947
// ID of Load Balancer.
948948
// +optional
949949
LoadBalancerId *string `json:"loadBalancerId,omitempty"`
950+
951+
// The NLB Spec
952+
// +optional
953+
NLBSpec NLBSpec `json:"nlbSpec,omitempty"`
954+
}
955+
956+
// NLBSpec specifies the NLB spec.
957+
type NLBSpec struct {
958+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
959+
// +optional
960+
BackendSetDetails BackendSetDetails `json:"backendSetDetails,omitempty"`
961+
}
962+
963+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
964+
type BackendSetDetails struct {
965+
// If this parameter is enabled, then the network load balancer preserves the source IP of the packet when it is forwarded to backends.
966+
// Backends see the original source IP. If the isPreserveSourceDestination parameter is enabled for the network load balancer resource, then this parameter cannot be disabled.
967+
// The value is false by default.
968+
// +optional
969+
IsPreserveSource *bool `json:"isPreserveSource,omitempty"`
970+
971+
// If enabled, the network load balancer will continue to distribute traffic in the configured distribution in the event all backends are unhealthy.
972+
// The value is false by default.
973+
// +optional
974+
IsFailOpen *bool `json:"isFailOpen,omitempty"`
975+
976+
// If enabled existing connections will be forwarded to an alternative healthy backend as soon as current backend becomes unhealthy.
977+
// +optional
978+
IsInstantFailoverEnabled *bool `json:"isInstantFailoverEnabled,omitempty"`
950979
}
951980

952981
// NetworkSpec specifies what the OCI networking resources should look like.

api/v1beta1/zz_generated.conversion.go

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/types.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,35 @@ type LoadBalancer struct {
955955
// Type of Load Balancer: NLB (default) or LBaaS.
956956
// +optional
957957
LoadBalancerType LoadBalancerType `json:"loadBalancerType,omitempty"`
958+
959+
// The NLB Spec
960+
// +optional
961+
NLBSpec NLBSpec `json:"nlbSpec,omitempty"`
962+
}
963+
964+
// NLBSpec specifies the NLB spec.
965+
type NLBSpec struct {
966+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
967+
// +optional
968+
BackendSetDetails BackendSetDetails `json:"backendSetDetails,omitempty"`
969+
}
970+
971+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
972+
type BackendSetDetails struct {
973+
// If this parameter is enabled, then the network load balancer preserves the source IP of the packet when it is forwarded to backends.
974+
// Backends see the original source IP. If the isPreserveSourceDestination parameter is enabled for the network load balancer resource, then this parameter cannot be disabled.
975+
// The value is false by default.
976+
// +optional
977+
IsPreserveSource *bool `json:"isPreserveSource,omitempty"`
978+
979+
// If enabled, the network load balancer will continue to distribute traffic in the configured distribution in the event all backends are unhealthy.
980+
// The value is false by default.
981+
// +optional
982+
IsFailOpen *bool `json:"isFailOpen,omitempty"`
983+
984+
// If enabled existing connections will be forwarded to an alternative healthy backend as soon as current backend becomes unhealthy.
985+
// +optional
986+
IsInstantFailoverEnabled *bool `json:"isInstantFailoverEnabled,omitempty"`
958987
}
959988

960989
// NetworkSpec specifies what the OCI networking resources should look like.

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud/scope/network_load_balancer_reconciler.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ func (s *ClusterScope) DeleteApiServerNLB(ctx context.Context) error {
9898
// NLBSpec builds the Network LoadBalancer from the ClusterScope and returns it
9999
func (s *ClusterScope) NLBSpec() infrastructurev1beta2.LoadBalancer {
100100
nlbSpec := infrastructurev1beta2.LoadBalancer{
101-
Name: s.GetControlPlaneLoadBalancerName(),
101+
Name: s.GetControlPlaneLoadBalancerName(),
102+
NLBSpec: s.OCIClusterAccessor.GetNetworkSpec().APIServerLB.NLBSpec,
102103
}
103104
return nlbSpec
104105
}
@@ -141,6 +142,10 @@ func (s *ClusterScope) UpdateNLB(ctx context.Context, nlb infrastructurev1beta2.
141142
// See https://docs.oracle.com/en-us/iaas/Content/NetworkLoadBalancer/overview.htm for more details on the Network
142143
// Load Balancer
143144
func (s *ClusterScope) CreateNLB(ctx context.Context, lb infrastructurev1beta2.LoadBalancer) (*string, *string, error) {
145+
isPreserverSourceIp := lb.NLBSpec.BackendSetDetails.IsPreserveSource
146+
if isPreserverSourceIp == nil {
147+
isPreserverSourceIp = common.Bool(false)
148+
}
144149
listenerDetails := make(map[string]networkloadbalancer.ListenerDetails)
145150
listenerDetails[APIServerLBListener] = networkloadbalancer.ListenerDetails{
146151
Protocol: networkloadbalancer.ListenerProtocolsTcp,
@@ -151,8 +156,10 @@ func (s *ClusterScope) CreateNLB(ctx context.Context, lb infrastructurev1beta2.L
151156

152157
backendSetDetails := make(map[string]networkloadbalancer.BackendSetDetails)
153158
backendSetDetails[APIServerLBBackendSetName] = networkloadbalancer.BackendSetDetails{
154-
Policy: LoadBalancerPolicy,
155-
IsPreserveSource: common.Bool(false),
159+
Policy: LoadBalancerPolicy,
160+
IsPreserveSource: isPreserverSourceIp,
161+
IsFailOpen: lb.NLBSpec.BackendSetDetails.IsFailOpen,
162+
IsInstantFailoverEnabled: lb.NLBSpec.BackendSetDetails.IsInstantFailoverEnabled,
156163
HealthChecker: &networkloadbalancer.HealthChecker{
157164
Port: common.Int(int(s.APIServerPort())),
158165
Protocol: networkloadbalancer.HealthCheckProtocolsHttps,

0 commit comments

Comments
 (0)