Managing Firewall Ports
Each node's host firewall is preconfigured with the ports required by the platform. You do not need to manage these ports, and you should not modify the platform's preconfigured port list directly.
When a workload needs an additional host port to be open—for example, a component that listens directly on the node—you can open it by installing a small systemd unit with a MachineConfig object. The unit opens the ports at runtime with firewall-cmd --add-port, leaving the platform's preconfigured ports untouched.
TOC
Why This Uses a Runtime Unit, Not a Firewalld ReloadOpening Additional PortsChanging or Removing PortsNotesWhy This Uses a Runtime Unit, Not a Firewalld Reload
Reloading or restarting firewalld (firewall-cmd --reload, systemctl restart firewalld) rebuilds the host firewall from scratch. On a cluster node this can drop packet-filtering rules that other components program directly—such as Istio's traffic-redirection rules, kube-proxy, or the CNI—causing intermittent connectivity loss. To avoid that, this procedure never reloads or restarts firewalld.
Instead, a oneshot systemd unit adds the ports to the running firewalld with firewall-cmd --add-port. This is purely additive and flushes nothing. The unit is ordered after firewalld and declared PartOf=firewalld.service, so if firewalld is ever restarted the unit runs again and re-adds the ports (a runtime --add-port does not survive a firewalld restart on its own).
Opening Additional Ports
The following example opens TCP ports 9141 (ZooKeeper) and 9308 (cpaas-kafka), two ports commonly needed by the logging stack. Change the --add-port list to the ports your workload requires.
-
Create a
MachineConfigthat installs a oneshot unit which opens the ports at runtime: -
Configure a node disruption policy so that changes to this unit restart the unit—re-running
firewall-cmd—instead of rebooting the node. Add theopen-app-ports.serviceentry to thenodeDisruptionPolicy.unitslist of theclusterMachineConfigurationobject in thecpaas-systemnamespace, and confirm it is reflected instatus.nodeDisruptionPolicyStatusbefore applying theMachineConfig:
After both objects are applied, the unit opens the ports on each targeted node with no firewalld reload and no node reboot; the platform's preconfigured ports and other components' rules are left intact.
The cluster object is a singleton and may already carry other unit or file policies. Add open-app-ports.service to the existing nodeDisruptionPolicy.units list rather than replacing the whole policy. A managed unit that is not listed here falls back to the default action for units, which reboots the node when the unit changes.
Changing or Removing Ports
- To add ports, extend the
--add-portlist in the unit and re-apply theMachineConfig. The node disruption policy restarts the unit and the new ports are added at runtime. - To remove a port, deleting it from the
--add-portlist is not sufficient by itself:firewall-cmd --add-portonly adds, so a port that is already open at runtime stays open until firewalld is restarted. Remove the port from the unit, then restart firewalld on the affected nodes—or reboot them—to drop it.
Notes
- Ports are added to firewalld's default zone. If the relevant interface is bound to a non-default zone, add
--zone=<zone>to thefirewall-cmdcommand. firewall-cmd --add-portis idempotent: re-adding an already-open port returns a warning and still succeeds, so the oneshot unit is safe to re-run.- The unit requires firewalld to be running. On a node that does not run host firewalld, the unit does not start and no ports are opened.
- A runtime
--add-portis not written to firewalld's permanent configuration. If firewalld is reloaded out of band (firewall-cmd --reload), these ports are dropped and are re-added only the next time firewalld or the node restarts.