@@ -14,7 +14,7 @@ machine (VM).
1414Overall, we need to do the followings:
1515
16161 . Build or reuse a Linux kernel.
17- 2 . (Optional) Build or fetch an init process.
17+ 2 . (Optional but recommended ) Build or fetch an init process.
18183 . Prepare the final image by appending the Linux kernel (and init) and set up
1919 ` urunc ` annotations.
2020
@@ -54,25 +54,61 @@ However, this is not always reliable:
5454- If the application exits, the system halts.
5555- CLI argument handling may be incorrect: Linux does not natively support
5656 multi-word arguments via kernel boot parameters. Each space-separated word is
57- treated as a separate argument.
57+ treated as a separate argument.
5858- A few necessary operations (such as mount /proc, set default route) might be
5959 required before executing the application.
60+ - The Linux kernel can only handle a limited number of characters in its boot
61+ parameters. If too many or very long environment variables are passed, the
62+ boot process will fail once that limit is exceeded.
6063
6164Especially, for CLI argument handing, ` urunc ` follows a simple convention. All
6265multi-word CLI arguments are wrapped in single quotes and the init process (or
6366application) is expected to reconstruct them properly.
6467
65- For all the above reasons, we recommend using a dedicated init process. We
66- provide [ urunit] ( https://github.com/nubificus/urunit# ) ; a lightweight init
68+ For all the above reasons, we strongly recommend using a dedicated init process.
69+ We provide [ urunit] ( https://github.com/nubificus/urunit# ) ; a lightweight init
6770designed specifically for ` urunc ` . It performs the following actions:
6871
69721 . Sets default route through eth0. This is necessary when we deploy
7073 the container in a Kubernetes cluster, where there is a high chance that
7174 the gateway of the container might be in a different subnet than the IP.
7275 As a result, Linux kernel will fail to set the gateway.
73762 . Groups multi-word arguments correctly.
77+ 3 . Mounts ` /proc ` and ` /sys ` .
78+ 3 . Reads and sets the environment variables for the application execution
79+ 3 . Reads and sets the uid,gid and working directory for the application execution
74803 . Acts as a reaper, cleaning up zombie processes.
7581
82+ To pass the necessary infomration to urunitlink, ` urunc ` uses a configuration
83+ file that passes to the VM with the following format:
84+
85+ ```
86+ UES
87+ /* list of environment variables */
88+ UEE
89+ UCS
90+ UID:<uid>
91+ GID:<gid>
92+ WD:<working_dir>
93+ UCE
94+ ```
95+
96+ In order to minimize the dependencies for the Linux kernel running as guest,
97+ ` urunc ` attaches this configuration file as an initrd of the VM and sets the
98+ ` retain_initrd ` kernel boot parameter. In that way, urunitlink will be able to
99+ read the configuration file from ` /sys/firmware/initrd ` . In case the guest is
100+ configured to boot with a user-specified initrd, then ` urunc ` will archive
101+ in the cpio format the configuration file and concatenate it with the
102+ user-provided initrd. The Linux kernel is smart enough to handle concatenated
103+ initrd and hence the configuration file will appear in the guest's rootfs.
104+
105+ As a result, in case urunitlink is used we strongly recommend to configure
106+ the Linux kernel setting the following configuration options:
107+
108+ - Support for initrd ` CONFIG_BLK_DEV_INITRD `
109+ - Support for sysfs ` CONFIG_SYSFS `
110+ - Support for procfs ` CONFIG_PROC_FS `
111+
76112You can obtain [ urunit] ( https://github.com/nubificus/urunit ) in two ways:
77113
78114- Fetch a static binary from [ urunit's release
0 commit comments