Allow alternative runtimes for functions

By setting FUNCTION_RUNTIME, in theory an alternative container
runtime could be used such as libkrun or kata. In practice,
other changes are required like using the VM network.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd) 2021-03-14 18:53:08 +00:00
parent dca036ee51
commit 5a7a5b2d6d

View File

@ -140,10 +140,7 @@ func deploy(ctx context.Context, req types.FunctionDeployment, client *container
memory.Limit = &v
}
container, err := client.NewContainer(
ctx,
name,
containerd.WithImage(image),
ctrOps := []containerd.NewContainerOpts{containerd.WithImage(image),
containerd.WithSnapshotter(snapshotter),
containerd.WithNewSnapshot(name+"-snapshot", image),
containerd.WithNewSpec(oci.WithImageConfig(image),
@ -152,7 +149,16 @@ func deploy(ctx context.Context, req types.FunctionDeployment, client *container
oci.WithMounts(mounts),
oci.WithEnv(envs),
withMemory(memory)),
containerd.WithContainerLabels(labels),
containerd.WithContainerLabels(labels)}
if v, ok := os.LookupEnv("FUNCTION_RUNTIME"); ok && len(v) > 0 {
ctrOps = append(ctrOps, containerd.WithRuntime(v, nil))
}
container, err := client.NewContainer(
ctx,
name,
ctrOps...,
)
if err != nil {