| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…ewall service Since apache#12706 a VPC offering can provide the Firewall service for public IPs. The VPC virtual router then drops ingress traffic to a public IP that has no firewall rule. CKS only created network ACL items, port forwarding and the API load balancer rule on VPC tiers, so the management server could not reach the nodes (SSH 2222+, API 6443), the control node could not reach its own API through the public IP, and cluster creation failed after the start timeout. When the VPC virtual router provides the Firewall service of the cluster's VPC (the check that sets vpc_firewall_enabled on the VR), CKS now creates the same ingress firewall rules as on isolated networks on create (including etcd nodes), scale and node add/remove. In a VPC the firewall rules are created after the load balancing and port forwarding rules: applying firewall rules on a VPC public IP does not associate the IP with the VR, and if they come first the IP is never associated. Firewall rules on VPC public IPs have no network_id, so per-node rules are looked up by public IP and ports. On delete the rules go with the release of the cluster public IP. Isolated networks, VPCs without the Firewall service and the NSX/Netris paths are unchanged.
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
Sorry, something went wrong.
There was a problem hiding this comment.
Scaling a firewall-enabled VPC cluster after importing a worker can fail because unreconciled per-node SSH rules conflict with the replacement port range.
1 open issue What changed in this PRThis PR fixes CKS connectivity on VPC tiers whose virtual router provides the Firewall service, extending public-IP firewall handling across cluster lifecycle operations.
Changes:
| File | Description |
|---|---|
| plugins/integrations/kubernetes-service/src/test/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorkerTest.java | Tests conditional VPC firewall creation and rule ordering. |
| plugins/integrations/kubernetes-service/src/test/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorkerTest.java | Tests firewall detection and network/public-IP lookups. |
| plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterStartWorker.java | Opens etcd SSH ports after VPC port forwarding. |
| plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterScaleWorker.java | Rebuilds VPC SSH firewall rules during scaling. |
| plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorker.java | Adds API and SSH firewall rules during VPC setup. |
| plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterRemoveWorker.java | Revokes per-node VPC firewall rules with missing-rule handling. |
| plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterAddWorker.java | Creates and rolls back per-node VPC firewall rules. |
| plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java | Centralizes firewall DAO injection, detection, and lookup helpers. |
Review effort: Balanced
Sorry, something went wrong.
| } | ||
| if (vpcFirewallEnabled) { | ||
| // After the port forwarding rules, as when the cluster is created | ||
| addFirewallRulesForNodes(publicIp, clusterVMIds.size()); |
There was a problem hiding this comment.
Thanks, the scenario is valid: the imported node's single-port SSH rule overlaps the rebuilt
range, and detectRulesConflict rejects it (same protocol and source CIDR).
Reading the code, isolated networks on main behave the same way: the add-node path creates the
same per-node rule
(KubernetesClusterAddWorker.java#L229),
and the isolated scale path also revokes a single rule before recreating the range
(KubernetesClusterScaleWorker.java#L135-L149).
This PR mirrors that handling for VPC tiers, so the case is not new, it just becomes reachable on
VPC tiers with the Firewall service.
I'd prefer to keep this PR to the missing rules and fix the import-then-scale case for both
network types in #14673, since it also touches removeSshFirewallRule, which
#14165 is changing. If you'd rather have it here, I'll add it to this PR.
Sorry, something went wrong.
There was a problem hiding this comment.
@adestis-mf , you opened three issues;
I'd prefer to keep this PR to the missing rules and fix the import-then-scale case for both
network types in #14673, since it also touches removeSshFirewallRule, which
#14165 is changing. If you'd rather have it here, I'll add it to this PR.
are you sugesting to solve all three in this PR?
Sorry, something went wrong.
There was a problem hiding this comment.
No, this PR only fixes #14668: the missing firewall rules for CKS clusters on VPC tiers when the VPC
has the Firewall service. The other two are separate:
Sorry, something went wrong.
There was a problem hiding this comment.
An update on the import-then-scale case: #14673 turned out to be a duplicate of #12633, and a fix is proposed in #14683. It targets 4.22, where the bug exists for isolated networks, and it leaves removeSshFirewallRule unchanged, so it does not conflict with #14165.
The VPC tier path of this PR is not in 4.22. Once #14683 is merged forward to main, I'll call the same method (removeExternalNodeSshRules) in scaleKubernetesClusterVpcTierRules here, so that VPC tiers with the Firewall service are covered as well.
Sorry, something went wrong.
|
A note on a dependency, found while looking into #14146 (root cause and reproduction in my comment |
Sorry, something went wrong.
|
@RosiKyu a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
Sorry, something went wrong.
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20005 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
This PR fixes CKS clusters on VPC tiers whose VPC uses the Firewall service for public IPs
(added in #12706). In such a VPC the VPC virtual router drops ingress traffic to a public IP
unless a firewall rule allows it. CKS only created network ACL items, port forwarding and the
API load balancer rule on VPC tiers. The management server could not reach the nodes (SSH 2222+,
API 6443), the control node could not reach its own API through the public IP
(controlPlaneEndpoint), and cluster creation failed after the start timeout.
When the VPC virtual router provides the Firewall service of the cluster's VPC, CKS now creates
the same ingress firewall rules as on isolated networks:
and the etcd SSH ports (setupKubernetesEtcdNetworkRules);
(scaleKubernetesClusterVpcTierRules), as for isolated networks;
(KubernetesClusterAddWorker, KubernetesClusterRemoveWorker).
In a VPC the firewall rules are created after the load balancing and port forwarding
rules. Applying firewall rules on a VPC public IP does not associate the IP with the VR
(IpAddressManagerImpl.applyRules skips it when the rule has no network). If the firewall rules
come first, the later LB/PF rules do not associate it either and the IP never reaches the VR
(#14669). On isolated networks the order stays as it was.
Firewall rules on VPC public IPs are stored with vpc_id and without network_id, so the
per-node lookup now goes by public IP and ports for VPC tiers
(findIngressFirewallRuleForPorts); isolated networks keep using findByNetworkIdAndPorts.
On cluster deletion the rules are revoked together with the release of the cluster public IP
(cleanupIpResources → revokeFirewallRulesForIp), so the destroy worker is unchanged.
The check (isVpcFirewallEnabled) is the one that sets vpc_firewall_enabled on the VR:
VpcServiceMapDao.canProviderSupportServiceInVpc(vpcId, Firewall, VPCVirtualRouter). VPCs
without the Firewall service, isolated networks and the NSX/Netris paths behave as before.
FirewallRulesDao is now injected once in KubernetesClusterActionWorker instead of separately
in three subclasses, so that the shared lookup can use it.
This targets main: the Firewall service for VPC public IPs is not in 4.22, and there is no
4.23 branch. The commit also applies cleanly on top of the 4.23.0.0 tag.
Fixes: #14668
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests (new): KubernetesClusterActionWorkerTest covers isVpcFirewallEnabled,
isPublicIpFirewallRequired and findIngressFirewallRuleForPorts for isolated networks and VPC
tiers with and without the Firewall service; KubernetesClusterResourceModifierActionWorkerTest
checks that setupKubernetesClusterVpcTierRules creates the firewall rules only when the VPC
firewall is enabled, and only after the LB and SSH port forwarding rules.
mvn -pl plugins/integrations/kubernetes-service -am test -Dtest='**/kubernetes/**/*Test' \ -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=falseResult on JDK 11 / Maven 3.10: BUILD SUCCESS, 141 tests in the kubernetes-service module,
0 failures, 0 errors; checkstyle 0 violations.
Live, on 4.23.0.0 (KVM) without the patch, adding by hand the firewall rules the patch creates
(same VPC with the Firewall service, same tier, v1.35.4, 1 control + 1 worker):
Deleting each cluster released the public IP and left no firewall rule behind. The patched
build itself was not deployed to a live management server.
How did you try to break this feature and the system with this change?
findByNetworkIdAndPorts.
patch creates them afterwards; a unit test pins the order.
NullPointerException.
(CKS: make the source CIDR of the auto-provisioned node SSH firewall rules configurable #13970, CKS: add an editable per-cluster management-access CIDR policy #14212); removeSshFirewallRule still matches by port, as before. On scale the VPC
path goes through the same removeSshFirewallRule, so the fix for clusters with separate etcd
nodes in kubernetes: prefer the node SSH rule when scaling a cluster with etcd nodes #14165 (CKS: scale-down with separate etcd revokes wrong SSH rules and fails (4.22.1.1) #14159) applies to VPC tiers as well once it is merged forward.