Skip to content

Commit 452799e

Browse files
Add field for additional LB ports to CP nodes
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent 8812ec2 commit 452799e

File tree

8 files changed

+120
-3
lines changed

8 files changed

+120
-3
lines changed

api/v1beta1/types.go

+13
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,22 @@ type NetworkSpec struct {
111111
// +optional
112112
ControlPlaneOutboundLB *LoadBalancerSpec `json:"controlPlaneOutboundLB,omitempty"`
113113

114+
// AdditionalControlPlaneLBPorts is the configuration for the additional inbound control-plane load balancer ports
115+
// +optional
116+
AdditionalControlPlaneLBPorts []LoadBalancerPort `json:"additionalControlPlaneLBPorts,omitempty"`
117+
114118
NetworkClassSpec `json:",inline"`
115119
}
116120

121+
// LoadBalancerPort specifies additional port for the API server load balancer
122+
type LoadBalancerPort struct {
123+
// Name for the additional port within LB definition
124+
Name string `json:"name"`
125+
126+
// Port for the LB definition
127+
Port int32 `json:"port"`
128+
}
129+
117130
// VnetSpec configures an Azure virtual network.
118131
type VnetSpec struct {
119132
// ResourceGroup is the name of the resource group of the existing virtual network

api/v1beta1/types_template.go

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ type NetworkTemplateSpec struct {
7575
// This is different from APIServerLB, and is used only in private clusters (optionally) for enabling outbound traffic.
7676
// +optional
7777
ControlPlaneOutboundLB *LoadBalancerClassSpec `json:"controlPlaneOutboundLB,omitempty"`
78+
79+
// AdditionalControlPlaneLBPorts is the configuration for the additional inbound control-plane load balancer ports
80+
// +optional
81+
AdditionalControlPlaneLBPorts []LoadBalancerPort `json:"additionalControlPlaneLBPorts,omitempty"`
7882
}
7983

8084
// GetSubnetTemplate returns the subnet template based on the subnet role.

api/v1beta1/zz_generated.deepcopy.go

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

azure/scope/cluster.go

+7
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
266266
BackendPoolName: s.APIServerLB().BackendPool.Name,
267267
IdleTimeoutInMinutes: s.APIServerLB().IdleTimeoutInMinutes,
268268
AdditionalTags: s.AdditionalTags(),
269+
AdditionalPorts: s.ControlPlaneAdditionalLBPorts(),
269270
}
270271

271272
if s.APIServerLB().FrontendIPs != nil {
@@ -299,6 +300,7 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
299300
BackendPoolName: s.APIServerLB().BackendPool.Name + "-internal",
300301
IdleTimeoutInMinutes: s.APIServerLB().IdleTimeoutInMinutes,
301302
AdditionalTags: s.AdditionalTags(),
303+
AdditionalPorts: s.ControlPlaneAdditionalLBPorts(),
302304
}
303305

304306
privateIPFound := false
@@ -771,6 +773,11 @@ func (s *ClusterScope) ControlPlaneOutboundLB() *infrav1.LoadBalancerSpec {
771773
return s.AzureCluster.Spec.NetworkSpec.ControlPlaneOutboundLB
772774
}
773775

776+
// ControlPlaneAdditionalLBPorts returns the additiona API server ports list.
777+
func (s *ClusterScope) ControlPlaneAdditionalLBPorts() []infrav1.LoadBalancerPort {
778+
return s.AzureCluster.Spec.NetworkSpec.AdditionalControlPlaneLBPorts
779+
}
780+
774781
// APIServerLBName returns the API Server LB name.
775782
func (s *ClusterScope) APIServerLBName() string {
776783
apiServerLB := s.APIServerLB()

azure/services/loadbalancers/spec.go

+28-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type LBSpec struct {
4747
APIServerPort int32
4848
IdleTimeoutInMinutes *int32
4949
AdditionalTags map[string]string
50+
AdditionalPorts []infrav1.LoadBalancerPort
5051
}
5152

5253
// ResourceName returns the name of the load balancer.
@@ -221,14 +222,14 @@ func getLoadBalancingRules(lbSpec LBSpec, frontendIDs []*armnetwork.SubResource)
221222
if len(frontendIDs) != 0 {
222223
frontendIPConfig = frontendIDs[0]
223224
}
224-
return []*armnetwork.LoadBalancingRule{
225+
rules := []*armnetwork.LoadBalancingRule{
225226
{
226227
Name: ptr.To(lbRuleHTTPS),
227228
Properties: &armnetwork.LoadBalancingRulePropertiesFormat{
228229
DisableOutboundSnat: ptr.To(true),
229230
Protocol: ptr.To(armnetwork.TransportProtocolTCP),
230-
FrontendPort: ptr.To[int32](lbSpec.APIServerPort),
231-
BackendPort: ptr.To[int32](lbSpec.APIServerPort),
231+
FrontendPort: ptr.To(lbSpec.APIServerPort),
232+
BackendPort: ptr.To(lbSpec.APIServerPort),
232233
IdleTimeoutInMinutes: lbSpec.IdleTimeoutInMinutes,
233234
EnableFloatingIP: ptr.To(false),
234235
LoadDistribution: ptr.To(armnetwork.LoadDistributionDefault),
@@ -242,6 +243,30 @@ func getLoadBalancingRules(lbSpec LBSpec, frontendIDs []*armnetwork.SubResource)
242243
},
243244
},
244245
}
246+
247+
for _, port := range lbSpec.AdditionalPorts {
248+
rules = append(rules, &armnetwork.LoadBalancingRule{
249+
Name: ptr.To(port.Name),
250+
Properties: &armnetwork.LoadBalancingRulePropertiesFormat{
251+
DisableOutboundSnat: ptr.To(true),
252+
Protocol: ptr.To(armnetwork.TransportProtocolTCP),
253+
FrontendPort: ptr.To(port.Port),
254+
BackendPort: ptr.To(port.Port),
255+
IdleTimeoutInMinutes: lbSpec.IdleTimeoutInMinutes,
256+
EnableFloatingIP: ptr.To(false),
257+
LoadDistribution: ptr.To(armnetwork.LoadDistributionDefault),
258+
FrontendIPConfiguration: frontendIPConfig,
259+
BackendAddressPool: &armnetwork.SubResource{
260+
ID: ptr.To(azure.AddressPoolID(lbSpec.SubscriptionID, lbSpec.ResourceGroup, lbSpec.Name, lbSpec.BackendPoolName)),
261+
},
262+
Probe: &armnetwork.SubResource{
263+
ID: ptr.To(azure.ProbeID(lbSpec.SubscriptionID, lbSpec.ResourceGroup, lbSpec.Name, httpsProbe)),
264+
},
265+
},
266+
})
267+
}
268+
269+
return rules
245270
}
246271
return []*armnetwork.LoadBalancingRule{}
247272
}

config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusters.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,25 @@ spec:
658658
description: NetworkSpec encapsulates all things related to Azure
659659
network.
660660
properties:
661+
additionalControlPlaneLBPorts:
662+
description: AdditionalControlPlaneLBPorts is the configuration
663+
for the additional inbound control-plane load balancer ports
664+
items:
665+
description: LoadBalancerPort specifies additional port for
666+
the API server load balancer
667+
properties:
668+
name:
669+
description: Name for the additional port within LB definition
670+
type: string
671+
port:
672+
description: Port for the LB definition
673+
format: int32
674+
type: integer
675+
required:
676+
- name
677+
- port
678+
type: object
679+
type: array
661680
apiServerLB:
662681
description: APIServerLB is the configuration for the control-plane
663682
load balancer.

config/crd/bases/infrastructure.cluster.x-k8s.io_azureclustertemplates.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,27 @@ spec:
520520
description: NetworkSpec encapsulates all things related to
521521
Azure network.
522522
properties:
523+
additionalControlPlaneLBPorts:
524+
description: AdditionalControlPlaneLBPorts is the configuration
525+
for the additional inbound control-plane load balancer
526+
ports
527+
items:
528+
description: LoadBalancerPort specifies additional port
529+
for the API server load balancer
530+
properties:
531+
name:
532+
description: Name for the additional port within
533+
LB definition
534+
type: string
535+
port:
536+
description: Port for the LB definition
537+
format: int32
538+
type: integer
539+
required:
540+
- name
541+
- port
542+
type: object
543+
type: array
523544
apiServerLB:
524545
description: APIServerLB is the configuration for the
525546
control-plane load balancer.

docs/book/src/self-managed/custom-vnet.md

+3
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ spec:
197197
name: my-vnet
198198
cidrBlocks:
199199
- 10.0.0.0/16
200+
additionalControlPlaneLBPorts:
201+
- name: RKE2
202+
port: 9345
200203
subnets:
201204
- name: my-subnet-cp
202205
role: control-plane

0 commit comments

Comments
 (0)