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
Kubernetesの事始め
Search
Iku Yamamoto
February 02, 2018
Technology
4
1.5k
Kubernetesの事始め
Kubernetes(k8s)の初学者や導入検討者向けの資料
Iku Yamamoto
February 02, 2018
Tweet
Share
Other Decks in Technology
See All in Technology
機械学習を「社会実装」するということ 2025年版 / Social Implementation of Machine Learning 2025 Version
moepy_stats
4
520
20240522 - 躍遷創作理念 @ PicCollage Workshop
dpys
0
310
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
110
2025年のARグラスの潮流
kotauchisunsun
0
740
KMP with Crashlytics
sansantech
PRO
0
190
テストを書かないためのテスト/ Tests for not writing tests
sinsoku
1
160
WantedlyでのKotlin Multiplatformの導入と課題 / Kotlin Multiplatform Implementation and Challenges at Wantedly
kubode
0
220
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
170
.NET AspireでAzure Functionsやクラウドリソースを統合する
tsubakimoto_s
0
170
Building Scalable Backend Services with Firebase
wisdommatt
0
110
商品レコメンドでのexplicit negative feedbackの活用
alpicola
1
220
ドメイン駆動設計の実践により事業の成長スピードと保守性を両立するショッピングクーポン
lycorptech_jp
PRO
3
640
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Facilitating Awesome Meetings
lara
50
6.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
KATA
mclloyd
29
14k
Typedesign – Prime Four
hannesfritz
40
2.5k
A Tale of Four Properties
chriscoyier
157
23k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
We Have a Design System, Now What?
morganepeng
51
7.3k
Fireside Chat
paigeccino
34
3.1k
Transcript
Kubernetesͷίτ࢝Ί 2018/01/30 ࢁຊ ҭ 1
• ໊લ: ࢁຊ ҭ(twitter_id: @Mt_mo1019) • ݱࡏͷࣄ • RDB PaaS։ൃ
• ࠓ·Ͱ • PostgreSQLͷݕূ etc… Who am I ? 2
• kubernetes(k8s)ͷॳֶऀɾಋೖݕ౼ऀ͚ • k8sͬͯԿʁ • k8sΛͲ͏͍ͬͯͬͯΔͷʁ • k8sΛಋೖ͢ΔͱԿ͕ྑ͘/ѱ͘ͳΔͷʁ ࠓ͢͜ͱͱ 3
• ίϯςφཧͷ౷߹ج൫ • ίϯςφͷࣗಈσϓϩΠɾ෮چ • ج൫ and ίϯςφͷεέʔϧΞτ • ϩʔυόϥϯγϯά
• ൿີใίϯϑΟάͷ౷߹ཧ what is k8s? 4
Master Server Master Server k8sͷΞʔΩςΫνϟ 5 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server kubectl Pod Pod Pod Pod Auto Deploy
Master Server Master Server k8sͷΞʔΩςΫνϟ 6 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server Pod Pod Pod Pod Crash
Master Server Master Server k8sͷΞʔΩςΫνϟ 7 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server Pod Pod Pod Pod ReDeploy Crash Pod
• k8s͕ཧ͢ΔΦϒδΣΫτͷ࠷খ୯Ґ • Pod ≒ Container • PodίϯςφΛแ͢Δ • PodෳͷίϯςφΛ࣋ͯΔ
what is Pod? 8
what is Pod normally 9 Container ex) nginx Pod Container
ex) exporter, fluentd etc • αʔϏεͱड͚࣋ͭ ϝΠϯͷcontainer • αϒͷcontainer • agentܥͷϓϩηε Λड͚࣋ͭ • sidecarͱݴΘΕΔ
• σϓϩΠͷͨΊͷmanifestϑΝΠϧΛॻ͘ • ఆٛ͢Δ͜ͱଟذʹΘͨΔ • Podͷ༻్ʹΑΓछผΛม͑Δ • PodҎ֎ʹαʔϏεʹඞཁͳՃఆٛ • manifestΛ࡞Εଞͷk8s
clusterʹҠ২Ͱ͖Δ σϓϩΠ͢Δํ๏ 10
ओͳdeploy manifests 11 ఆٛ ֓ཁ Deployments ҰൠతͳPodͷσϓϩΠ StatefulSets StatefulͳΞϓϦέʔγϣϯͷσϓϩΠ DaemonSet
NodeશͷσϓϩΠ Jobs daemonize͠ͳ͍ΞϓϦͷσϓϩΠ CronJob Jobsͷఆظతͳ࣮ߦ Service PodͷΞΫηε੍ޚ ConfigMap PodʹΠϯδΣΫγϣϯ͢ΔϑΝΠϧఆٛ PersistentVolume ӬଓԽ͢ΔετϨʔδͷఆٛ
• ҰൠతͳσϓϩΠʹར༻ • ࢦఆͨ͠PodΛNodeʹσϓϩΠ • σϓϩΠ͢ΔPodͷࢦఆ Deployments 12
Master Server Master Server Deployments 13 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server Pod Pod Replicas=2
• StatefulͳΞϓϦέʔγϣϯͰར༻ • PodͷىಈΛॱ࣍ͬͯσϓϩΠ͢Δ • Podͷ໊લ͕Ұఆʹఆ·ΔͷͰ໊લղܾͷ લఏ͕Ͱ͖Δ • clusterߏ͕Ͱ͖ΔAppʹ༗ޮ StatefulSets
14
Master Server Master Server StatefulSets 15 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server 1st Pod Replicas=2
Master Server Master Server StatefulSets 16 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server 1st Pod Replicas=2 2nd Pod
• શNodesʹPodΛஔ͢Δ࣌ʹར༻ • NodeͰڞ௨తʹར༻͢ΔagentͳͲ • fluentdͳͲɺnodeʹແ݅ʹར༻͢ΔAppʹ༗ޮ DaemonSet 17
Master Server Master Server DaemonSet 18 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server Pod Pod Pod
• Ұ͚࣮ͩߦ͢Δॲཧʹར༻ • batchDatabaseͷmigrate࣌ͷscript࣮ߦ • Job͕ࣦഊͨ͠߹ʹ࠶࣮ߦͰ͖Δ Jobs 19
Master Server Master Server Jobs 20 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server Pod Ͳ͔͜ͷNodeͰ࣮ߦ
• JobsΛఆظ࣮ߦ͢Δࡍʹར༻ • ఆظbatchॲཧΛ࣮ߦͰ͖Δ • crontabΛClusterͰ੍ޚͰ͖Δ • ه๏crontabͱಉ༷ CronJob 21
Master Server Master Server CronJob 22 Master Nodes Nodes(Minion) Master
Server kubernetes cluster Node Server Node Server Node Server Pod Ͳ͔͜ͷNodeͰJobΛىಈ ఆظ࣮ߦ
• NodeͷΞΫηεͱPodΛ݁ͼ͚ͭΔ • ղ์͢ΔαʔϏε(Pod)Λఆٛ • Pod͕ଞͷNodeʹҠͬͯै͢Δ • ෳPod͕͋Δ߹ɺΑ͠ͳʹৼΓ͚Δ Service 23
Service 24 Nodes(Minion) kubernetes cluster Node Server Node Server Node
Server Pod Pod Service ͲͷNodeʹΞΫηεͯ͠ ݁ͼ͍ͭͨPodʹಧ͘
• PodʹfileΛInjectionͰ͖Δ • ConfigΛfileͰඞཁͱ͢ΔAppͰར༻ ConfigMap 25
• σʔλӬଓԽ͕Ͱ͖ΔετϨʔδͷఆٛ • Access Mode͕͋ΔͷͰݕ౼͕ඞཁ • https://kubernetes.io/docs/concepts/storage/ persistent-volumes/#access-modes Persistent Volumes
26
• manifestϑΝΠϧ͕࡞ڥ͝ͱʹͰ͖Δ • devڥɺtestڥɺproductionڥ etc… • ಉ͡ఆٛ(yaml)Λཧ͢Δ͜ͱʹͳΔ • ಉ͡هड़templateԽ͍ͨ͠ manifestΛ࡞͍ͬͯ͘ͱى͖Δ
27
• manifestϑΝΠϧΛtemplateԽͯ͠ཧ • https://github.com/kubernetes/helm • Podͷىಈ/ߋ৽લޙʹhookͯ͠JobΛڬΊΔ what is helm? 28
• Go templateΛར༻ͨ͠manifestཧ • templatesͱvaluesͷ2ϑΝΠϧͰཧ • values͚ͩΛڥ͝ͱʹมߋ͢Δ • pre/postॲཧΛ࣮ࢪͰ͖Δ what
is helm? 29
• ެࣜDocumentΛಡΉ(ࣗಈ༁Ͱ݁ߏ៉ྷ) • https://kubernetes.io/docs/home/ • ଞਓͷmanifestΛಡΈࠐΉ k8sͷา͖ํ 30
• ίϯςφͳͷͰىಈ͕ૣ͍ • ։ൃऀͷ༗ޮͳػೳ͕ଟ͍ • εέʔϧΞτ • ো࣌ͷࣗಈFailOver͕Α͍ • CronJobͷΫϥελ੍ޚ
• ͲͷNodeʹΞΫηεͯ͠Podʹ౸ୡͰ͖Δ • Document͕ἧ͍ͬͯΔɻӳޠ͕៉ྷɻ • ॳظֶशίετ͕ߴ͍ ར༻ऀͱͯ͠ͷk8sͷॴײ 31
• ։ൃڥͷk8sͷ࠶ߏங • Stagingڥͷނো ӡ༻தʹىͬͨ͜͜ͱ 32
• ։ൃڥͷഁଛ • Podؒͷ௨৴͕औΕͳ͘ͳͬͨ • ࠶ߏஙͱ෮چͷൺֱͰ࠶ߏஙͨ͠ k8sͷ࠶ߏங 33
k8sͷߏஙํ๏ 34 ߏஙํ๏ Pros. Cons. ࣗલͷansible ࣗલͰ࡞ΕΔͷͰॊೈ ै͕େม kubeadm kubenetesຊՈͷϨϙδτϦ
શͯͷΦϖϨʔγϣϯͷ ίʔυԽΛࢦ͢ https://github.com/kubernetes/ kubeadm ·ͩ։ൃ్த starগͳΊ kube-spray star͕ଟ͍ ෳͷύλʔϯʹରԠͯ͠ ͍Δ https://github.com/kubernetes- incubator/kubespray ຊՈϨϙδτϦͰͳ͍ playbookࣗମෳࡶ
• Podͷ໊લղܾ͕Ͱ͖ͳ͘ͳͬͨ • kube-dnsͱNWPluginͷෳ߹ࣄҊ • ͷݪҼෆ໌ͳ·· • tokenͷ࠶ൃߦPodͷ࠶ੜͳͲɺ༷ʑͳ ରԠ(issuesΛࢀߟ)Ͱ෮چ Stagingڥͷނো
35
• ղܾʹ3͔͔ͬͨ • Podͷࣗಈ෮چʹΑΓσϓϩΠ͍ͯͨ͠ϛυ ϧΣΞͷΫϥελ่յ • ͱͱίϯςφલఏͷઃܭʹͳ͍ͬͯͳ ͍ΞϓϦҙ StagingڥͷނোͷӨڹ 36
• ྑ͍ͱ͜Ζ • ։ൃεϐʔυ͕ͱͯૣ͍ • ػೳଟ͘ἧ͍ͬͯͯศར • ѱ͍ͱ͜Ζ • ॳظֶशίετ͕ߴ͍
• ӡ༻ൣғ͕ଟذʹΔ • NW plugin͕Կ͕͍͍͔Θ͔Βͳ͍ • ReadWriteManyʹରԠͨ͠PersistentVolume͕গͳ͍ ॴײ 37
• k8sΛར༻͢ΔͳΒ • GKEͳͲͷڊਓͷݞͷ্ʹཱͭ • ࣗ৫Ͱ͏ͳΒઐ༻ͷӡ༻෦ୂΛ༻ҙ͢Δ • ։ൃऀʹͱͯخ͍͠ػೳ͕ଟ͍ • ίϯςφͰͷ։ൃ͕Ͱ͖ΔΤϯδχΞ͕ඞਢ
૯ׅ 38