Skip to content

LoadBalancer services in a VPC with the Firewall service get no firewall rule #114

Open

Description

@adestis-mf

Since apache/cloudstack#12706 (CloudStack 4.23.0.0) a VPC offering can include the Firewall
service for public IPs. The VPC virtual router then drops ingress traffic to a public IP that
has a port forwarding, load balancing or static NAT rule unless a firewall rule allows it (a
FIREWALL_<ip> chain ending in DROP).

applyLoadBalancerRules (cloudstack_loadbalancer.go, main at 363cd03, same in v1.3.0-rc1)
decides per port between a firewall rule and a network ACL item from the services of the
cluster's network:

if isFirewallSupported(network.Service) {
    lb.updateFirewallRule(lbRule.Publicipid, ...)
} else if isNetworkACLSupported(network.Service) {
    lb.updateNetworkACL(..., network.Id)
}

In a VPC the Firewall service belongs to the VPC, not to the tier. A VPC tier reports
NetworkACL but not Firewall, so the CCM only adds an ACL item, and the service port stays
behind the DROP of the VPC firewall. Removal (pruneFirewallRule / pruneNetworkACLRule) uses
the same switch.

Reproduced

CloudStack 4.23.0.0 (KVM), VPC offering with Firewall:VpcVirtualRouter, tier offering with
Dhcp, Dns, Lb, NetworkACL, PortForwarding, SourceNat, StaticNat, UserData, Vpn (no Firewall),
CKS cluster v1.35.4 (1 control, 1 worker), CCM v1.3.0-rc1, nginx behind a LoadBalancer
service on port 80.

Service on the cluster's public IP (spec.loadBalancerIP set to the IP that CKS uses for the
API, so the IP is already configured on the VR):

  • The CCM created the load balancer rule (port 80, Active) and a network ACL item for TCP 80
    ("Managed by the CloudStack Kubernetes Provider"), but no firewall rule.
  • TCP 80 on that IP timed out from two different clients, while TCP 6443 on the same IP, which
    has a firewall rule, answered.
  • After adding a firewall rule for TCP 80 on that IP by hand, the service answered at once
    (HTTP 200 from both clients).
  • On kubectl delete svc the CCM removed the load balancer rule and the ACL item. The firewall
    rule stayed, as expected, since the CCM does not know about it; a fix has to remove the rule it
    created, because the IP is shared with the cluster API.

Service on a new public IP (no loadBalancerIP):

Expected

When the cluster network is a VPC tier and the VPC has the Firewall service (the VPC's service
list from listVPCs contains Firewall), create a firewall rule for each service port on the
service's public IP in addition to the ACL item, honouring loadBalancerSourceRanges, and remove
it together with the service. The order in the code is already right (load balancer rule first,
then the firewall rule): on CloudStack versions without the fix for apache/cloudstack#14146 the
opposite order keeps a new public IP off the router.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions