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
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
200
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
Lambdaと地方とコミュニティ
miu_crescent
2
370
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
130
いざ、BSC討伐の旅
nikinusu
2
780
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
9
1.1k
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
Engineer Career Talk
lycorp_recruit_jp
0
190
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
300
Featured
See All Featured
Designing for Performance
lara
604
68k
Unsuck your backbone
ammeep
668
57k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
A designer walks into a library…
pauljervisheath
204
24k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Statistics for Hackers
jakevdp
796
220k
Embracing the Ebb and Flow
colly
84
4.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Git: the NoSQL Database
bkeepers
PRO
427
64k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
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