Upgrade to Pro — share decks privately, control downloads, hide ads and more …

「入門Kubernetes」入門 / 20180609 GCPUG Hiroshima #4

「入門Kubernetes」入門 / 20180609 GCPUG Hiroshima #4

GCPUG Hiroshima #4 https://gcpug-hiroshima.connpass.com/event/85416/ で発表した際の資料

「入門Kubernetes」には図が少なく動きがイメージしにくいという欠点を補うべく、Kubernetesのリソースなどの動きを図を使って説明してみました。

D98ee74ffe0fafbdc83b23907dda3665?s=128

doublemarket

June 09, 2018
Tweet

Transcript

  1. ʮೖ໳Kubernetesʯೖ໳ 2018೥6݄9೔(౔) GCPUG Hiroshima #4 doublemarket

  2. দӜ ൏ਓ Twitter : dblmkt GitHub : doublemarket

  3. https://yakst.com/ja http://sql-performance-explained.jp https://employment.en-japan.com/engineerhub/entry/2017/06/26/110000

  4. None
  5. ! ධ൑ • Kubernetesॳ৺ऀ޲͚ʹ͓͢͢Ί • جຊ֓೦Λཧղ͢ΔͷʹΑ͍

  6. " ධ൑ • ݪจʹؒҧ͍͕ଟ͍ • ຋༁൛ʹ͸Erattaద༻ࡁΈ • मਖ਼ࡁΈίʔυ • https://github.com/doublemarket/kuar-examples-1-9

  7. " ධ൑ • ೔ຊޠ൛ͷؒҧ͍ • ਖ਼ޡද • https://github.com/doublemarket/kuar-examples-1-9/ wiki/Errata •

    ୈ2࡮Ͱ͍͔ͭ͘मਖ਼ࡁΈ
  8. " ධ൑ • ਤ͕গͳ͍ ͜ͷࢿྉͰิ׬͠ʹདྷ·ͨ͠ʂ

  9. ίϯςφͱ͸ʁ Kubernetesͱ͸ʁ

  10. ෺ཧϚγϯ͔Βίϯςφ΁ ϋʔυ΢ΣΞ OS ϥΠϒϥϦ ΞϓϦ ΞϓϦ ϋʔυ΢ΣΞ ϋΠύʔόΠβ OS ϥΠϒϥϦ

    ΞϓϦ ΞϓϦ OS ϥΠϒϥϦ ΞϓϦ ΞϓϦ ϋʔυ΢ΣΞ OS ϥΠϒ ϥϦ ΞϓϦ ΞϓϦ ϥΠϒ ϥϦ ϥΠϒ ϥϦ ΞϓϦ ΞϓϦ ϥΠϒ ϥϦ ίϯςφ࣮ߦ؀ڥ ෺ཧϚγϯ Ծ૝Ϛγϯ ίϯςφ
  11. ίϯςφͷ؅ཧ Web Web Web Web

  12. ίϯςφͷ؅ཧ Web Web Web Web DB Web Storage Batch

  13. ίϯςφͷ؅ཧ Web Web Web Web DB Web Storage Batch

  14. ίϯςφͷ؅ཧ Web Web Web Web DB Web Storage Batch ؅ཧ͕ͭΒ͍

  15. Kubernetes • ίϯςφΦʔέετϨʔλ • ίϯςφͷσϓϩΠɺεέʔϧɺ؅ཧͷࣗಈԽͷ࢓૊Έ

  16. Kubernetesͷઃܭࢥ૝

  17. ΠϛϡʔλϏϦςΟ Πϯετʔϧ ઃఆมߋ ϛϡʔλϒϧͳ΍Γํ

  18. ΠϛϡʔλϏϦςΟ Πϯετʔϧ ઃఆมߋ ΞϯΠϯετʔϧ Πϯετʔϧ ઃఆมߋ ϛϡʔλϒϧͳ΍Γํ มߋΛੵΈॏͶΔ

  19. ΠϛϡʔλϏϦςΟ Πϯετʔϧ ઃఆมߋ ΞϯΠϯετʔϧ Πϯετʔϧ ઃఆมߋ ΠϯετʔϧࡁΈ Πϝʔδ ϛϡʔλϒϧͳ΍Γํ Πϛϡʔλϒϧͳ΍Γํ

    มߋΛੵΈॏͶΔ
  20. ΠϛϡʔλϏϦςΟ Πϯετʔϧ ઃఆมߋ ΞϯΠϯετʔϧ Πϯετʔϧ ઃఆมߋ ΠϯετʔϧࡁΈ Πϝʔδ ϛϡʔλϒϧͳ΍Γํ Πϛϡʔλϒϧͳ΍Γํ

    ΠϯετʔϧࡁΈ Πϝʔδ มߋΛੵΈॏͶΔ ৽͘͠࡞Γ௚͢
  21. એݴతઃఆ 3.times{ WebαʔόΛىಈ
 } ໋ྩతઃఆ

  22. એݴతઃఆ 3.times{ WebαʔόΛىಈ
 } Webαʔό਺ : 3 ໋ྩతઃఆ એݴతઃఆ

  23. ࣗݾճ෮γεςϜ Web Pod Node Web Pod Node Web Pod Node

    3ͭͷίϯςφΛಈ͔͢
  24. ࣗݾճ෮γεςϜ Web Pod Node Web Pod Node Web Pod Node

    1୆ϊʔυ͕མͪͨΒ
  25. ࣗݾճ෮γεςϜ Web Pod Node Web Pod Node Web Pod Node

    ৗʹίϯςφ͕3ͭಈ͘Α͏ʹ͸ͨΒ͘
  26. ࣗݾճ෮γεςϜ Web Pod Node Web Pod Node Web Pod Node

    Web Pod Node 4ͭ໨ΛखಈͰ࡞੒ͯ͠΋
  27. ࣗݾճ෮γεςϜ Web Pod Node Web Pod Node Web Pod Node

    Web Pod Node ৗʹίϯςφ͕3ͭಈ͘Α͏ʹ͸ͨΒ͘
  28. KubernetesͷϦιʔε

  29. Node Node

  30. None
  31. Pod Web ಉظ Node Pod ߋ৽ ഑৴

  32. Volume Web ಉظ Node Pod ߋ৽ ഑৴ Volume

  33. Podͷઃܭ Word Press DB Node Pod Node Node

  34. Podͷઃܭ Word Press DB Node Pod Node Node Word Press

    DB Pod Word Press DB Pod εέʔϧ͍ͨ͠ͷ͸͜ͷ୯Ґʁ
  35. Podͷઃܭ DB Node Pod Node Node Word Press Pod Word

    Press Pod Word Press Pod Word Press Pod Word Press Pod Word Press Pod DB Pod ࣮ࡍʹ͸͜ͷΑ͏ʹεέʔϧ͢Δ͸ͣ…
  36. Podͷઃܭ Web ಉظ Node Pod ߋ৽ ഑৴ Volume

  37. ಉ͡PodʹೖΕΔ΂͖ίϯςφ • ͓ޓ͍͕ಉҰNode্ʹͳ͍ͱಈ͔ͳ͍ • Ұॹʹεέʔϧ͢Δඞཁ͕͋Δ

  38. Label / Annotation Web ಉظ Node Pod ߋ৽ ഑৴

  39. Label / Annotation Web ಉظ Node Pod ߋ৽ ഑৴ type=sync

    type=w eb disk=ssd
  40. Service kuard Node Pod kuard Node Pod env=prod ໊લ :

    alpaca-prod ϥϕϧ : app=alpaca, env=prod Service app=alpaca env=prod app=alpaca
  41. Service kuard Node Pod kuard Node Pod env=prod Service app=alpaca

    env=prod app=alpaca ΫϥελIP 10.115.245.13 alpaca-prod.default.svc.cluster.local ໊લ : alpaca-prod ϥϕϧ : app=alpaca, env=prod
  42. ServiceʹNodePortΛઃఆ kuard Node Pod kuard Node Pod env=prod Service app=alpaca

    env=prod app=alpaca ΫϥελIP 10.115.245.13 alpaca-prod.default.svc.cluster.local ໊લ : alpaca-prod ϥϕϧ : app=alpaca, env=prod NodePort 32711
  43. ReplicaSet Node Node Node ϨϓϦΧ : 2 ϥϕϧ : app=kuard

    ίϯςφ(Pod) : kuard ReplicaSet
  44. ReplicaSet kuard Node Pod Node kuard Node Pod app=kuard app=kuard

    ϨϓϦΧ : 2 ϥϕϧ : app=kuard ίϯςφ(Pod) : kuard ReplicaSet
  45. ReplicaSet ɿௐ੔ϧʔϓ kuard Node Pod Node kuard Node Pod ϨϓϦΧ

    : 4 ϥϕϧ : app=kuard ίϯςφ(Pod) : kuard ReplicaSet app=kuard app=kuard
  46. ReplicaSet : ௐ੔ϧʔϓ kuard Node Pod kuard Node Pod kuard

    Node Pod ϨϓϦΧ : 4 ϥϕϧ : app=kuard ίϯςφ(Pod) : kuard ReplicaSet app=kuard app=kuard app=kuard kuard Pod app=kuard
  47. ReplicaSet : ௐ੔ϧʔϓ kuard Node Pod kuard Node Pod kuard

    Node Pod app=kuard app=kuard app=kuard kuard Pod app=kuard ϨϓϦΧ : 4 ϥϕϧ : app=kuard ίϯςφ(Pod) : kuard ReplicaSet
  48. ReplicaSet : ௐ੔ϧʔϓ kuard Node Pod kuard Node Pod kuard

    Node Pod app=kuard app=kuard app=kuard kuard Pod app=kuard ϨϓϦΧ : 4 ϥϕϧ : app=kuard ίϯςφ(Pod) : kuard ReplicaSet
  49. DaemonSet Node Node ίϯςφ(Pod) : fluentd DaemonSet

  50. DaemonSet Node Node ίϯςφ(Pod) : fluentd DaemonSet fluentd Pod app=fluentd

    fluentd Pod app=fluentd
  51. DaemonSet Node Node Node ίϯςφ(Pod) : fluentd DaemonSet fluentd Pod

    app=fluentd fluentd Pod app=fluentd
  52. DaemonSet Node Node Node ίϯςφ(Pod) : fluentd DaemonSet fluentd Pod

    app=fluentd fluentd Pod app=fluentd fluentd Pod app=fluentd
  53. DaemonSet : Nodeͷ੍ݶ Node Node Node ϥϕϧ : ssd=true ίϯςφ(Pod)

    : fluentd DaemonSet ssd=true ssd=true
  54. DaemonSet : Nodeͷ੍ݶ Node Node Node ϥϕϧ : ssd=true ίϯςφ(Pod)

    : fluentd DaemonSet fluentd Pod app=fluentd fluentd Pod app=fluentd ssd=true ssd=true
  55. Job : 1ճݶΓ ໊લ : oneshot ίϯςφ(Pod) : kuard completions

    : 1 parallelism : 1 Job Node
  56. Job : 1ճݶΓ ໊લ : oneshot ίϯςφ(Pod) : kuard completions

    : 1 parallelism : 1 Job Node kuard Pod job=oneshot
  57. Job : 1ճݶΓ ໊લ : oneshot ίϯςφ(Pod) : kuard completions

    : 1 parallelism : 1 Job Node kuard Pod job=oneshot
  58. Job : Ұఆ਺੒ޭ͢Δ·Ͱ࣮ߦ Node Node Node Node Node ໊લ :

    oneshot ίϯςφ(Pod) : kuard completions : 10 parallelism : 5 Job
  59. Job : Ұఆ਺੒ޭ͢Δ·Ͱ࣮ߦ Node kuard Pod job=oneshot Node kuard Pod

    job=oneshot Node kuard Pod job=oneshot Node kuard Pod job=oneshot Node kuard Pod job=oneshot ໊લ : oneshot ίϯςφ(Pod) : kuard completions : 10 parallelism : 5 Job
  60. Job : Ұఆ਺੒ޭ͢Δ·Ͱ࣮ߦ Node kuard Pod job=oneshot kuard Pod job=oneshot

    Node kuard Pod job=oneshot kuard Pod job=oneshot Node kuard Pod job=oneshot kuard Pod job=oneshot Node kuard Pod job=oneshot kuard Pod job=oneshot Node kuard Pod job=oneshot kuard Pod job=oneshot ໊લ : oneshot ίϯςφ(Pod) : kuard completions : 10 parallelism : 5 Job
  61. Job : Ұఆ਺੒ޭ͢Δ·Ͱ࣮ߦ ໊લ : oneshot ίϯςφ(Pod) : kuard completions

    : 10 parallelism : 5 Job Node kuard Pod job=oneshot kuard Pod job=oneshot Node kuard Pod job=oneshot kuard Pod job=oneshot Node kuard Pod job=oneshot kuard Pod job=oneshot Node kuard Pod job=oneshot kuard Pod job=oneshot Node kuard Pod job=oneshot kuard Pod job=oneshot
  62. ConfigMap / Secret kuard Node Pod another-param = another-value extra-param

    = extra-value my-config.txt parameter1 = value1 parameter2 = value2 ConfigMap
  63. ConfigMap / Secret kuard Node Pod another-param = another-value extra-param

    = extra-value my-config.txt parameter1 = value1 parameter2 = value2 ConfigMap ConfigMap volume ANOTHER_PARAM=another-value EXTRA_PARAM=extra-value /config +- another-param +- extra-param +- my-config.txt +- parameter1 +- parameter2
  64. Deployment nginx Node Pod Node ϨϓϦΧ : 1 ϥϕϧ :

    run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet ϨϓϦΧ : 1 ໊લ : nginx ίϯςφ : nginx:1.7.12 Deployment run=nginx
  65. Deployment ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ : nginx:1.7.12

    Deployment ϨϓϦΧ : 1 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx Node Pod Node
  66. Deployment ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ : nginx:1.7.12

    Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx Node Pod Node nginx Pod
  67. Deployment ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ : nginx:1.7.12

    Deployment ϨϓϦΧ : 1 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx Node Pod Node nginx Pod
  68. Deploymentઓུ : Recreate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod
  69. Deploymentઓུ : Recreate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod
  70. Deploymentઓུ : Recreate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod nginx 1.9.10 Pod nginx 1.9.10 Pod ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.9.10 ReplicaSet run=nginx
  71. Deploymentઓུ : RollingUpdate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 maxAvailable : 1 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod
  72. Deploymentઓུ : RollingUpdate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 maxAvailable : 1 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod
  73. Deploymentઓུ : RollingUpdate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 maxAvailable : 1 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.9.10 ReplicaSet run=nginx nginx 1.9.10 Pod
  74. Deploymentઓུ : RollingUpdate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 maxAvailable : 1 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.9.10 ReplicaSet run=nginx nginx 1.9.10 Pod
  75. Deploymentઓུ : RollingUpdate ϨϓϦΧ : 2 ໊લ : nginx ίϯςφ

    : nginx:1.9.10 maxAvailable : 1 Deployment ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.7.12 ReplicaSet run=nginx nginx 1.7.2 Node Pod Node nginx 1.7.2 Pod ϨϓϦΧ : 2 ϥϕϧ : run=nginx ίϯςφ : nginx:1.9.10 ReplicaSet run=nginx nginx 1.9.10 Pod nginx 1.9.10 Pod
  76. StatefulSet Node Node Node StatefulSet ϨϓϦΧ : 1 ϥϕϧ :

    app=mongo ίϯςφ : mongo:3.4.1
  77. StatefulSet Node Node mongo 0 Node Pod ϨϓϦΧ : 1

    ϥϕϧ : app=mongo ίϯςφ : mongo:3.4.1 StatefulSet app=m ongo
  78. StatefulSet mongo 1 Node Pod Node mongo 0 Node Pod

    app=m ongo ϨϓϦΧ : 3 ϥϕϧ : app=mongo ίϯςφ : mongo:3.4.1 StatefulSet app=m ongo
  79. StatefulSet mongo 1 Node Pod Node mongo 0 Node Pod

    app=m ongo ϨϓϦΧ : 3 ϥϕϧ : app=mongo ίϯςφ : mongo:3.4.1 StatefulSet app=m ongo mongo 2 Pod app=m ongo
  80. StatefulSet mongo 1 Node Pod Node mongo 0 Node Pod

    app=m ongo ϨϓϦΧ : 2 ϥϕϧ : app=mongo ίϯςφ : mongo:3.4.1 StatefulSet app=m ongo mongo 2 Pod app=m ongo
  81. PersistentVolume mongo 1 Node Pod Node mongo 0 Node Pod

    app=m ongo ϨϓϦΧ : 3 ϥϕϧ : app=mongo ίϯςφ : mongo:3.4.1 StatefulSet app=m ongo mongo 2 Pod app=m ongo ωοτϫʔΫετϨʔδ PersistentVolume
  82. ͞Βʹ͓ษڧ͢Δʹ͸

  83. ৘ใݯ • ެࣜυΩϡϝϯτ (ӳޠ) https://kubernetes.io/ • ॻ੶ • Kubernetes in

    Action (ӳޠ) • ϒϩά • Google Cloud (ӳޠ) https://medium.com/google-cloud • ެࣜϒϩά (ӳޠ) https://kubernetes.io/blog/
  84. ৘ใݯ • SlackϫʔΫεϖʔε https://slack.kubernetes.io/ • ೔ຊޠνϟϯωϧ #jp-users, #jp-events • Podcast

    • Kubernetes Podcast (ӳޠ) https://kubernetespodcast.com/ • ษڧձɾΧϯϑΝϨϯε • Kubernetes Meetup Tokyo (೔ຊޠ) https://k8sjp.connpass.com/ • KubeCon (ӳޠ)