Open tgross opened 1 year ago
The firecracker-go-sdk can either set up CNI itself or can use a static interface which allows us to pass on the details of the interfaces that Nomad created.
In my case, I need:
NetworkInterfaces: []firecracker.NetworkInterface{
{
StaticConfiguration: &firecracker.StaticNetworkConfiguration{
HostDevName: "<host tap device>",
MacAddress: "<some mac address>",
IPConfiguration: &firecracker.IPConfiguration{
IfName: "eth0",
IPAddr: net.IPNet{
IP: <interface ip>
Mask: <ip mask>,
},
Gateway: <gateway ip>,
},
},
AllowMMDS: true,
},
The cni.Result has all the details I would need to configure that. Having that exposed to the driver would solve my dilemma. Perhaps other drivers have a similar need.
I've been fighting with these for a few days and I'm on the verge of giving up. I believe what @eveld is proposing would be beneficial. Happy to open a PR if this is possible 😄
While working on https://github.com/hashicorp/nomad/issues/10628 I bumped into this in terms of missing DNS configuration, as described in https://github.com/hashicorp/nomad/issues/11102. Threading the cni.Result
down into the task driver might be the best solution to this or we could add the missing fields to the existing fields on drivers.TaskConfig
Task drivers are not currently supplied much information about the network specification produced by CNI plugins. For example, consider the following CNI configuration:
I've used this with a simple
raw_exec
task for purposes of illustration:jobspec
```hcl job "example" { group "web" { network { mode = "cni/test" } task "http" { driver = "raw_exec" config { command = "python3" args = [ "-m", "http.server", "--directory", "local", ] } } } } ```The network manager reads the mode
cni/test
(refnetwork_manager_linux.go#L192-L197
and callsnewCNINetworkConfigurator
innetworking_cni.go
, which ultimately callsSetup
. The debug log line we get here has plenty of detail about the resulting spec:But if we add a
spew.Dump
to the top of the task driver'sStartTask
, we get the followingNetworkIsolation
block:While this works fine for our built-in task drivers, @eveld has reported a need for custom task drivers to know about how the network was configured, so that they can set appropriate values in the task (for example, setting the IP in a Firecracker VM's MMDS).
We currently pass some of this information along for
bridge
networking if the driver has set some Docker-specific tags (refnetwork_hook.go#L132-L175
, but this doesn't work for CNI and in any case shouldn't be Docker-specific.