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
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
1
560
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
CSC305 Lecture 26
javiergs
PRO
0
140
ドメインイベント増えすぎ問題
h0r15h0
1
270
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
730
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
310
Zoneless Testing
rainerhahnekamp
0
120
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
useSyncExternalStoreを使いまくる
ssssota
6
1k
Featured
See All Featured
KATA
mclloyd
29
14k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Designing for Performance
lara
604
68k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
How STYLIGHT went responsive
nonsquared
95
5.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
BBQ
matthewcrist
85
9.4k
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