nabla-containers / runnc

OCI-interfacing Container runtime for Nabla Containers
https://nabla-containers.github.io/
ISC License
257 stars 22 forks source link

Use `runnc` directly #53

Open ricarkol opened 5 years ago

ricarkol commented 5 years ago

Trying to use runnc without going through docker, and getting this:

# ls /tmp/hello/
test_hello.nabla

# cat config.json 
{
    "ociVersion": "1.0.0",
    "process": {
        "terminal": false,
        "user": {
            "uid": 0,
            "gid": 0
        },
        "args": [
            "/test_hello.nabla"
        ],
        "env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "TERM=xterm"
        ],
        "cwd": "/"
    },
    "root": {
        "path": "/tmp/hello",
        "readonly": true
    }
}

# runnc create abcd1234123asdfasd2
# runnc start abcd1234123asdfasd2
Running with args: [/opt/runnc/bin/runnc-cont -k8s -nabla-run /opt/runnc/bin/nabla-run -tap tapabcd1234123a -cwd / -volume /run/runnc/abcd1234123asdfasd2/rootfs.iso:/ -unikernel /tmp/hello/test_hello.nabla -env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -env TERM=xterm --]root@nabla5:~/go/src/github.com/nabla-containers/runnc# Could not create tapabcd1234123a: no master interface: Link not found
ricarkol commented 5 years ago

Why is it running runnc-cont with -k8s? Removing the -k8s allows one to run runnc directly.

lumjjb commented 5 years ago

The -k8s flag is mainly to handle the networking stuff.

In regular containers, if run directly, there would not be a network interface configured.

What would the default behavior for network be for rumprun that would be valid?

lumjjb commented 5 years ago

Since networking is not the job for the runnc binary, one possible idea is to use prestart hooks to set up a dummy network:

{
    "ociVersion": "1.0.0",
    "process": {
        "terminal": false,
        "user": {
            "uid": 0,
            "gid": 0
        },
        "args": [
            "/test_hello.nabla"
        ],
        "env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "TERM=xterm"
        ],
        "cwd": "/"
    },
    "root": {
        "path": "/tmp/hello",
        "readonly": true
    },
        "hooks": {
                "prestart": [
        {
            "path": "/sbin/ip",
            "args": ["ip", "link", "add" , "eth0", "type", "dummy"]
        },
        {
            "path": "/sbin/ip",
            "args": ["ip", "addr", "add", "10.0.0.251/8", "dev", "eth0"]
        },
        {
            "path": "/sbin/ip",
            "args": ["ip", "link", "set", "eth0", "up"]
        },
        {
            "path": "/sbin/ip",
            "args": ["ip", "route", "add", "default", "via", "10.0.0.251"]
        }
        ]
        }
}
lumjjb commented 5 years ago

TODO: if runnc-cont detects that there isnt a master IP, just create the TAP with no config and don’t pass in any NIC information into rump should work.

ricarkol commented 5 years ago

This is fixed right?

lumjjb commented 5 years ago

Not yet - this is still a dummy network, it would not be able to run node still for example. We need a flag to have a --standalone-network option.