Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Write Container Runtime in Go
Search
tomocy
October 28, 2019
Programming
4
3.1k
Write Container Runtime in Go
Presented in Go Conference 2019 Autumn
https://gocon.jp/sessions/write_container_runtime_in_go/
tomocy
October 28, 2019
Tweet
Share
More Decks by tomocy
See All by tomocy
Work around Dart custom lint rule
tomocy
1
420
Other Decks in Programming
See All in Programming
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
470
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
340
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
140
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
140
Beyond ORM
77web
7
920
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
390
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
情報漏洩させないための設計
kubotak
3
300
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
140
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
790
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Building Applications with DynamoDB
mza
91
6.1k
Navigating Team Friction
lara
183
15k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Code Review Best Practice
trishagee
65
17k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Code Reviewing Like a Champion
maltzj
520
39k
How to Ace a Technical Interview
jacobian
276
23k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
Transcript
Write Container Runtime in Go Go Conference 2019 Autumn Koki
Tomoshige (@towocy)
Write Container Runtime in Go
Write Container Runtime in Go
ίϯςφϥϯλΠϜʹ͍ͭͯ
ίϯςφٕज़ ίϯςφϥϯλΠϜͱ ίϯςφΠϝʔδ
ίϯςφϥϯλΠϜ OCI runtimeʹ४ڌ͍ͯ͠Δ
OCIʢOpen Container Initiativeʣ ίϯςφٕज़ͷඪ४ن֨Λ ࡞͢ΔͨΊͷஂମ
None
runtime.me ίϯςφϥϯλΠϜͱͯ͠ͷ ঢ়ଶͱৼΔ͍ https://github.com/opencontainers/runtime-spec/blob/master/runtime.md
Query State state <container-id> Create create <container-id> <path-to-bundle> Start start
<container-id> Kill kill <container-id> <signal> Delete delete <container-id>
None
Standard Go Project Layout /cmd https://github.com/golang-standards/project-layout#cmd
None
CLI pkg github.com/urfave/cli
None
None
None
None
None
InterfaceͰͷநԽ ༻ऀଆ͕ ٻΊΔৼΔ͍Λఆٛ͢Δ https://github.com/golang/go/wiki/CodeReviewComments#interfaces
None
ίϯςφϥϯλΠϜͷ࣮ʹ͍ͭͯ
ίϯςφϥϯλΠϜ ϗετOS্ͷ Ϧιʔεִ͕ɺ੍ݶ͞Εͨϓϩηε
‘Contain’er ʙΛด͡ࠐΊΔ
ίϯςφϥϯλΠϜ How to contain a process
https://employment.en-japan.com/engineerhub/entry/2019/02/05/103000#ίϯςφͱ ΧʔωϧϦιʔεɺϑΝΠϧγεςϜͷִ Namespaceɺchroot/pivot_root ϋʔυΣΞϦιʔεͷ੍ݶ cgroup ݖݶͷ੍ Capabilityɺseccomp
None
Fork
Fork ϓϩηε ࢠϓϩηε
Fork ϓϩηε ࢠϓϩηε Contain
None
Build Constraints ϑΝΠϧ໊Ͱ ϏϧυରΛ͚Δ https://golang.org/pkg/go/build/#hdr-Build_Constraints
None
None
None
None
Fork ϓϩηε ࢠϓϩηε Contain
https://github.com/rrreeeyyy/container-internship/tree/master/02#linux-namespaces IPC ϓϩηεؒ௨৴Ͱ͏Ϧιʔε Network ωοτϫʔΫσόΠεɺϧʔςΟϯάςʔϒϧ Mount ϑΝΠϧγεςϜπϦʔ PID ϓϩηε ID
User Ϣʔβ IDɺάϧʔϓ ID UTS nodenameɺdomainname
None
Fork
None
Filesystem bundle config.jsonͱrootfs https://github.com/opencontainers/runtime-spec/blob/master/bundle.md
ࢠϓϩηεͷϧʔτ༻ʹ
ࢠϓϩηεͷϧʔτ༻ʹ mount͍ͯ͘͠
ࢠϓϩηεͷϧʔτ༻ʹ mount͍͖ͯ͠ ͦͯ͠pivot_root͢Δ
ࢠϓϩηεʹ / ʹݟ͑Δ
cgroup ϓϩηεʹରͯ͠ ڞ௨ͷϦιʔεཧΛ͢Δ https://gihyo.jp/admin/serial/01/linux_containers/0003
None
None
None
None
None
None
None
None
None
None
None
None
Write Container Runtime in Go
͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ
https://github.com/opencontainers/runtime-spec/blob/master/runtime.md https://github.com/opencontainers/runtime-spec/blob/master/bundle.md https://github.com/golang-standards/project-layout#cmd https://github.com/golang/go/wiki/CodeReviewComments#interfaces https://employment.en-japan.com/engineerhub/entry/2019/02/05/103000#ίϯςφͱ https://golang.org/pkg/go/build/#hdr-Build_Constraints https://github.com/rrreeeyyy/container-internship/tree/master/02#linux-namespaces https://employment.en-japan.com/engineerhub/entry/2019/02/05/103000 https://github.com/tomocy/gocon ࢀߟจݙ
https://speakerdeck.com/kyohmizu/windowskontenaru-men?slide=26 https://speakerdeck.com/tenforward/cndt2019 https://sil.hatenablog.com/entry/why-container-is-secure