Compare commits

...

2 Commits

Author SHA1 Message Date
a4c1995587 Alter IP range and share kvm
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-03-14 19:33:07 +00:00
5a7a5b2d6d 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>
2021-03-14 18:53:08 +00:00
3 changed files with 16 additions and 9 deletions

View File

@ -42,7 +42,7 @@ const (
defaultBridgeName = "openfaas0"
// defaultSubnet is the default subnet used in the defaultCNIConf -- this value is set to not collide with common container networking subnets:
defaultSubnet = "10.62.0.0/16"
defaultSubnet = "10.63.0.0/16"
// defaultIfPrefix is the interface name to be created in the container
defaultIfPrefix = "eth"
@ -179,7 +179,7 @@ func GetIPAddress(container string, PID uint32) (string, error) {
//
// Example:
//
// /var/run/cni/openfaas-cni-bridge/10.62.0.2
// /var/run/cni/openfaas-cni-bridge/10.63.0.2
//
// nats-621
// eth1

View File

@ -10,7 +10,7 @@ import (
func Test_isCNIResultForPID_Found(t *testing.T) {
body := `nats-621
eth1`
fileName := `10.62.0.2`
fileName := `10.63.0.2`
container := "nats"
PID := uint32(621)
fullPath := filepath.Join(os.TempDir(), fileName)
@ -38,7 +38,7 @@ eth1`
func Test_isCNIResultForPID_NoMatch(t *testing.T) {
body := `nats-621
eth1`
fileName := `10.62.0.3`
fileName := `10.63.0.3`
container := "gateway"
PID := uint32(621)
fullPath := filepath.Join(os.TempDir(), fileName)

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),
@ -151,8 +148,18 @@ func deploy(ctx context.Context, req types.FunctionDeployment, client *container
oci.WithCapabilities([]string{"CAP_NET_RAW"}),
oci.WithMounts(mounts),
oci.WithEnv(envs),
oci.WithLinuxDevice("/dev/kvm", "rmw"),
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 {