Skip to content

Commit cbc79e1

Browse files
authored
Merge pull request #46 from drachenfels-de/imports-and-docs
Imports and docs
2 parents 9c901fb + 6b5af07 commit cbc79e1

File tree

16 files changed

+197
-392
lines changed

16 files changed

+197
-392
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ENV K8S_URL="https://dl.k8s.io/v1.20.4/kubernetes-server-linux-amd64.tar.gz"
2626
ENV LXC_GIT_REPO=https://github.com/lxc/lxc.git
2727
ENV LXC_GIT_VERSION=master
2828

29-
ENV LXCRI_GIT_REPO=https://github.com/drachenfels-de/lxcri.git
29+
ENV LXCRI_GIT_REPO=https://github.com/lxc/lxcri.git
3030
ENV LXCRI_GIT_VERSION=main
3131

3232
COPY install.sh /

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
1+
[![Go Reference](https://pkg.go.dev/badge/github.com/lxc/lxcri.svg)](https://pkg.go.dev/github.com/lxc/lxcri)
2+
![Build](https://github.com/lxc/lxcri/actions/workflows/build.yml/badge.svg)
3+
14
# About
25

36
`lxcri` is a wrapper around [LXC](https://github.com/lxc/lxc) which can be used as
47
a drop-in container runtime replacement for use by [CRI-O](https://github.com/kubernetes-sigs/cri-o).
58

69
### OCI compliance
710

8-
With liblxc >= https://github.com/lxc/lxc/commit/b5daeddc5afce1cad4915aef3e71fdfe0f428709
11+
With liblxc starting from [lxc-4.0.0-927-gb5daeddc5](https://github.com/lxc/lxc/commit/b5daeddc5afce1cad4915aef3e71fdfe0f428709)
912
it passes all sonobuoy conformance tests.
1013

11-
## Installation
14+
## Build
15+
16+
You can use the provided [Dockerfile](Dockerfile) to build an</br>
17+
18+
runtime only image (`lxcri` + `lxc`)
19+
20+
`docker build --build-arg installcmd=install_runtime`
21+
22+
or with everything required for a kubernetes node (kubelet, kubeadm, cri-o, lxcri, lxc ...)
23+
24+
`docker build`
1225

13-
For the installation of the runtime see [install.md](doc/install.md)</br>
14-
For the installation and initialization of a kubernetes cluster see [kubernetes.md](doc/kubernetes.md)
26+
Note: The images are not pre-configured and you must follow the steps in setup for now.
1527

16-
## Bugs
28+
## Setup
1729

18-
* cli: --help shows environment values not defaults https://github.com/urfave/cli/issues/1206
30+
To use `lxcri` as OCI runtime in `cri-o` see [setup.md](doc/setup.md)
1931

20-
## Requirements and restrictions
32+
## API Usage
2133

22-
* Only cgroupv2 (unified cgroup hierarchy) is supported.
23-
* A recent kernel >= 5.8 is required for full cgroup support.
34+
Please have a look at the [runtime tests](runtime_test.go) for now.
2435

25-
### Unimplemented features
36+
## Notes
2637

27-
* [runtime: Implement POSIX platform hooks](https://github.com/Drachenfels-GmbH/lxcri/issues/10)
28-
* [runtime: Implement cgroup2 resource limits](https://github.com/Drachenfels-GmbH/lxcri/issues/11)
38+
* It's currently only tested with cgroups v2.

cmd/lxcri-hook-builtin/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"path/filepath"
77

8-
"github.com/drachenfels-de/lxcri/pkg/specki"
8+
"github.com/lxc/lxcri/pkg/specki"
99
"github.com/opencontainers/runtime-spec/specs-go"
1010
"golang.org/x/sys/unix"
1111
)

cmd/lxcri-hook/README.md

Lines changed: 0 additions & 128 deletions
This file was deleted.

cmd/lxcri-hook/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"path/filepath"
99
"time"
1010

11-
"github.com/drachenfels-de/lxcri/pkg/specki"
11+
"github.com/lxc/lxcri/pkg/specki"
1212
"github.com/opencontainers/runtime-spec/specs-go"
1313
)
1414

cmd/lxcri-init/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"path/filepath"
1010
"time"
1111

12-
"github.com/drachenfels-de/lxcri/pkg/specki"
12+
"github.com/lxc/lxcri/pkg/specki"
1313
"github.com/opencontainers/runtime-spec/specs-go"
1414
"golang.org/x/sys/unix"
1515
)

cmd/lxcri/cli.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"text/template"
1111
"time"
1212

13-
"github.com/drachenfels-de/lxcri"
14-
"github.com/drachenfels-de/lxcri/pkg/log"
15-
"github.com/drachenfels-de/lxcri/pkg/specki"
13+
"github.com/lxc/lxcri"
14+
"github.com/lxc/lxcri/pkg/log"
15+
"github.com/lxc/lxcri/pkg/specki"
1616
"github.com/opencontainers/runtime-spec/specs-go"
1717
"github.com/urfave/cli/v2"
1818
)

container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/drachenfels-de/lxcri/pkg/specki"
11+
"github.com/lxc/lxcri/pkg/specki"
1212
"github.com/opencontainers/runtime-spec/specs-go"
1313
"github.com/rs/zerolog"
1414
"golang.org/x/sys/unix"

create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"path/filepath"
88
"strings"
99

10-
"github.com/drachenfels-de/lxcri/pkg/specki"
10+
"github.com/lxc/lxcri/pkg/specki"
1111
"github.com/opencontainers/runtime-spec/specs-go"
1212
)
1313

doc/cli.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
## Glossary
2+
3+
* `runtime` the lxcri binary and the command set that implement the [OCI runtime spec](https://github.com/opencontainers/runtime-spec/releases/download/v1.0.2/oci-runtime-spec-v1.0.2.html)
4+
* `container process` the process that starts and runs the container using liblxc (lxcri-start)
5+
* `container config` the LXC config file
6+
* `bundle config` the lxcri container state (bundle path, pidfile ....)
7+
* `runtime spec` the OCI runtime spec from the bundle
8+
9+
## Setup
10+
11+
The runtime binary implements flags that are required by the `OCI runtime spec`,</br>
12+
and flags that are runtime specific (timeouts, hooks, logging ...).
13+
14+
Most of the runtime specific flags have corresponding environment variables. See `lxcri --help`.</br>
15+
The runtime evaluates the flag value in the following order (lower order takes precedence).
16+
17+
1. cmdline flag from process arguments (overwrites process environment)
18+
2. process environment variable (overwrites environment file)
19+
3. environment file (overwrites cmdline flag default)
20+
4. cmdline flag default
21+
22+
### Environment variables
23+
24+
Currently you have to compile to environment file yourself.</br>
25+
To list all available variables:
26+
27+
```
28+
grep EnvVars cmd/cli.go | grep -o LXCRI_[A-Za-z_]* | xargs -n1 -I'{}' echo "#{}="
29+
```
30+
31+
### Environment file
32+
33+
The default path to the environment file is `/etc/defaults/lxcri`.</br>
34+
It is loaded on every start of the `lxcri` binary, so changes take immediate effect.</br>
35+
Empty lines and those commented with a leading *#* are ignored.</br>
36+
37+
A malformed environment will let the next runtime call fail.</br>
38+
In production it's recommended that you replace the environment file atomically.</br>
39+
40+
E.g the environment file `/etc/default/lxcri` could look like this:
41+
42+
```sh
43+
LXCRI_LOG_LEVEL=debug
44+
LXCRI_CONTAINER_LOG_LEVEL=debug
45+
#LXCRI_LOG_FILE=
46+
#LXCRI_LOG_TIMESTAMP=
47+
#LXCRI_MONITOR_CGROUP=
48+
#LXCRI_LIBEXEC=
49+
#LXCRI_APPARMOR=
50+
#LXCRI_CAPABILITIES=
51+
#LXCRI_CGROUP_DEVICES=
52+
#LXCRI_SECCOMP=
53+
#LXCRI_CREATE_TIMEOUT=
54+
#LXCRI_CREATE_HOOK=/usr/local/bin/lxcri-backup.sh
55+
#LXCRI_CREATE_HOOK_TIMEOUT=
56+
#LXCRI_START_TIMEOUT=
57+
#LXCRI_KILL_TIMEOUT=
58+
#LXCRI_DELETE_TIMEOUT=
59+
```
60+
61+
### Runtime (security) features
62+
63+
All supported runtime security features are enabled by default.</br>
64+
The following runtime (security) features can optionally be disabled.</br>
65+
Details see `lxcri --help`
66+
67+
* apparmor
68+
* capabilities
69+
* cgroup-devices
70+
* seccomp
71+
72+
### Logging
73+
74+
There is only a single log file for runtime and container process log output.</br>
75+
The log-level for the runtime and the container process can be set independently.
76+
77+
* containers are ephemeral, but the log file should not be
78+
* a single logfile is easy to rotate and monitor
79+
* a single logfile is easy to tail (watch for errors / events ...)
80+
* robust implementation is easy
81+
82+
#### Log Filtering
83+
84+
Runtime log lines are written in JSON using [zerolog](https://github.com/rs/zerolog).</br>
85+
The log file can be easily filtered with [jq](https://stedolan.github.io/jq/).</br>
86+
For filtering with `jq` you must strip the container process logs with `grep -v '^lxc'`</br>
87+
88+
E.g Filter show only errors and warnings for runtime `create` command:
89+
90+
```sh
91+
grep -v '^lxc ' /var/log/lxcri.log |\
92+
jq -c 'select(.cmd == "create" and ( .l == "error or .l == "warn")'
93+
```
94+
95+
#### Runtime log fields
96+
97+
Fields that are always present:
98+
99+
* `l` log level
100+
* `m` log message
101+
* `c` caller (source file and line number)
102+
* `cid` container ID
103+
* `cmd` runtime command
104+
* `t` timestamp in UTC (format matches container process output)
105+
106+
### Debugging
107+
108+
Apart from the logfile following resources are useful:
109+
110+
* Systemd journal for cri-o and kubelet services
111+
* `coredumpctl` if runtime or container process segfaults.

0 commit comments

Comments
 (0)