Slide 1

Slide 1 text

Rustとコンテナランタイム
 Rust 🤝 Container Runtime
 Rust.Tokyo 2021 September 18th
 うたもく(@utam0k)
 1

Slide 2

Slide 2 text

self‐introduction ● うたもく(@utam0k) ● I work for a web company and use Scala language ● I'm studying containers in earnest starting in 2021. ● Member of the containers 2

Slide 3

Slide 3 text

What I want you to know ● Youki, a container runtime written in Rust ● A brief description of container technology ○ What is container runtime? ○ Learning container technologies with youki's code ● Rust 🤝 Container Runtime 3

Slide 4

Slide 4 text

What is youki? ● I’m creator of youki ● A container runtime written in Rust ● Developed under containers, the organization that develop podman ● ★ 1.3K in github.com ● youki = 容器 = container (Meaning "container" in Japanese) 4

Slide 5

Slide 5 text

A container runtime … ?
 5

Slide 6

Slide 6 text

Kubelet(K8s)
 Linux etc...
 High-Level Runtime
 CRI
 Low-Level Runtime
 OCI
 CRI − Container Runtime Interface
 OCI − Open Container Initiative
 Container Runtime
 6

Slide 7

Slide 7 text

Kubelet(K8s)
 Linux etc...
 High-Level Runtime
 CRI
 Low-Level Runtime
 OCI
 ● runC
 ● youki
 ● crun
 Container Runtime
 7

Slide 8

Slide 8 text

What is a container? ● A process ≒ A container ○ Processes in which various resources are isolated Process Files Process Files Process Files OS 8

Slide 9

Slide 9 text

isolated? ● pivot_root ○ Change the destination that the root directory of a process points to ● namespace ○ Ability to isolate resources that a process can manipulate ● cgroup ○ Allows configuration of resources available to processes 9

Slide 10

Slide 10 text

isolated? ● pivot_root ○ Change the destination that the root directory of a process points to ● namespace ○ Ability to isolate resources that a process can manipulate ● cgroup ○ Allows configuration of resources available to processes 10

Slide 11

Slide 11 text

cgroup ● Create a group of processes and configure settings for that group ● For example... ○ Limit CPU usage time, specifying assigned CPUs ○ Device access control ○ Pause/resume tasks ● There are resource controllers for different types of resources 11

Slide 12

Slide 12 text

/sys/fs/cgroup
 CPU
 Memory
 Devices
 P P P P P P P P P P Represent tree with directories inherit 12

Slide 13

Slide 13 text

Let’s dive into youki 13

Slide 14

Slide 14 text

Rust 🤝 Container Runtime
 14

Slide 15

Slide 15 text

Rust × Container Runtime 👍 :+1: ● Performance ● Easy to handle system calls ● A Good fit between low layers and Rust community 15

Slide 16

Slide 16 text

Rust × Container Runtime 👍 :+1: ● Performance ● Easy to handle system calls ● A Good fit between low layers and Rust community 16

Slide 17

Slide 17 text

Performance ● Enables containers to be launched even with tight memory limits $ podman --runtime youki run --rm --memory 1M fedora echo work work $ podman --runtime runc run --rm --memory 1M fedora echo work Error: OCI runtime error: .... 17

Slide 18

Slide 18 text

Performance ● Enables containers to be launched even with tight memory limits ● Faster container startup and deletion ○ There is a C language implementation of a container runtime called crun ■ Probably not that different in speed from crun ○ Technically challenging and interesting :) 18

Slide 19

Slide 19 text

Rust × Container Runtime 👍 :+1: ● Performance ● Easy to handle system calls ● A Good fit between low layers and Rust community 19

Slide 20

Slide 20 text

Easy to handle system calls ● Threads and processes can be precise controlled ○ Difficult when language runtime is multithreaded ■ Rust and C are not ○ setns(2) - reassociate thread with a namespace A multithreaded process may not change user namespace with setns(). ○ Youki has little trouble in this area ● Existence of libc crate and nix crate. Thanks 🙏 20

Slide 21

Slide 21 text

Rust × Container Runtime 👍 :+1: ● Performance ● Easy to handle system calls ● A Good fit between low layer and Rust community 21

Slide 22

Slide 22 text

Good fit between low layers and Rust community ● Low Layer Programming 🤝 Rust ○ There are many programmers in the Rust community who like this layer ○ Topics adopted for the linux kernel ● Rustacean, who is also interested in this layer, joined youki to learn more about container technology 22

Slide 23

Slide 23 text

Rust × Container Runtime 😖 :confounded: ● There are no libraries or other assets ● Little knowledge in the Rust community 23

Slide 24

Slide 24 text

Rust × Container Runtime 😖 :confounded: ● There are no libraries or other assets ● Little knowledge in the Rust community 24

Slide 25

Slide 25 text

There are no libraries or other assets ● There are still few libraries compared to the major languages (Go / C) in the container area ○ For example, Go has a library set in the specification repository to parse a JSON file according to the specification ● FFI(Foreign Function Interface)... ? ○ We want to use the full potential of Rust! 25

Slide 26

Slide 26 text

There are no libraries or other assets ● The Issue youki would like to solve in any way possible ● Cut out the codes used in youki and crate it ○ containers/oci-spec-rs ○ cgroup(It's not complete) ● We are trying to create a common integration test tool for the container runtime community 26

Slide 27

Slide 27 text

Rust × Container Runtime 😖 :confounded: ● There are no libraries or other assets ● Little knowledge in the Rust community 27

Slide 28

Slide 28 text

Little knowledge in the Rust community ● There are few Rustacean in the container world ● Youki is a gateway to containers for Rustacean ○ Youki's maintainers have got knowledgeable enough about it to read runC ○ Container people may use it to learn Rust ● Would you like to join us? 28

Slide 29

Slide 29 text

Summary ● Advantages of Rust 🤝 Container Runtime ○ Performance ○ Easy to handle system calls ○ A Good fit between low layers and Rust community ● The problems that youki wants to solve ○ There are no libraries or other assets ○ Little knowledge in the Rust community 29

Slide 30

Slide 30 text

Youki in the future ● Aim for the first release ● Contributing to the container community ○ Testing tools for generic container runtimes ● Consideration of unique features as container runtime ○ Asynchronous processing using io_uring ○ Features using wasm or kernel modules... 🤔 ● We'll have fun developing :) 30

Slide 31

Slide 31 text

Thanks to all the people who already contributed to youki :) 31

Slide 32

Slide 32 text

Thanks you! Any questions? 32