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
410
Other Decks in Programming
See All in Programming
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
Ethereum_.pdf
nekomatu
0
460
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
630
受け取る人から提供する人になるということ
little_rubyist
0
250
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
Outline View in SwiftUI
1024jp
1
330
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
200
Featured
See All Featured
Facilitating Awesome Meetings
lara
50
6.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
A Philosophy of Restraint
colly
203
16k
Fireside Chat
paigeccino
34
3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Done Done
chrislema
181
16k
Scaling GitHub
holman
458
140k
Documentation Writing (for coders)
carmenintech
65
4.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
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