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
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
110
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
140
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
170
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
15
6.3k
実務につなげる数理最適化
recruitengineers
PRO
6
600
うちにも入れたいDatadog
recruitengineers
PRO
2
240
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
160
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
190
Classmethod_regrowth_2024_tokyo_security_identity_governance_summary
hiashisan
0
970
Wantedly での Datadog 活用事例
bgpat
1
160
Oracle Cloud Infrastructure IaaS 新機能アップデート 2024/9 - 2024/11
oracle4engineer
PRO
1
120
ABEMA スマートテレビアプリケーションのパフォーマンス改善 〜業界トップクラスを目指して〜 / Performance Improvements on ABEMA Smart TV App
nodaguti
0
290
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Docker and Python
trallard
41
3.1k
Side Projects
sachag
452
42k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Building Adaptive Systems
keathley
38
2.3k
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