Skip to content

Commit a81db72

Browse files
authored
Merge pull request #281 from sipsma/use-firewall
Add firewall plugin to demo-network configuration.
2 parents a28cf67 + 31d33b4 commit a81db72

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
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 & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ You need to have the following things in order to use firecracker-containerd:
3838

3939
</details>
4040
* git
41-
* The Firecracker binary with the optional `vsock` feature enabled. This
42-
feature requires building from source; instructions for doing so are in the
43-
[Firecracker getting started guide](https://github.com/firecracker-microvm/firecracker/blob/master/docs/getting-started.md#building-from-source)
4441
* A root filesystem image (you can use the one
4542
[described here](https://github.com/firecracker-microvm/firecracker/blob/master/docs/getting-started.md#running-firecracker)
4643
as `hello-rootfs.ext4`).
4744
* A recent installation of [Docker CE](https://docker.com).
4845
* Go 1.11 or later, which you can download from [here](https://golang.org/dl/).
49-
* Rust 1.32 (and Cargo), which you can download from [here](https://rustup.rs/).
5046

5147
## Setup
5248

@@ -279,28 +275,41 @@ previously cloned firecracker-containerd repository:
279275
$ sudo make demo-network
280276
```
281277

282-
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
283279
quick summary:
284-
* [`ptp` CNI plugin](https://github.com/containernetworking/plugins/tree/master/plugins/main/ptp)
285-
- Creates a [veth](http://man7.org/linux/man-pages/man4/veth.4.html) pair with
286-
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.
287284
* [`host-local` CNI
288285
plugin](https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local)
289-
- 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
290287
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.
291292
* [`tc-redirect-tap` CNI
292-
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)
293294
- A CNI plugin that adapts other CNI plugins to be usable by Firecracker VMs.
294-
[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
295296
devices created by the `ptp` plugin to tap devices provided to VMs.
296-
* [`fcnet.conflist`](../tools/demo/fcnet.conflist) - A sample CNI configuration
297-
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
298299
`tc-redirect-tap` plugins
299-
300-
After those dependencies are installed, an update to the firecracker-containerd
301-
configuration file is required for VMs to use the `fcnet` CNI-configuration as
302-
their default way of generating network interfaces. Just include the following `
303-
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
304313
at `/etc/containerd/firecracker-runtime.json`):
305314
```json
306315
"default_network_interfaces": [
@@ -313,19 +322,6 @@ at `/etc/containerd/firecracker-runtime.json`):
313322
]
314323
```
315324

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