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

Introduction to Kubernetes Using GKE

Introduction to Kubernetes Using GKE

lanocci

June 19, 2018
Tweet

More Decks by lanocci

Other Decks in Technology

Transcript

  1. ໌೔͔Β࢖͑Δ
    Kubernetes ೖ໳
    ~جૅ͔ΒॳΊͯͷσϓϩΠ~
    Supporterz CoLab ษڧձ
    Jun. 19, 2018
    Ӝ໺ ߛҰ / URANO, Koichi (@lanocci)
    SRE at Adtech Studio, CyberAgent, Inc.

    View full-size slide

  2. ໨࣍
    1. ࣗݾ঺հ
    2. ຊ೔ͷ͓඼ॻ͖
    3. લఏ஌ࣝͷ͓͞Β͍
    4. Kubernetesͷதͷ֓೦ʢຊ୊ʣ
    5. ࣄྫ঺հʢ෭୊ᶃʣ
    6. ίϚϯυϥΠϯπʔϧͱ͔ͷ঺հʢ෭୊ᶄʣ

    View full-size slide

  3. ࣗݾ঺հ
    • Ӝ໺ɹߛҰ (@lanocci)
    • גࣜձࣾαΠόʔΤʔδΣϯτ
    • Πϯλʔωοτ޿ࠂͷΠϯϑϥ΍ͬͯ·͢
    • Kubernetesྺ: GKEͰ໿1೥
    • ࡢ೥7݄·Ͱ͸SIerͰέʔϒϧςϨϏاۀͷγεςϜ։ൃɾӡ༻
    • CKA (Certified Kubernetes Administrator) ϗϧμʔ(#366)
    Koichi Urano
    April 1, 2018 CKA-1800-0366-0100
    1 / 1

    View full-size slide

  4. ຊ೔ͷ͓඼ॻ͖

    View full-size slide

  5. ͷલʹͪΐͬͱΞϯέʔτ

    View full-size slide

  6. Assumed Listeners (Readers)
    • ͜Ε͔ΒKubernetesΛ৮ͬͯΈΑ͏ͱࢥ͍ͬͯΔਓ
    • KubernetesٴͼGKEΛ৮ͬͯΈ͚ͨͲͳΜ͔Α͘Θ
    ͔ΒΜͱ͍͏ਓ
    • KubernetesٴͼGKEʹڵຯ͋Δਓ
    • ΋͏݁ߏ͍͡ΕΔΑɺͱ͍͏ਓ͸ੋඇஆ͔͍໨Ͱݟ
    क͍͚ͬͯͨͩΔͱخ͍͠Ͱ͢

    View full-size slide

  7. The Goal of This Talk
    • ʮKubernetesͬͯͳʹʁΑ͘Θ͔ΒΜʯͱ͍͏ਓ
    ͕ɺKubernetesͰΞϓϦΛಈ͔͢Πϝʔδ͕ͳΜͱ
    ͳ͘Ͱ͖ΔΑ͏ʹͳΔ͜ͱ
    • ʮKubernetes৮ͬͯΈ͚ͨͲ࠳ંͨ͠ʯͱ͍͏ਓ
    ͕΋͏Ұ౓ϋνϚΩΛకΊ௚͖͔͚ͬ͢ͱͳΔ͜ͱ
    • ໌೔͔ΒGKEͰ༡ΜͰΈ͍ͯͩ͘͞Ͷʂʂ

    View full-size slide

  8. This Talk Includes …
    • શ͘Կ΋஌Βͳ͔ͬͨ๻͕Kubernetes্ʹΞϓϦ
    έʔγϣϯΛߏஙͰ͖ΔΑ͏ʹͳΔ·ͰʹֶΜͩ͜ͱ
    • Kubernetesͷجຊతͳ֓೦ͱ͔ߏ੒ͱ͔
    • KubernetesΛ࢖͏ͨΊͷಓ۩ཱͯ
    • GKEͷجຊతͳ࢖͍ํ

    View full-size slide

  9. This Talk Doesn’t Include …
    • ϕετϓϥΫςΟεతͳ࿩Ͱ͸͋Γ·ͤΜ
    • GCPͷجຊతͳ৮ΓํʢϩάΠϯͱ͔ϓϩδΣ
    Ϋτ࡞੒ͱ͔ʣ
    • KubernetesΫϥελࣗମͷΞʔΩςΫνϟৄࡉ
    • Dockerͷࡉ͔͍࿩

    View full-size slide

  10. Bottom Line First
    • Kubernetes৮Γ࢝ΊΔΜͩͬͨΒͱΓ͋͑ͣ
    DeploymentͱService͍ͬͯ͡༡ΜͰΈ·
    ͠ΐ͏
    • ʢGKE࢖͏ͱ؆୯ʹ࢝ΊΒΕΔΑ

    View full-size slide

  11. ࢿྉͱ͔
    • ࠓ೔࢖͏αϯϓϧ͸͜͜ʹஔ͍ͯ͋Γ·͢
    • https://github.com/lanocci/getting-started-kubernetes
    • ࢿྉ͸͜͜ʹ͋Γ·͢
    • https://speakerdeck.com/lanocci/introduction-to-
    kubernetes-using-gke

    View full-size slide

  12. લఏ஌ࣝͱ͔

    View full-size slide

  13. What’s Docker Engine?
    • ʮίϯςφʯͷ࣮ߦ؀ڥΛఏڙ
    • ϑϨʔϜϫʔΫͷόʔδϣϯͳͲɺ͍ΖΜͳґଘؔ܎Λʮίϯςφʯ
    ͷதʹด͡ࠐΊΔ͜ͱͰɺҠ২ੑͷߴ͍ΞϓϦέʔγϣϯΛ࡞Δ͜ͱ
    ͕Ͱ͖Δɹɹ(Build Once, Run Anywhere) ⁶ PaaS
    • ίϯςφͷ࡞੒ɺ࡟আ͸ߴ଎ͳͷͰෛՙঢ়گʹΑͬͯॊೈʹϦιʔε
    Λ࢖͍෼͚ΒΕΔͱ͍͏ϝϦοτ͕͋Δ
    • Docker୯ମͰ͸ಉҰϗετ಺ͷίϯςφ͔͠؅ཧͰ͖ͳ͍
    ɹɹɹ→ͪΌΜͱ࢖͏ͳΒΦʔέετϨʔγϣϯγεςϜ͕ඞཁ

    View full-size slide

  14. What’s Kubernetes?
    • ίϯςφΛ࢖ͬͨΞϓϦέʔγϣϯͷσϓϩΠɺεέʔϧɺ؅ཧΛࣗಈԽ͢
    ΔΦʔϓϯιʔεγεςϜ
    • Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications. (https://
    kubernetes.io/)
    • DockerͰ΋ެࣜαϙʔτ͞ΕͨΓʢDocker for Mac ʹඪ४౥ࡌʣɺઌ೔
    AWSͰ΋KubernetesͷαʔϏε͕GA͞ΕͨΓͰɺΦʔέετϨʔγϣϯ
    πʔϧͷ΄΅σϑΝΫτελϯμʔυͱݴ͑Δײ͡
    • Docker Engine౳Λ࢖ͬͯ࡞੒ͨ͠ΞϓϦέʔγϣϯΛෳ਺ͷαʔόʹσϓ
    ϩΠͯ͠ӡ༻͢ΔͨΊʹඞཁͳػೳΛఏڙͯ͘͠ΕΔ
    • ΞϓϦέʔγϣϯಉ࢜Λ࿈ܞͤͨ͞ΓɺϚγϯϦιʔεΛ؅ཧͨ͠Γɺ֎෦͔ΒͷΞΫηεํ๏Λఏڙͨ͠ΓɺΞϓϦέʔγϣϯͷΞοϓσʔτख
    ஈΛఏڙͨ͠Γ
    • Docker͚ͩ͡Όͳͯ͘rktͱ͔΋࢖͑ΔΒ͍͠

    View full-size slide

  15. What’s GKE?
    • Google Kubernetes Engineͷུ
    • ʢࡢ೥຤ࠒ·Ͱ͸Google Container Engineʣ
    • Google Cloud Platform ͷͳ͔ͰKubernetes
    Λ࢖ͬͨίϯςφج൫Λఏڙ͢ΔαʔϏε

    View full-size slide

  16. Why GKE?
    • PCϩʔΧϧ΍ɺGCEͳͲͷVMʹKubernetesΛߏங͢Δ͜ͱ΋Ͱ͖Δ͕ɺ
    ͦΕΛ͢Δʹ͸Kubernetes಺෦ͷΞʔΩςΫνϟʹର͢Δཧղ͕ඞཁ
    • ಺෦ωοτϫʔΫͷઃఆ΋ผ్ඞཁͩͬͨΓͯ݁͠ߏͦ͜Ͱ٧·ͬͨΓ͢
    Δ
    • खͬऔΓૣ͘KubernetesΛཧղ͢ΔͨΊʹ͸·ͣɺϚωʔδυαʔϏεΛ
    ࢖ͬͯΈΔͷ͕ۙಓͩͱࢥ͍·͢
    • ͔͠΋ɺGKE͸ແྉ࿮Ͱ݁ߏ৭ʑ͍͡ΕΔͷͰΦεεϝ
    • $300෼ͷແྉ࿮͕1೥ؒ࢖͑Δ
    • minikubeͰ΋͍͍͚Ͳtype: loadBalancerͱ͔Ͱ֎෦ެ։Ͱ͖Δͷ͸ศར

    View full-size slide

  17. Concepts of Kubernetes
    (And Related Ideas)

    View full-size slide

  18. ʢࢀߟʣArchitecture of Kubernetes
    https://kubernetes.io/docs/concepts/architecture/cloud-controller/
    Nodes

    View full-size slide

  19. Components of Kubernetes
    https://kubernetes.io/docs/tutorials/kubernetes-basics/cluster-intro/

    View full-size slide

  20. جຊ֓೦ᶃ - Cluster
    • Kubernetesͷ؀ڥΛߏங͢Δ্ͰҰ൪େ͖͍
    ୯Ґ
    • ҰͭͷClusterͷதʹNode, Pod, Service౳ͷ
    ߏ੒ཁૉΛ࡞͍ͬͯ͘(ޙड़)
    • (MasterͱNode͔Βߏ੒͞ΕΔ)

    View full-size slide

  21. Components of Kubernetes
    https://kubernetes.io/docs/tutorials/kubernetes-basics/cluster-intro/

    View full-size slide

  22. جຊ֓೦ᶄ - Master
    • Kuberentes Clusterͷ؅ཧશൠΛߦ͏
    • ΞϓϦέʔγϣϯͷঢ়ଶ؅ཧ΍ͦΕʹԠͨ͡εέδϡʔϦϯά౳
    • kubectlίϚϯυ(ޙड़)΍Kubernetes API͸͜
    ͜Ͱड͚෇͚ͯॲཧ͞ΕΔ
    • GKEΛ࢖͏৔߹ɺ͜͜͸ϚωʔδυαʔϏε
    ʹͳ͍ͬͯΔ

    View full-size slide

  23. Components of Kubernetes
    https://kubernetes.io/docs/tutorials/kubernetes-basics/cluster-intro/

    View full-size slide

  24. جຊ֓೦ᶅ - Node
    • ίϯςφ͕഑ஔ͞ΕΔϚγϯ(෺ཧϚγϯ / VM)
    • ͜ͷNodeʹҰͭҰͭͷPod(ޙड़)ׂ͕Γ౰ͯΒ
    ΕΔΠϝʔδ
    • GKEͰ͸ClusterΛ࡞੒͢ΔͱࣗಈͰNodeʹ૬
    ౰͢ΔGCEΠϯελϯε͕࡞੒͞ΕΔ

    View full-size slide

  25. Components of Kubernetes
    https://kubernetes.io/docs/tutorials/kubernetes-basics/cluster-intro/

    View full-size slide

  26. DEMO
    • Ϋϥελͷ࡞੒

    • image-type: NodeͷOSλΠϓ
    • machine-type: Node ͷαΠζ(CPU/Mem)
    • num-nodes: Nodeͷ਺
    • preemptible: ҆͘͢ΔͨΊͷ͓·͡ͳ͍ʢpreemptive nodeʣ
    $ gcloud container clusters create test-cluster \
    --image-type=cos \
    —-machine-type=n1-standard-1 \
    -—preemptible \
    -—num-nodes=2

    View full-size slide

  27. جຊ֓೦ᶆ - Pod
    • ҰͭͷΞϓϦέʔγϣϯΛಈ͔ͨ͢ΊͷίϯςφͱϦιʔ
    εΛάϧʔϓԽͨ͠΋ͷ
    • Kubernetesͷߏ੒ཁૉͱͯ͠͸࠷খͷ୯Ґ
    • Pod͝ͱʹCPUɺϝϞϦɺσΟεΫɺωοτϫʔΫΞυ
    Ϩε౳ͷϦιʔεΛ࣋ͭͷͰɺʮҰ୆ͷαʔόʯͱݟΔ
    ͜ͱ΋Ͱ͖Δ
    • Ϋϥελଆ͔ΒݟΔͱҰͭͷʮϓϩηεʯ

    View full-size slide

  28. ਤ:
    جຊ֓೦ᶆ - Pod

    View full-size slide

  29. ࣮ࡍʹ͍͡Δର৅ - ·ͣ͸͜Ε͚ͩ
    • Deployment
    • Service

    View full-size slide

  30. Deployment
    • Podͷ࡞੒ɺߋ৽Λߦ͏୯ҐΛఆٛ
    • DeploymentΛ࡞੒͢Δͱ͜Μͳ͜ͱ͕Ͱ͖Δ
    • Podࣗମͷ࡞੒
    • Pod਺ͷઃఆɾมߋ
    • Deploymentʹଐ͢ΔPodͷΞϓϦέʔγϣϯΛࢭΊͣʹΞοϓ
    σʔτʢϩʔϦϯάΞοϓσʔτʣ
    • Serviceʢޙड़ʣ΁ͷΞλον
    ※ ࡉ͔͍͜ͱΛݴ͏ͱDeployment͸Replica SetΛ؅ཧ͍ͯ͠Δ͕ɺઆ໌͸ׂѪ

    View full-size slide

  31. Deployment Sample(nginx)
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
    name: test-deployment
    spec:
    replicas: 2
    selector:
    matchLabels:
    app: nginx
    template:
    metadata:
    labels:
    app: nginx
    spec:
    containers:
    - name: nginx
    image: nginx:latest
    resources:
    limits:
    cpu: 400m
    memory: 200Mi
    requests:
    cpu: 200m
    memory: 200Mi
    ports:
    - containerPort: 80
    σϓϩΠϝϯτ໊
    ࡞੒͢Δ1PE਺
    ͜ͷϥϕϧ͕͍͍ͭͯΔ1PEΛσϓϩΠϝϯτ͕؅ཧ͢Δ
    1PEʹ͚ͭΔϥϕϧ
    ίϯςφͷ൪ϙʔτΛ։͚Δ
    ʢࢦఆ͠ͳͯ͘΋։͘ʣ
    ࢖༻͢ΔEPDLFSΠϝʔδ
    ׂΓ౰ͯϦιʔε
    1PEͷ
    ఆٛ

    View full-size slide

  32. • Deploymentͷద༻
    • yamlϑΝΠϧ͔ΒDeploymentΛద༻͢Δ
    • ͪΌΜͱͰ͖ͯΔ͔֬ೝ
    $ kubectl apply -f path/to/the/deployment-manifest.yaml
    DEMO
    $ kubectl port-forward test-nginx 8080:80

    View full-size slide

  33. ͜͜·ͰͰ
    • nginxΛಈ͔͢ͱ͜Ζ·Ͱ͸Ͱ͖͚ͨͲɺΫϥε
    λ಺ͷϓϥΠϕʔτ IP͔͠ৼΒΕͯͳ͍͔ΒɺΫ
    ϥελͷ֎͔ΒΞΫηεͰ͖ͳ͍
    • ϒϥ΢βͰ֬ೝ͚ͨ͠Ε͹kubectlίϚϯυͰPod
    ͦΕͧΕʹτϯωϦϯά͠ͳ͍ͱ͍͚ͳ͍
    • ͜ͷ··Ͱ͸࢖͑ͳ͍͠ɺ͍͍ͪͪΊΜͲ͍

    View full-size slide

  34. Service
    • Pod΁ͷΞΫηεΛந৅Խ͢Δ
    • Pod͸ࢮΜͩΓੜ·ΕͨΓ͢Δ΋ͷͳͷͰɺ΋ͬͱந৅తͳ
    ୯ҐͰ·ͱΊ͓͔ͯͳ͍ͱΫϥΠΞϯτ͔ΒͷΞΫηεઌ͕
    ίϩίϩมΘͬͪΌ͏
    • ϧʔλ΍ϩʔυόϥϯαʹ૬౰͢ΔػೳͰɺΫϥελ֎
    ͔ΒͷΞΫηεΛ஥հ͢Δ
    • τϥϑΟοΫ੍ޚͷํ๏ʹΑͬͯɺ͍͔ͭ͘ͷλΠϓ͔
    Βબ΂Δ

    View full-size slide

  35. Service (type: LoadBalancer)
    • L4ϩʔυόϥϯα૬౰ͷػೳΛఏڙ͢ΔʢIP
    ΞυϨεͰΞΫηεͰ͖Δʣ
    • ֎෦ΤϯυϙΠϯτ(External IP)Λ΋ͪɺಠࣗ
    ͷIPΞυϨεΛ࢖ͬͯΞΫηεͤ͞Δ͜ͱ͕Ͱ
    ͖Δ

    View full-size slide

  36. Service.yml Sample(LoadBalancer)
    apiVersion: v1
    kind: Service
    metadata:
    name: test-service
    spec:
    ports:
    - port: 80
    targetPort: 80
    protocol: TCP
    loadBalancerIP: xx.xx.xx.xx
    type: LoadBalancer
    selector:
    app: nginx
    ֎෦͔ΒͷΞΫηεΛड͚෇͚Δ*1ΞυϨε
    (,&Ͱ͸ࢦఆ͠ͳ͚Ε͹ࣗಈͰׂΓ౰ͯ

    ΞΫηεΛసૹ͢Δઌͷ
    1PEଆͷϙʔτ൪߸
    ΞΫηεΛड͚෇͚Δ
    4FSWJDFଆͷϙʔτ൪߸
    ΞΫηεΛసૹ͢Δઌͷ
    1PEΛϥϕϧͰࢦఆ

    View full-size slide

  37. • Serviceͷద༻
    • yamlϑΝΠϧ͔ΒServiceΛద༻͢Δ
    • ͜Μͳ΍Γํ΋͋Δ
    $ kubectl apply -f path/to/the/service-manifest.yaml
    DEMO
    $ kubectl expose deployment test-deployment —-port=80 —-target-port=80

    View full-size slide

  38. Service (type: NodePort)
    • Nodeͷಛఆͷϙʔτ൪߸΁ͷΞΫηεΛɺಛ
    ఆͷPodʹసૹ͢Δ
    • Kubernetesͷ֎ʹϩʔυόϥϯαʔΛ࣋ͪͨ
    ͍৔߹΍ɺIngress(ޙड़)Λ࢖͍͍ͨ৔߹ʹ͜
    ΕΛࢦఆ͢Δ͜ͱ͕ଟ͍ʢͱࢥ͏ʣ

    View full-size slide

  39. Service.yml Sample(NodePort)
    apiVersion: v1
    kind: Service
    metadata:
    name: test-service
    spec:
    ports:
    - port: 80
    targetPort: 80
    nodePort: 30080
    protocol: TCP
    type: NodePort
    selector:
    app: nginx
    ΞΫηεΛసૹ͢Δઌͷ
    1PEΛࢦఆ
    /PEFͷ͜ͷϙʔτ΁ͷΞΫηεΛ͜ͷαʔϏεʹసૹ
    ࢦఆ͠ͳ͚Ε͹ࣗಈͰׂΓ౰ͯ

    View full-size slide

  40. ͜͜·Ͱ
    • Ͱ͖ͨ͜ͱ
    • type: loadBalancerͷαʔϏεΛ࢖͏͜ͱͰಠࣗIP
    Ͱ֎෦͔ΒͷΞΫηεΛड͚෇͚ͨΓ
    • type: nodePortͰϊʔυͷIP:PortͰ֎෦͔ΒͷΞ
    ΫηεΛड͚෇͚ͨΓ
    • WEBαʔϏε࡞Εͦ͏

    View full-size slide

  41. ࢖ͬͯΈΔͱศརͳίϯϙʔωϯτ
    • Config Map
    • Secret
    • Ingress
    • Daemon Set
    • Cronjob
    • ʢ͜ͷล͸ຊ൪؀ڥ࡞ΔͳΒඞਢ͔΋͚ͩͲɺݸਓͰ༡Ϳ෼ʹ͸ͳͯ͘΋ͳΜͱ͔ͳΔʣ

    View full-size slide

  42. Config Map
    • Pod಺෦Ͱ࢖͏؀ڥม਺ΛConfig Mapͱͯ͠
    ఆ͓ٛͯ͘͜͠ͱͰɺDeploymentͷҠ২ੑΛ
    ߴΊΔ͜ͱ͕Ͱ͖Δ
    • NamespaceͰ؀ڥ͝ͱʹ࢖͏Config MapΛ
    ੾Γସ͑ͨΓ͢Δ͜ͱ΋Ͱ͖Δ

    View full-size slide

  43. Config Map Sample
    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: dev-common-env
    data:
    TEST_HOST: “www.testdomain.com"
    TEST_PORT: "8081"
    TEST_ID: “test-project"
    EBUBϑΟʔϧυͷԼʹ
    ΩʔόϦϡʔΛॻ͘

    View full-size slide

  44. Deployment͔Βͷݺͼग़͠

    envFrom:
    - configMapRef:
    name: dev-common-env


    env:
    - name: DB_ACCESS_POINT
    valueFrom:
    configMapKeyRef:
    name: dev-common—env
    key: TEST_ID

    DPOpHNBQΛؙ͝ͱಡΈग़͠
    ͯ؀ڥม਺ʹద༻
    DPOpHNBQ͔Β஋ΛҰͭ
    ಡΈग़ͯ͠؀ڥม਺ʹద༻

    View full-size slide

  45. Secret
    • ConfigMapͱಉ͡Α͏ʹɺDeploymentఆٛ
    ͔Β஋Λݺͼग़͢͜ͱ͕Ͱ͖Δ
    • Config Mapͱ͸ҧ͍ɺ಺෦Ͱ҉߸Խͯ͠ѻ͏
    ͷͰɺύεϫʔυͳͲൿີ৘ใΛ֨ೲ͓ͯ͠
    ͘ͱ͖ʹద͍ͯ͠Δ

    View full-size slide

  46. Secret Sample
    ---
    apiVersion: v1
    data:
    tls.crt:
    tls.key:
    kind: Secret
    metadata:
    name: domain-certs
    type: Opaque
    EBUBϑΟʔϧυͷԼʹ
    ΩʔόϦϡʔΛॻ͘

    View full-size slide

  47. Deployment͔Βͷݺͼग़͠

    env:
    - name: AWS_ACCESS_KEY_ID
    valueFrom:
    secretKeyRef:
    name: aws-credential
    key: aws.access_key_id

    TFDSFU͔Β஋ΛҰͭ
    ಡΈग़ͯ͠؀ڥม਺ʹద༻

    View full-size slide

  48. Ingress
    • HTTPϕʔεͷϩʔυόϥϯαػೳΛఏڙ͢Δ
    • HTTPSରԠͷͨΊʹSSLΛऴ୺ͤͨ͞Γɺ໊લ
    ϕʔεͷόʔνϟϧϗετͷઃఆΛ͢Δ͜ͱ΋
    Ͱ͖Δ

    View full-size slide

  49. Ingress Sample
    ---
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
    name: test-ingress
    annotations:
    kubernetes.io/ingress.global-static-ip-name: dev-console-ingress
    kubernetes.io/ingress.class: "gce"
    spec:
    tls:
    - secretName: domain-certs
    backend:
    serviceName: test-service
    servicePort: 80
    rules:
    - host: www.test.com
    http:
    paths:
    - path: /*
    backend:
    serviceName: test-service
    servicePort: 80
    (,&ͩͱɺOHJOYΛ࢖͏͔ɺ
    ($1ͷ)551-#Λ࢖͏͔બ΂Δ
    σϑΥϧτͷόοΫΤϯυͷαʔϏεΛࢦఆ
    ΞΫηεϧʔϧΛࢦఆͯ͠
    όʔνϟϧϗετͷΑ͏ʹ࢖͏͜ͱ΋Ͱ͖Δ
    ʢ͜ͷCBDLFOEͷࢦఆ͕TQFDCBDLFOEΑΓɹ
    ɹ༏ઌ͞ΕΔʣ
    ※ Ingress͕ར༻͢ΔHealth Check͸σϑΥϧτͰbackendͷ/΁ͷΞΫηε
    ※ มߋ͍ͨ͠৔߹͸PodͷఆٛͰ`readinessProbe`Λઃఆ͢Δඞཁ͕͋Δ
    5-4ͷऴ୺΋*OHSFTTͰͰ͖Δ

    View full-size slide

  50. ؆୯ͳߏ੒ྫ঺հ
    ࣌ؒͷ౎߹্ࡉ͔͍࿩͸ʢଟ෼ʣͰ͖·ͤΜͷͰɺ
    ؾʹͳΔͱ͜Ζͱ͔͸࠙਌ձͰฉ͍͍ͯͩ͘͞

    View full-size slide

  51. αʔϏεͷߏ੒ྫ

    View full-size slide

  52. ͜Μͳײ͡ͰCanary Releaseͨ͠Γ

    View full-size slide

  53. ίϚϯυϥΠϯπʔϧ

    View full-size slide

  54. Google Cloud SDK
    • GCPΛ͍͡ΔͨΊͷίϚϯυϥΠϯπʔϧ
    • `gcloud` Ͱݺͼग़͢

    View full-size slide

  55. `gcloud container clusters`
    • ओʹΫϥελͷ࡞੒΍ϩάΠϯઌͷΫϥελͷ
    ੾Γସ͑ʹ࢖͏
    • ଞʹ΋ɺΫϥελΛϦαΠζ͢ΔίϚϯυͱ͔͋Δ͚Ͳࠓ೔͸লུ
    e.g. (Լઢ෦͸ࣗ͝਎ͷ؀ڥʹஔ͖׵͑ͯ࢖͍ͬͯͩ͘͞)
    # Ϋϥελͷ࡞੒
    ## CPU 0.5core/ Memory 1.7GB ͰcoreosϕʔεͷϚγϯ3୆ΛnodeΫϥελͱͯ͠૊Ή
    $ gcloud container clusters create test-cluster \
    —-project=your-project —-zone=asia-northeast1-a —image-type=cos \
    —-machine-type=g1-small --num-nodes=3
    # Ϋϥελ΁ͷϩάΠϯ
    ## ্ͷίϚϯυͰ࡞੒ͨ͠Ϋϥελ΁ϩάΠϯ͠ɺkubectlΛ࢖͑ΔΑ͏ʹ͢Δ
    $ gcloud container clusters get-credentials test_cluster \
    —-project=your-project ——zone=asia-northeast1-a
    # ࡞ͬͨΫϥελΛ࡟আ
    $ gcloud container clusters delete test-cluster —-zone=asia-northeast1-a

    View full-size slide

  56. kubectl
    • KubernetesΛ੍ޚ͢ΔͨΊͷίϚϯυϥΠϯπʔϧ
    • ҎԼͷૢ࡞Λ͓͚֮͑ͯ͹ͱΓ͋͑ͣ͸࢖͑Δ
    • (Deployment΍Service౳)֤ίϯϙʔωϯτΛ࡞Δ
    • ֤ίϯϙʔωϯτΛมߋ͢Δ
    • ֤ίϯϙʔωϯτΛ࡟আ͢Δ
    • ֤ίϯϙʔωϯτͷ৘ใΛӾཡ͢Δ(CLI / GUI)
    • ࣗ෼ͷϩάΠϯ৘ใΛ֬ೝ͢Δ

    View full-size slide

  57. Α͘࢖͏ίϚϯυ
    # ϑΝΠϧ͔ΒίϯϙʔωϯτΛ࡞੒͢Δ
    # ಉ໊ͷίϯϙʔωϯτΛߋ৽͢Δͱ͖΋ಉ͡ίϚϯυ
    $ kubectl apply -f deployment.yml
    # ཁૉҰཡΛऔಘ (pods /ɹdeployments / services / ingress / configmap …)
    $ kubectl get pods # লུ΋Ͱ͖ΔΑ pods -> po ͱ͔ services -> svcͱ͔
    # ৄࡉΈ͍ͨ৔߹͸ͬͪ͜
    $ kubectl describe deployment test-deployment
    # ίϯςφΠϝʔδΛߋ৽
    $ kubectl set image deployment/test-deployment nginx=nginx:latest
    # ίϯςφͷதʹೖͬͯΈΔ
    $ kubectl exec -it test-deployment-xxxxxxx —- /bin/bash

    View full-size slide

  58. Others
    • kubectx
    Ϋϥελͷ੾Γସ͑ʢίϯςΩετͷ੾Γସ͑ʣ
    • stern
    ࢦఆͨ͠จࣈྻΛؚΉPodͷϩάΛ tail ͯ͘͠ΕΔ
    • ckube
    kubectl ͰͷϫʔΫϑϩʔΛ؆୯ʹͯ͘͠ΕΔπʔϧ
    | ࢀߟ:

    View full-size slide

  59. ༻ྫ
    # ίϯςΩετҰཡ
    $ kubectx
    # ίϯςΩετ੾Γସ͑
    $ kubectx test-cluster
    # ͋ΔσϓϩΠϝϯτͷlogΛ·ͱΊͯtail
    $ stern test-deployment
    # ΠϯλϥΫςΟϒʹ֤ίϯϙʔωϯτͷ৘ใʹΞΫηε
    $ ckube ls

    View full-size slide

  60. GKE ͬͯԿͰͰ͖ͯΔͷʁ
    • Master: ϚωʔδυαʔϏε
    • Node: GCEΠϯελϯε͕࡞੒͞ΕΔ
    • Service(type LoadBalancer): Forwarding Rule
    • Ingress: GCP HTTP(S) Load Balancer

    View full-size slide

  61. Wrapping Up
    • GKE࢖ͬͯΔͱجຊతʹ͸ίϯιʔϧૢ࡞ / ίϚϯυ
    ͳΒҰൃͰ؆୯ʹΫϥελ૊Ίͯߏஙָνϯ
    • Kubernetes࢖͏ͳΒ·ͣ͸DeploymentͱServiceΛ
    ԡ͓͚͑ͯ͞͹ΞϓϦಈ͔ͤͯΔײ͡ΛຯΘ͑Δ͔Β
    ͔ͦ͜Β࢝ΊΔͱ͍͍ͱࢥ͏
    • DaemonSetͱ͔ConfigMapͱ͔΋࢖͏ͱΑΓ៉ྷͳ
    ߏ੒ΛऔΕΔΑ͏ʹͳ͍ͬͯ͘

    View full-size slide

  62. Further Reading
    • ࠔͬͨΒͱΓ͋͑ͣެࣜʢӳޠͷΈʣ
    ͜Ε:
    • ίϯςφج൫ͷσβΠϯύλʔϯ͕Google͔Βެ։͞Ε͍ͯΔͷͰɺڵຯ͕͋ͬͨ
    ΒͦΕΛࢀߟʹͯ͠ຏ͖Λ͔͚͍ͯ͘ͱྑ͍͔΋
    ͜Ε:
    • ͔ͬ͜Α͘σϓϩΠ͍ͨ͠ਓ޲͚
    Helm(ύοέʔδ؅ཧ): : Kubernetes ϚχϑΣετΛύοέʔδͷΑ͏ʹར༻
    Spinnaker(CDπʔϧ): : σϓϩΠύΠϓϥΠϯΛߏங
    Istio (Service Mesh): : Canary Release Ͱ Canary ൛΁ͷτϥϑΟοΫίϯτϩʔϧͱ͔

    View full-size slide

  63. We Are Hiring
    • ͝ڵຯͷ͋Δํ͸͓ؾܰʹ͓੠͔͚͍ͩ͘͞
    • ΦϑΟεݟֶ͚ͩͰ΋େ׻ܴ
    • ຊ൪؀ڥ Ͱ Kubernetes ࢖͏ϓϩμΫτ΋૿͖͑ͯ·ͨ͠
    • ࣾ಺ʹεΩϧΞοϓθϛͱ͍͏੍౓͕͋ͬͯɺKubernetesͷθϛ΋͋Γ·͢
    גࣜձࣾαΠόʔΤʔδΣϯτ
    ΞυςΫελδΦ / ΞυςΫຊ෦

    View full-size slide