Skip to content

Commit

Permalink
feat(gvisor): add new runtime class with kvm support
Browse files Browse the repository at this point in the history
This patch adds a new runtime class to the gvisor extension allowing to
use the KVM platform feature. This is done by selecting `runsc-kvm` as
runtime.

References:
https://gvisor.dev/docs/user_guide/platforms/
https://gvisor.dev/docs/user_guide/production/

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
Signed-off-by: Noel Georgi <git@frezbo.dev>
  • Loading branch information
SISheogorath authored and frezbo committed Jul 25, 2024
1 parent b48d3a6 commit c536209
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
33 changes: 33 additions & 0 deletions container-runtime/gvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ machine:
## Testing
### default
Apply the following manifest to run nginx pod via gVisor:
```yaml
Expand Down Expand Up @@ -46,3 +48,34 @@ $ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-gvisor 1/1 Running 0 40s
```

### With platform KVM (requires nested virtualization or bare-metal)

Apply the following manifest to run nginx pod via gVisor with kvm platform:

```yaml
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: gvisor
handler: runsc-kvm
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-gvisor
spec:
runtimeClassName: gvisor
containers:
- name: nginx
image: nginx
```
The pod should be up and running:
```bash
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-gvisor 1/1 Running 0 40s
```

**Hint**: You can run both runtime handlers in parallel by naming them different
6 changes: 6 additions & 0 deletions container-runtime/gvisor/gvisor-kvm.part
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runsc-kvm]
runtime_type = "io.containerd.runsc.v1"

[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runsc-kvm.options]
TypeUrl = "io.containerd.runsc.v1.options"
ConfigPath = "/etc/cri/conf.d/runsc-kvm.toml"
4 changes: 4 additions & 0 deletions container-runtime/gvisor/pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ finalize:
to: /rootfs/etc/cri/conf.d/gvisor.part
- from: /pkg/runsc.toml
to: /rootfs/etc/cri/conf.d/runsc.toml
- from: /pkg/gvisor-kvm.part
to: /rootfs/etc/cri/conf.d/gvisor-kvm.part
- from: /pkg/runsc-kvm.toml
to: /rootfs/etc/cri/conf.d/runsc-kvm.toml
2 changes: 2 additions & 0 deletions container-runtime/gvisor/runsc-kvm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[runsc_config]
platform = "kvm"

0 comments on commit c536209

Please sign in to comment.