Skip to content

Commit 0091001

Browse files
Add e2e test for RKE2 ClusterClass
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent cf4c84b commit 0091001

25 files changed

+1403
-34
lines changed

api/v1beta1/types.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ 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
114+
// AdditionalAPIServerLBPorts specifies extra inbound ports for the APIServer load balancer.
115+
// Each port specified (e.g., 9345) creates an inbound rule where the frontend port and the backend port are the same.
115116
// +optional
116-
AdditionalControlPlaneLBPorts []LoadBalancerPort `json:"additionalControlPlaneLBPorts,omitempty"`
117+
AdditionalAPIServerLBPorts []LoadBalancerPort `json:"additionalAPIServerLBPorts,omitempty"`
117118

118119
NetworkClassSpec `json:",inline"`
119120
}

api/v1beta1/types_template.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ type NetworkTemplateSpec struct {
7676
// +optional
7777
ControlPlaneOutboundLB *LoadBalancerClassSpec `json:"controlPlaneOutboundLB,omitempty"`
7878

79-
// AdditionalControlPlaneLBPorts is the configuration for the additional inbound control-plane load balancer ports
79+
// AdditionalAPIServerLBPorts is the configuration for the additional inbound control-plane load balancer ports
80+
// Each port specified (e.g., 9345) creates an inbound rule where the frontend port and the backend port are the same.
8081
// +optional
81-
AdditionalControlPlaneLBPorts []LoadBalancerPort `json:"additionalControlPlaneLBPorts,omitempty"`
82+
AdditionalAPIServerLBPorts []LoadBalancerPort `json:"additionalAPIServerLBPorts,omitempty"`
8283
}
8384

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

api/v1beta1/zz_generated.deepcopy.go

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

azure/scope/cluster.go

+9-14
Original file line numberDiff line numberDiff line change
@@ -1030,15 +1030,9 @@ func (s *ClusterScope) SetControlPlaneSecurityRules() {
10301030

10311031
subnet := s.ControlPlaneSubnet()
10321032

1033-
if subnet.SecurityGroup.SecurityRules == nil {
1034-
subnet := s.ControlPlaneSubnet()
1035-
1036-
s.AzureCluster.Spec.NetworkSpec.UpdateControlPlaneSubnet(subnet)
1037-
}
1038-
1039-
if subnet.GetSecurityRuleByDestination("22") == nil {
1040-
subnet := s.ControlPlaneSubnet()
1041-
subnet.SecurityGroup.SecurityRules = append(s.ControlPlaneSubnet().SecurityGroup.SecurityRules,
1033+
missing_ssh := subnet.GetSecurityRuleByDestination("22") == nil
1034+
if missing_ssh {
1035+
subnet.SecurityGroup.SecurityRules = append(subnet.SecurityGroup.SecurityRules,
10421036
infrav1.SecurityRule{
10431037
Name: "allow_ssh",
10441038
Description: "Allow SSH",
@@ -1051,14 +1045,13 @@ func (s *ClusterScope) SetControlPlaneSecurityRules() {
10511045
DestinationPorts: ptr.To("22"),
10521046
Action: infrav1.SecurityRuleActionAllow,
10531047
})
1054-
1055-
s.AzureCluster.Spec.NetworkSpec.UpdateControlPlaneSubnet(subnet)
10561048
}
10571049

10581050
port := strconv.Itoa(int(s.APIServerPort()))
1059-
if subnet.GetSecurityRuleByDestination(port) == nil {
1060-
subnet := s.ControlPlaneSubnet()
1061-
subnet.SecurityGroup.SecurityRules = append(s.ControlPlaneSubnet().SecurityGroup.SecurityRules, infrav1.SecurityRule{
1051+
1052+
missing_api_port := subnet.GetSecurityRuleByDestination(port) == nil
1053+
if missing_api_port {
1054+
subnet.SecurityGroup.SecurityRules = append(subnet.SecurityGroup.SecurityRules, infrav1.SecurityRule{
10621055
Name: "allow_apiserver",
10631056
Description: "Allow K8s API Server",
10641057
Priority: 2201,
@@ -1070,7 +1063,9 @@ func (s *ClusterScope) SetControlPlaneSecurityRules() {
10701063
DestinationPorts: ptr.To(port),
10711064
Action: infrav1.SecurityRuleActionAllow,
10721065
})
1066+
}
10731067

1068+
if missing_ssh || missing_api_port {
10741069
s.AzureCluster.Spec.NetworkSpec.UpdateControlPlaneSubnet(subnet)
10751070
}
10761071
}

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,10 @@ 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
661+
additionalAPIServerLBPorts:
662+
description: |-
663+
AdditionalAPIServerLBPorts specifies extra inbound ports for the APIServer load balancer.
664+
Each port specified (e.g., 9345) creates an inbound rule where the frontend port and the backend port are the same.
664665
items:
665666
description: LoadBalancerPort specifies additional port for
666667
the API server load balancer.

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,10 @@ 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
523+
additionalAPIServerLBPorts:
524+
description: |-
525+
AdditionalAPIServerLBPorts is the configuration for the additional inbound control-plane load balancer ports
526+
Each port specified (e.g., 9345) creates an inbound rule where the frontend port and the backend port are the same.
527527
items:
528528
description: LoadBalancerPort specifies additional port
529529
for the API server load balancer.

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,22 @@ spec:
146146
name: my-subnet-cp-nsg
147147
securityRules:
148148
- name: "allow_ssh"
149-
description: "Deny SSH"
149+
description: "allow SSH"
150150
direction: "Inbound"
151151
priority: 2200
152152
protocol: "*"
153153
destination: "*"
154154
destinationPorts: "22"
155155
source: "*"
156156
sourcePorts: "*"
157-
action: "Deny"
157+
action: "Allow"
158158
- name: "allow_apiserver"
159-
description: "Allow Custom K8s API Server"
159+
description: "Allow K8s API Server"
160160
direction: "Inbound"
161161
priority: 2201
162162
protocol: "*"
163163
destination: "*"
164-
destinationPorts: "1234" # Custom API server URL
164+
destinationPorts: "6443"
165165
source: "*"
166166
sourcePorts: "*"
167167
action: "Allow"
@@ -197,7 +197,7 @@ spec:
197197
name: my-vnet
198198
cidrBlocks:
199199
- 10.0.0.0/16
200-
additionalControlPlaneLBPorts:
200+
additionalAPIServerLBPorts:
201201
- name: RKE2
202202
port: 9345
203203
subnets:

templates/cluster-template-clusterclass-rke2.yaml

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

0 commit comments

Comments
 (0)