|
| 1 | +# (De)multiplexing Snapshotter |
| 2 | + |
| 3 | +This package enables the use of in-VM snapshotters. |
| 4 | + |
| 5 | +There are a couple of components within this package that enable containerd |
| 6 | +snapshot requests to be proxied to an in-VM snapshotter: |
| 7 | + |
| 8 | + * The snapshotter plugin that runs as a service to receive snapshotter |
| 9 | + requests from containerd via GRPC. See [containerd's plugin guide](https://github.com/containerd/containerd/blob/v1.6.6/docs/PLUGINS.md) |
| 10 | + for more information on building external snapshotter plugins. This plugin enables |
| 11 | + containerd snapshotter requests to be proxied over a GRPC connection on top of [firecracker's |
| 12 | + vsock](https://github.com/firecracker-microvm/firecracker/blob/v1.1.0/docs/vsock.md). |
| 13 | + * The address resolver agent which implements the namespace lookup API for querying firecracker's |
| 14 | + vsock pathing for communication to the microVM. |
| 15 | + |
| 16 | +## Snapshotter Plugin |
| 17 | + |
| 18 | +The snapshotter plugin is a snapshots service for which we can configure containerd to proxy snapshot requests. |
| 19 | + |
| 20 | +``` |
| 21 | +[proxy_plugins] |
| 22 | + [proxy_plugins.proxy] |
| 23 | + type = "snapshot" |
| 24 | + address = "/var/lib/demux-snapshotter/snapshotter.sock" |
| 25 | +``` |
| 26 | + |
| 27 | +The containerd configuration above will match the demux snapshotter listener configuration. |
| 28 | + |
| 29 | +```toml |
| 30 | +[snapshotter.listener] |
| 31 | + type = "unix" |
| 32 | + address = "/var/lib/demux-snapshotter/snapshotter.sock" |
| 33 | +``` |
| 34 | + |
| 35 | +## Address Resolver Agent |
| 36 | + |
| 37 | +The address resolver agent is a service for querying the network address for a remote snapshotter keyed off the namespace |
| 38 | +of the container being built. |
| 39 | + |
| 40 | +The example agent provided here does a simple lookup of the Firecracker microVM using |
| 41 | +a firecracker-control client where the `VMID` matches the namespace of the container. |
| 42 | + |
| 43 | +### HTTP Address Resolver Agent |
| 44 | + |
| 45 | +An address resolver agent must implement the following HTTP endpoint to be able to handle requests from the demux snapshotter. |
| 46 | + |
| 47 | +Example Request: |
| 48 | +``` |
| 49 | +GET /address?namespace="cbfad871-0862-4dd6-ae7a-52e9b1c16ede" |
| 50 | +``` |
| 51 | + |
| 52 | +Example Response: |
| 53 | +```json |
| 54 | +{ |
| 55 | + "network": "unix", |
| 56 | + "address": "/var/lib/firecracker-containerd/shim-base/default#cbfad871-0862-4dd6-ae7a-52e9b1c16ede/firecracker.vsock", |
| 57 | + "snapshotter_port": "10000", |
| 58 | + "metrics_port": "10001", |
| 59 | + "labels": { |
| 60 | + "namespace": "cbfad871-0862-4dd6-ae7a-52e9b1c16ede" |
| 61 | + } |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +## Building |
| 66 | + |
| 67 | +`demux-snapshotter` and `http-address-resolver` can be built with |
| 68 | + |
| 69 | +``` |
| 70 | +make |
| 71 | +``` |
| 72 | + |
| 73 | +## Testing |
| 74 | + |
| 75 | +To run unit-tests, run: |
| 76 | + |
| 77 | +``` |
| 78 | +make test |
| 79 | +``` |
| 80 | + |
| 81 | +To run integration tests, run: |
| 82 | + |
| 83 | +``` |
| 84 | +make integ-test |
| 85 | +``` |
| 86 | + |
| 87 | +## Configuration |
| 88 | + |
| 89 | +Configuration filepath can be specified at runtime using command line argument `--config`. |
| 90 | + |
| 91 | +By default, if no configuration filepath is specified then `/etc/demux-snapshotter/config.toml` will be used. |
| 92 | + |
| 93 | +### Listener |
| 94 | + |
| 95 | +Application configuration to denote the interface the service will receive requests. |
| 96 | + |
| 97 | +```toml |
| 98 | +[snapshotter.listener] |
| 99 | + type = "unix" |
| 100 | + address = "/var/lib/demux-snapshotter/snapshotter.sock" |
| 101 | +``` |
| 102 | + |
| 103 | +### Proxy Address Resolver |
| 104 | + |
| 105 | +Application configuration to denote the interface to use for resolving proxy addressing |
| 106 | +for remote snapshotters. |
| 107 | + |
| 108 | +```toml |
| 109 | +[snapshotter.proxy.address.resolver] |
| 110 | + type = "http" |
| 111 | + address = "http://127.0.0.1:10001" |
| 112 | +``` |
| 113 | + |
| 114 | +### Metrics |
| 115 | + |
| 116 | +Application configuration to enable remote snapshotter metrics collection via a demux snapshotter endpoint. |
| 117 | + |
| 118 | +```toml |
| 119 | +[snapshotter.metrics] |
| 120 | + enable = true |
| 121 | + port_range = "9000-9999" |
| 122 | + |
| 123 | + [snapshotter.metrics.service_discovery] |
| 124 | + enable = true |
| 125 | + port = 8080 |
| 126 | +``` |
| 127 | + |
| 128 | +Service discovery enables Prometheus service discovery at `http://localhost:{port}` which returns proxy |
| 129 | +endpoints for remote snapshotter Prometheus endpoints. |
0 commit comments