Skip to content

Commit b441fca

Browse files
twz123github-actions[bot]
authored andcommitted
Update docs around firewalld
Clarify backend selection, mention that Oracle Linux uses firewalld, and reuse the ostests firewalld service snippets, so the documented setup stays in lockstep with the automated tests. Signed-off-by: Tom Wieczorek <[email protected]> (cherry picked from commit 1d1fa31)
1 parent a888f28 commit b441fca

File tree

1 file changed

+88
-17
lines changed

1 file changed

+88
-17
lines changed

docs/networking.md

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,35 +81,106 @@ There are [known](https://bugzilla.netfilter.org/show_bug.cgi?id=1632) version i
8181

8282
## Firewalld & k0s
8383

84-
If you are using [`firewalld`](https://firewalld.org/) on your hosts you need to ensure it is configured to use the same `FirewallBackend` as k0s and other Kubernetes components use. Otherwise networking will be broken in various ways.
84+
If you are using [firewalld] on your hosts, make sure that it runs with the same
85+
backend (`nftables` or `iptables`) that k0s and the bundled Kubernetes
86+
components use. Otherwise, kube-proxy, Kube-router, or Calico will program rules
87+
in the wrong backend, which will result in a networking failure. You can
88+
configure the active backend via the `FirewallBackend` option in
89+
`/etc/firewalld/firewalld.conf`.
8590

86-
Here's an example configuration for a tested working networking setup:
91+
Firewalld is known to be enabled by default in Oracle Linux.
8792

88-
```sh
89-
[root@rhel-test ~]# firewall-cmd --list-all
93+
Instead of adding individual ports, create dedicated firewalld services for k0s.
94+
The k0s automated test suite uses the following XML snippets, so using them will
95+
ensure that your configuration is aligned with our automated validation process:
96+
97+
Create the service file for controller nodes in
98+
`/etc/firewalld/services/k0s-controller.xml` as follows:
99+
100+
```xml
101+
{% include "../hack/ostests/modules/os/k0s-controller.firewalld-service.xml" %}
102+
```
103+
104+
Create the service file for worker nodes in
105+
`/etc/firewalld/services/k0s-worker.xml` as follows:
106+
107+
```xml
108+
{% include "../hack/ostests/modules/os/k0s-worker.firewalld-service.xml" %}
109+
```
110+
111+
With the services in place, enable them on the nodes. For nodes running
112+
controller components:
113+
114+
```console
115+
$ sudo firewall-cmd --permanent --add-service=k0s-controller
116+
success
117+
```
118+
119+
For nodes running worker components:
120+
121+
```console
122+
$ sudo firewall-cmd --permanent --add-service=k0s-worker
123+
success
124+
$ sudo firewall-cmd --permanent --add-masquerade
125+
success
126+
```
127+
128+
For nodes that run both controller and worker components, i.e. nodes running
129+
with the `controller --enable-worker` flag, you need to enable both.
130+
131+
Allow traffic from your pod and service networks so that the host accepts
132+
traffic arriving via the overlay interfaces:
133+
134+
```console
135+
$ sudo firewall-cmd --permanent --add-source=<podCIDR>
136+
success
137+
$ sudo firewall-cmd --permanent --add-source=<serviceCIDR>
138+
success
139+
```
140+
141+
Replace `<podCIDR>` and `<serviceCIDR>` with the values configured in
142+
`k0s.yaml`. When you schedule workloads on controller nodes, add both
143+
`k0s-controller` and `k0s-worker` services to the machine. Add `--zone=<zone>`
144+
to the commands if you are configuring a zone other than the default.
145+
146+
Reload firewalld once after applying the permanent changes:
147+
148+
```console
149+
$ sudo firewall-cmd --reload
150+
success
151+
```
152+
153+
For automated image builds where firewalld is not yet running (for example
154+
during cloud-init), use the offline variant:
155+
156+
```console
157+
$ sudo firewall-offline-cmd --add-service=k0s-controller
158+
success
159+
$ sudo firewall-offline-cmd --add-service=k0s-worker
160+
success
161+
$ sudo firewall-offline-cmd --add-masquerade
162+
success
163+
$ sudo systemctl reload firewalld
164+
```
165+
166+
After reloading, you should see the k0s services applied:
167+
168+
```console
169+
$ sudo firewall-cmd --list-all
90170
public (active)
91171
target: default
92172
icmp-block-inversion: no
93173
interfaces: eth0
94174
sources: 10.244.0.0/16 10.96.0.0/12
95-
services: cockpit dhcpv6-client ssh
96-
ports: 80/tcp 6443/tcp 8132/tcp 10250/tcp 179/tcp 179/udp
175+
services: cockpit dhcpv6-client k0s-controller k0s-worker ssh
176+
ports:
97177
protocols:
98-
forward: no
178+
forward: yes
99179
masquerade: yes
100180
forward-ports:
101181
source-ports:
102182
icmp-blocks:
103183
rich rules:
104184
```
105185

106-
Basic single node firewalld setup:
107-
108-
```sh
109-
# Allow traffic from podCIDR
110-
$ firewall-cmd --add-source=10.244.0.0/16 --permanent
111-
# Allow kubelet API traffic
112-
$ firewall-cmd --add-port=10250/tcp --permanent
113-
# Apply firewall changes
114-
$ firewall-cmd --reload
115-
```
186+
[firewalld]: https://firewalld.org/

0 commit comments

Comments
 (0)