Skip to content

Commit 342a110

Browse files
Fix the label in CRD for versions and add more parameters to NLB spec
1 parent d8cd71c commit 342a110

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
@@ -953,6 +953,35 @@ type LoadBalancer struct {
953953
// ID of Load Balancer.
954954
// +optional
955955
LoadBalancerId *string `json:"loadBalancerId,omitempty"`
956+
957+
// The NLB Spec
958+
// +optional
959+
NLBSpec NLBSpec `json:"nlbSpec,omitempty"`
960+
}
961+
962+
// NLBSpec specifies the NLB spec.
963+
type NLBSpec struct {
964+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
965+
// +optional
966+
BackendSetDetails BackendSetDetails `json:"backendSetDetails,omitempty"`
967+
}
968+
969+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
970+
type BackendSetDetails struct {
971+
// If this parameter is enabled, then the network load balancer preserves the source IP of the packet when it is forwarded to backends.
972+
// Backends see the original source IP. If the isPreserveSourceDestination parameter is enabled for the network load balancer resource, then this parameter cannot be disabled.
973+
// The value is false by default.
974+
// +optional
975+
IsPreserveSource *bool `json:"isPreserveSource,omitempty"`
976+
977+
// If enabled, the network load balancer will continue to distribute traffic in the configured distribution in the event all backends are unhealthy.
978+
// The value is false by default.
979+
// +optional
980+
IsFailOpen *bool `json:"isFailOpen,omitempty"`
981+
982+
// If enabled existing connections will be forwarded to an alternative healthy backend as soon as current backend becomes unhealthy.
983+
// +optional
984+
IsInstantFailoverEnabled *bool `json:"isInstantFailoverEnabled,omitempty"`
956985
}
957986

958987
// 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
@@ -961,6 +961,35 @@ type LoadBalancer struct {
961961
// Type of Load Balancer: NLB (default) or LBaaS.
962962
// +optional
963963
LoadBalancerType LoadBalancerType `json:"loadBalancerType,omitempty"`
964+
965+
// The NLB Spec
966+
// +optional
967+
NLBSpec NLBSpec `json:"nlbSpec,omitempty"`
968+
}
969+
970+
// NLBSpec specifies the NLB spec.
971+
type NLBSpec struct {
972+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
973+
// +optional
974+
BackendSetDetails BackendSetDetails `json:"backendSetDetails,omitempty"`
975+
}
976+
977+
// BackendSetDetails specifies the configuration of a network load balancer backend set.
978+
type BackendSetDetails struct {
979+
// If this parameter is enabled, then the network load balancer preserves the source IP of the packet when it is forwarded to backends.
980+
// Backends see the original source IP. If the isPreserveSourceDestination parameter is enabled for the network load balancer resource, then this parameter cannot be disabled.
981+
// The value is false by default.
982+
// +optional
983+
IsPreserveSource *bool `json:"isPreserveSource,omitempty"`
984+
985+
// If enabled, the network load balancer will continue to distribute traffic in the configured distribution in the event all backends are unhealthy.
986+
// The value is false by default.
987+
// +optional
988+
IsFailOpen *bool `json:"isFailOpen,omitempty"`
989+
990+
// If enabled existing connections will be forwarded to an alternative healthy backend as soon as current backend becomes unhealthy.
991+
// +optional
992+
IsInstantFailoverEnabled *bool `json:"isInstantFailoverEnabled,omitempty"`
964993
}
965994

966995
// 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)