Skip to content

Commit 31d33b4

Browse files
committed
Add firewall plugin to demo-network configuration.
This plugin results in more consistent success in getting traffic forwarded to/from host networks and the VMs. Signed-off-by: Erik Sipsma <[email protected]>
1 parent 6fc6665 commit 31d33b4

File tree

3 files changed

+39
-32
lines changed

3 files changed

+39
-32
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ HOSTLOCAL_BIN?=$(CNI_BIN_ROOT)/host-local
147147
$(HOSTLOCAL_BIN): $(CNI_BIN_ROOT)
148148
GOBIN=$(CNI_BIN_ROOT) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/ipam/host-local
149149

150+
FIREWALL_BIN?=$(CNI_BIN_ROOT)/firewall
151+
$(FIREWALL_BIN): $(CNI_BIN_ROOT)
152+
GOBIN=$(CNI_BIN_ROOT) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/meta/firewall
153+
150154
TC_REDIRECT_TAP_BIN?=$(CNI_BIN_ROOT)/tc-redirect-tap
151155
$(TC_REDIRECT_TAP_BIN): $(CNI_BIN_ROOT)
152156
GOBIN=$(CNI_BIN_ROOT) go install github.com/firecracker-microvm/firecracker-go-sdk/cni/cmd/tc-redirect-tap
@@ -157,7 +161,7 @@ $(FCNET_CONFIG):
157161
cp tools/demo/fcnet.conflist $(FCNET_CONFIG)
158162

159163
.PHONY: demo-network
160-
demo-network: $(PTP_BIN) $(HOSTLOCAL_BIN) $(TC_REDIRECT_TAP_BIN) $(FCNET_CONFIG)
164+
demo-network: $(PTP_BIN) $(HOSTLOCAL_BIN) $(FIREWALL_BIN) $(TC_REDIRECT_TAP_BIN) $(FCNET_CONFIG)
161165

162166
##########################
163167
# Firecracker submodule

docs/getting-started.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -275,28 +275,41 @@ previously cloned firecracker-containerd repository:
275275
$ sudo make demo-network
276276
```
277277

278-
You can check the Makefile to see exactly what is installed and where, but for a
278+
You can check the Makefile to see exactly what is installed and where, but for a
279279
quick summary:
280-
* [`ptp` CNI plugin](https://github.com/containernetworking/plugins/tree/master/plugins/main/ptp)
281-
- Creates a [veth](http://man7.org/linux/man-pages/man4/veth.4.html) pair with
282-
one end in a private network namespace and the other end in the host's network namespace.
280+
* [`ptp` CNI plugin](https://github.com/containernetworking/plugins/tree/master/plugins/main/ptp)
281+
- Creates a [veth](http://man7.org/linux/man-pages/man4/veth.4.html) pair with
282+
one end in a private network namespace and the other end in the host's network
283+
namespace.
283284
* [`host-local` CNI
284285
plugin](https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local)
285-
- Manages IP allocations of network devices present on the local machine by
286+
- Manages IP allocations of network devices present on the local machine by
286287
vending them from a statically defined subnet.
288+
* [`firewall` CNI
289+
plugin](https://github.com/containernetworking/plugins/tree/master/plugins/meta/firewall)
290+
- Sets up firewall rules on the host that allows traffic to/from VMs via the host
291+
network.
287292
* [`tc-redirect-tap` CNI
288-
plugin](https://github.com/firecracker-microvm/firecracker-go-sdk/tree/master/cni)
293+
plugin](https://github.com/firecracker-microvm/firecracker-go-sdk/tree/master/cni)
289294
- A CNI plugin that adapts other CNI plugins to be usable by Firecracker VMs.
290-
[See this doc for more details](networking.md). It is used here to adapt veth
295+
[See this doc for more details](networking.md). It is used here to adapt veth
291296
devices created by the `ptp` plugin to tap devices provided to VMs.
292-
* [`fcnet.conflist`](../tools/demo/fcnet.conflist) - A sample CNI configuration
293-
file that defines a `fcnet` network created via the `ptp`, `host-local` and
297+
* [`fcnet.conflist`](../tools/demo/fcnet.conflist) - A sample CNI configuration
298+
file that defines a `fcnet` network created via the `ptp`, `host-local` and
294299
`tc-redirect-tap` plugins
295-
296-
After those dependencies are installed, an update to the firecracker-containerd
297-
configuration file is required for VMs to use the `fcnet` CNI-configuration as
298-
their default way of generating network interfaces. Just include the following `
299-
default_network_interfaces` key in your runtime configuration file (by default
300+
- Note that, by default, the nameserver configuration within your host's
301+
`/etc/resolv.conf` will be parsed and provided to VMs as their nameserver
302+
configuration. This can cause problems if your host is using a systemd
303+
resolver or other resolver that operates on localhost (which results in the
304+
VM using its own localhost as the nameserver instead of your host's). This
305+
situation may require manual tweaking of the default CNI configuration, such
306+
as specifying [static DNS configuration as part of the `ptp` plugin](
307+
https://github.com/containernetworking/plugins/tree/master/plugins/main/ptp#network-configuration-reference).
308+
309+
After those dependencies are installed, an update to the firecracker-containerd
310+
configuration file is required for VMs to use the `fcnet` CNI-configuration as
311+
their default way of generating network interfaces. Just include the following
312+
`default_network_interfaces` key in your runtime configuration file (by default
300313
at `/etc/containerd/firecracker-runtime.json`):
301314
```json
302315
"default_network_interfaces": [
@@ -309,19 +322,6 @@ at `/etc/containerd/firecracker-runtime.json`):
309322
]
310323
```
311324

312-
After that, start up a container (as described in the above Usage section) and
313-
try pinging your host IP.
314-
315-
At the time of this writing, there is a bug in the ptp plugin that prevents the
316-
DNS settings from the IPAM plugin being propagated. This is being addressed, but
317-
until that time DNS resolution will require users manually tweak the installed
318-
CNI configuration to specify static DNS nameservers appropriate to their local
319-
network in [the `dns` section of the PTP plugin](https://github.com/containernetworking/plugins/tree/master/plugins/main/ptp#network-configuration-reference)
320-
321-
While your host's IP should always be reachable from the VM given the above
322-
networking setup, your VM may or may not have outbound internet access depending
323-
on the details of your host's network. The ptp plugin attempts to setup iptables
324-
rules to allow the VM's traffic to be forwarded on your host's network but may
325-
not be able to if there are pre-existing iptables rules that overlap. In those
326-
cases, granting your VM outbound internet access may require customization of
327-
the CNI configuration past what's installed above.
325+
After that, start up a container (as described in the above Usage section) and
326+
try pinging any IP available on your host. If your host has internet access,
327+
you should also be able to access the internet from the container too.

tools/demo/fcnet.conflist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"cniVersion": "0.3.1",
2+
"cniVersion": "0.4.0",
33
"name": "fcnet",
44
"plugins": [
55
{
@@ -12,6 +12,9 @@
1212
"resolvConf": "/etc/resolv.conf"
1313
}
1414
},
15+
{
16+
"type": "firewall"
17+
},
1518
{
1619
"type": "tc-redirect-tap"
1720
}

0 commit comments

Comments
 (0)