Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 8f0bb09

Browse files
committed
howto: add sandbox config annotation howto
It explains the details of current supported annotations. Fixes: #486 Fixes: #294 Depends-on: github.com/kata-containers/tests#2240 Signed-off-by: Peng Tao <[email protected]>
1 parent 2fc36da commit 8f0bb09

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

how-to/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
- [Privileged Kata Containers](privileged.md)
2626
- [How to load kernel modules in Kata Containers](how-to-load-kernel-modules-with-kata.md)
2727
- [How to use Kata Containers with `virtio-mem`](how-to-use-virtio-mem-with-kata.md)
28+
- [How to set sandbox Kata Containers configurations with pod annotations](how-to-set-sandbox-config-kata.md)
+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Per-Pod Kata Configurations
2+
3+
Kata Containers gives users freedom to customize at per-pod level, by setting
4+
a wide range of Kata specific annotations in the pod specification.
5+
6+
# Kata Configuration Annotations
7+
There are several kinds of Kata configurations and they are listed below.
8+
9+
## Global Options
10+
| Key | Value Type | Comments |
11+
|-------| ----- | ----- |
12+
| `io.katacontainers.config_path` | string | Kata config file location that overrides the default config paths |
13+
| `io.katacontainers.pkg.oci.bundle_path` | string | OCI bundle path |
14+
| `io.katacontainers.pkg.oci.container_type`| string | OCI container type. Only accepts `pod_container` and `pod_sandbox` |
15+
16+
## Runtime Options
17+
| Key | Value Type | Comments |
18+
|-------| ----- | ----- |
19+
| `io.katacontainers.config.runtime.experimental` | `boolean` | determines if experimental features enabled |
20+
| `io.katacontainers.config.runtime.disable_guest_seccomp`| `boolean` | determines if `seccomp` should be applied inside guest |
21+
| `io.katacontainers.config.runtime.disable_new_netns` | `boolean` | determines if a new netns is created for the hypervisor process |
22+
| `io.katacontainers.config.runtime.internetworking_model` | string| determines how the VM should be connected to the container network interface. Valid values are `macvtap`, `tcfilter` and `none` |
23+
| `io.katacontainers.config.runtime.sandbox_cgroup_only`| `boolean` | determines if Kata processes are managed only in sandbox cgroup |
24+
25+
## Agent Options
26+
| Key | Value Type | Comments |
27+
|-------| ----- | ----- |
28+
| `io.katacontainers.config.agent.enable_tracing` | `boolean` | enable tracing for the agent |
29+
| `io.katacontainers.config.agent.kernel_modules` | string | the list of kernel modules and their parameters that will be loaded in the guest kernel. Semicolon separated list of kernel modules and their parameters. These modules will be loaded in the guest kernel using `modprobe`(8). E.g., `e1000e InterruptThrottleRate=3000,3000,3000 EEE=1; i915 enable_ppgtt=0` |
30+
| `io.katacontainers.config.agent.trace_mode` | string | the trace mode for the agent |
31+
| `io.katacontainers.config.agent.trace_type` | string | the trace type for the agent |
32+
33+
## Hypervisor Options
34+
| Key | Value Type | Comments |
35+
|-------| ----- | ----- |
36+
| `io.katacontainers.config.hypervisor.asset_hash_type` | string | the hash type used for assets verification, default is `sha512` |
37+
| `io.katacontainers.config.hypervisor.block_device_cache_direct` | `boolean` | Denotes whether use of `O_DIRECT` (bypass the host page cache) is enabled |
38+
| `io.katacontainers.config.hypervisor.block_device_cache_noflush` | `boolean` | Denotes whether flush requests for the device are ignored |
39+
| `io.katacontainers.config.hypervisor.block_device_cache_set` | `boolean` | cache-related options will be set to block devices or not |
40+
| `io.katacontainers.config.hypervisor.block_device_driver` | string | the driver to be used for block device, valid values are `virtio-blk`, `virtio-scsi`, `nvdimm`|
41+
| `io.katacontainers.config.hypervisor.default_max_vcpus` | uint32| the maximum number of vCPUs allocated for the VM by the hypervisor |
42+
| `io.katacontainers.config.hypervisor.default_memory` | uint32| the memory assigned for a VM by the hypervisor in `MiB` |
43+
| `io.katacontainers.config.hypervisor.default_vcpus` | uint32| the default vCPUs assigned for a VM by the hypervisor |
44+
| `io.katacontainers.config.hypervisor.disable_block_device_use` | `boolean` | disallow a block device from being used |
45+
| `io.katacontainers.config.hypervisor.disable_vhost_net` | `boolean` | specify if `vhost-net` is not available on the host |
46+
| `io.katacontainers.config.hypervisor.enable_hugepages` | `boolean` | if the memory should be `pre-allocated` from huge pages |
47+
| `io.katacontainers.config.hypervisor.enable_iothreads` | `boolean`| enable IO to be processed in a separate thread. Supported currently for virtio-`scsi` driver |
48+
| `io.katacontainers.config.hypervisor.enable_mem_prealloc` | `boolean` | the memory space used for `nvdimm` device by the hypervisor |
49+
| `io.katacontainers.config.hypervisor.enable_swap` | `boolean` | enable swap of VM memory |
50+
| `io.katacontainers.config.hypervisor.entropy_source` | string| the path to a host source of entropy (`/dev/random`, `/dev/urandom` or real hardware RNG device) |
51+
| `io.katacontainers.config.hypervisor.file_mem_backend` | string | file based memory backend root directory |
52+
| `io.katacontainers.config.hypervisor.firmware_hash` | string | container firmware SHA-512 hash value |
53+
| `io.katacontainers.config.hypervisor.firmware` | string | the guest firmware that will run the container VM |
54+
| `io.katacontainers.config.hypervisor.guest_hook_path` | string | the path within the VM that will be used for drop in hooks |
55+
| `io.katacontainers.config.hypervisor.hotplug_vfio_on_root_bus` | `boolean` | indicate if devices need to be hotplugged on the root bus instead of a bridge|
56+
| `io.katacontainers.config.hypervisor.hypervisor_hash` | string | container hypervisor binary SHA-512 hash value |
57+
| `io.katacontainers.config.hypervisor.image_hash` | string | container guest image SHA-512 hash value |
58+
| `io.katacontainers.config.hypervisor.image` | string | the guest image that will run in the container VM |
59+
| `io.katacontainers.config.hypervisor.initrd_hash` | string | container guest initrd SHA-512 hash value |
60+
| `io.katacontainers.config.hypervisor.initrd` | string | the guest initrd image that will run in the container VM |
61+
| `io.katacontainers.config.hypervisor.jailer_hash` | string | container jailer SHA-512 hash value |
62+
| `io.katacontainers.config.hypervisor.jailer_path` | string | the jailer that will constrain the container VM |
63+
| `io.katacontainers.config.hypervisor.kernel_hash` | string | container kernel image SHA-512 hash value |
64+
| `io.katacontainers.config.hypervisor.kernel_params` | string | additional guest kernel parameters |
65+
| `io.katacontainers.config.hypervisor.kernel` | string | the kernel used to boot the container VM |
66+
| `io.katacontainers.config.hypervisor.machine_accelerators` | string | machine specific accelerators for the hypervisor |
67+
| `io.katacontainers.config.hypervisor.machine_type` | string | the type of machine being emulated by the hypervisor |
68+
| `io.katacontainers.config.hypervisor.memory_offset` | uint32| the memory space used for `nvdimm` device by the hypervisor |
69+
| `io.katacontainers.config.hypervisor.memory_slots` | uint32| the memory slots assigned to the VM by the hypervisor |
70+
| `io.katacontainers.config.hypervisor.msize_9p` | uint32 | the `msize` for 9p shares |
71+
| `io.katacontainers.config.hypervisor.path` | string | the hypervisor that will run the container VM |
72+
| `io.katacontainers.config.hypervisor.shared_fs` | string | the shared file system type, either `virtio-9p` or `virtio-fs` |
73+
| `io.katacontainers.config.hypervisor.use_vsock` | `boolean` | specify use of `vsock` for agent communication |
74+
| `io.katacontainers.config.hypervisor.virtio_fs_cache_size` | uint32 | virtio-fs DAX cache size in `MiB` |
75+
| `io.katacontainers.config.hypervisor.virtio_fs_cache` | string | the cache mode for virtio-fs, valid values are `always`, `auto` and `none` |
76+
| `io.katacontainers.config.hypervisor.virtio_fs_daemon` | string | virtio-fs `vhost-user` daemon path |
77+
| `io.katacontainers.config.hypervisor.virtio_fs_extra_args` | string | extra options passed to `virtiofs` daemon |
78+
79+
# Example - Using annotations
80+
81+
As mentioned above, not all containers need the same modules, therefore using
82+
the configuration file for specifying the list of kernel modules per POD can
83+
be a pain. Unlike the configuration file, annotations provide a way to specify
84+
custom configurations per POD.
85+
86+
The list of kernel modules and parameters can be set using the annotation
87+
`io.katacontainers.config.agent.kernel_modules` as a semicolon separated
88+
list, where the first word of each element is considered as the module name and
89+
the rest as its parameters.
90+
91+
Also users might want to enable guest `seccomp` to provide better isolation with a
92+
little performance sacrifice. The annotation
93+
`io.katacontainers.config.runtime.disable_guest_seccomp` can used for such purpose.
94+
95+
In the following example two PODs are created, but the kernel modules `e1000e`
96+
and `i915` are inserted only in the POD `pod1`. Also guest `seccomp` is only enabled
97+
in the POD `pod2`.
98+
99+
100+
```yaml
101+
apiVersion: v1
102+
kind: Pod
103+
metadata:
104+
name: pod1
105+
annotations:
106+
io.katacontainers.config.agent.kernel_modules: "e1000e EEE=1; i915"
107+
spec:
108+
runtimeClassName: kata
109+
containers:
110+
- name: c1
111+
image: busybox
112+
command:
113+
- sh
114+
stdin: true
115+
tty: true
116+
117+
---
118+
apiVersion: v1
119+
kind: Pod
120+
metadata:
121+
name: pod2
122+
annotations:
123+
io.katacontainers.config.runtime.disable_guest_seccomp: false
124+
spec:
125+
runtimeClassName: kata
126+
containers:
127+
- name: c2
128+
image: busybox
129+
command:
130+
- sh
131+
stdin: true
132+
tty: true
133+
```

0 commit comments

Comments
 (0)