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

Compose on Kubernetes をGKEで動かそう

Masa
June 07, 2019

Compose on Kubernetes をGKEで動かそう

Compose on Kuberenetes を GKEで動かしました。
それで得られた知見などをまとめています。

Event
- 2019/06/07 Cloud Native Kansai #03
- https://cnjp.connpass.com/event/127545/

Masa

June 07, 2019
Tweet

More Decks by Masa

Other Decks in Technology

Transcript

  1. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Compose on
    Kubernetes を
    GKEで動かそう
    Cloud Native Kansai #03
    2019/06/07
    @masayuki14

    View full-size slide

  2. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Masaといいます
    もりさきまさゆき

    @masayuki14

    プロ主夫
    フリーランス (パートタイム)

    Webエンジニア

    データベーススペシャリスト


    View full-size slide

  3. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    このアイコン
    Follow me !!

    View full-size slide

  4. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    自己紹介
    コミュニティ
    はんなりPython (第3金曜開催@京都)

    OSS Gate (京都, 大阪, 東京)


    スプーキーズアンバサダー

    View full-size slide

  5. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    スプーキーズ@京都
    ボードゲーム制作

    ソーシャルゲーム開発

    Web系システム

    ゲームクリエイター積極採用中

    View full-size slide

  6. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    スプーキーズ@京都
    モクモクモック(もくもく会)
    テクテクテック(勉強会)
    2019/07 企画中
    ISUCONワークショップ - 速度改善

    CTF - セキュリティ


    View full-size slide

  7. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    今日の話
    Compose on
    Kubernetesを
    GKEで動かそう

    View full-size slide

  8. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Compose on k8s
    Compose on Kubernetes
    allows you to deploy Docker
    Compose fles onto a
    Kubernetes cluster.
    [「https://github.com/docker/compose-on-
    kubernetes」より引用]

    View full-size slide

  9. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Compose on k8s
    docker-compose.ymlをk8sクラ
    スターにデプロイ

    前回のLTで紹介

    View full-size slide

  10. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Docker Preferences

    View full-size slide

  11. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    docker-compose.yml
    version: '3.3'
    services:
    db:
    image: dockersamples/k8s-wordsmith-db
    words:
    image: dockersamples/k8s-wordsmith-api
    deploy:
    replicas: 5
    web:
    image: dockersamples/k8s-wordsmith-web
    ports:
    - "33000:80"

    View full-size slide

  12. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    ローカルで実行
    $ docker stack deploy \
    -c docker-compose.yml \
    --orchestrator=kubernetes \
    kubesample

    View full-size slide

  13. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    ローカルで実行
    $ docker stack deploy -c docker-compose.yml --orchestrator=kubernetes kubesample
    Waiting for the stack to be stable and running...
    words: Ready [pod status: 2/5 ready, 3/5 pending, 0/5 failed]
    web: Ready [pod status: 1/1 ready, 0/1 pending, 0/1 failed]
    db: Ready [pod status: 1/1 ready, 0/1 pending, 0/1 failed]
    Stack kubesample is stable and running
    $ kubectl get pods
    NAME READY STATUS RESTARTS AGE
    db-79b45689db-f49f6 1/1 Running 0 4m
    web-6b56cf97b9-2rbwg 1/1 Running 0 4m
    words-6d654698d5-49l8g 1/1 Running 0 4m
    words-6d654698d5-b9pf7 1/1 Running 0 4m
    words-6d654698d5-fmp9f 1/1 Running 0 4m
    words-6d654698d5-xhvfn 1/1 Running 0 4m
    words-6d654698d5-z6zsf 1/1 Running 0 4m

    View full-size slide

  14. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Compose on k8s
    Deploy on GKE

    View full-size slide

  15. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Install

    View full-size slide

  16. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Run
    $ kubectl config use-context gke_beta-4...
    $ docker stack deploy \
    -c docker-compose.yml \
    --orchestrator=kubernetes \
    kubesample
    failed to find a Stack API version

    View full-size slide

  17. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    結果
    動かない!!
    おしまい!!

    View full-size slide

  18. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Issue 作成
    Contribute

    View full-size slide

  19. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    返信なし
    同じ問題に困ってる人はいた

    どうしよう(いまここ)

    View full-size slide

  20. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    わかったこと
    本を読もう

    レジストリ使おう

    Docker/CLI 最新版必要

    GCP $300 トライアル

    コントリビュートしよう

    動かすことで理解が深まる

    View full-size slide

  21. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    本を読もう

    View full-size slide

  22. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    本を読もう
    docker, compose, swarm
    順序よく学べる


    GCP まわりもわかる
    gcloud

    kubectl


    View full-size slide

  23. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    本を読もう
    Webの情報では不十分

    入門書として良い

    時間を買うと思えば安い

    View full-size slide

  24. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    レジストリ使おう
    Docker Compose
    build できる


    Compose on k8s
    build できない


    View full-size slide

  25. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    レジストリ使おう
    docker-compose.yml
    services:
    app:
    build:
    context: ./app
    dockerfile: Dockerfile
    build できない

    View full-size slide

  26. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    レジストリ使おう
    docker-compose.yml
    services:
    app:
    image: localhost:5000/sample/app
    レジストリを指定

    View full-size slide

  27. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    レジストリ使おう
    Dockerレジストリサービス
    Docker Hub

    Quay

    View full-size slide

  28. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    レジストリ使おう
    コンテナでローカルレジストリ
    $ docker run \
    -v $(pwd)/registry:/var/lib/registry \
    -p 5000:5000 \
    registry:latest

    View full-size slide

  29. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    レジストリ使おう
    build & push
    $ ls
    Dockerfile
    $ docker build -t localhost:5000/sample/app .
    $ docker push localhost:5000/sample/app

    View full-size slide

  30. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    レジストリ使おう
    tag & push
    $ docker tag app localhost:5000/sample/app
    $ docker push localhost:5000/sample/app

    View full-size slide

  31. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Docker/CLI 最新版必要
    Important: You will need a
    custom build of Docker CLI to
    deploy stacks onto GKE. The
    build must include this PR
    which has been merged onto
    the master branch.
    [「https://github.com/docker/compose-on-
    kubernetes/blob/master/docs/install-on-gke.md」よ
    り引用]

    View full-size slide

  32. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Docker/CLI 最新版必要
    $ docker version
    stable
    18.09.2


    requirement
    19.03 <=


    View full-size slide

  33. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Docker/CLI 最新版必要
    $ git clone [email protected]:docker/cli.git
    $ cd cli
    $ make -f docker.Makefile binary
    $ make -f docker.Makefile cross
    $ ./build/docker-darwin-amd64 version

    View full-size slide

  34. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    Docker/CLI 最新版必要
    19.03 is comming soon.

    View full-size slide

  35. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    GCP $300 トライアル
    いまなら1年間$300まで使い放題

    View full-size slide

  36. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    GCP $300 トライアル

    View full-size slide

  37. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    コントリビュートしよう
    困ったことはIssueにあげる
    返事があるとは限らない


    バグレポート

    View full-size slide

  38. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    コントリビュートしよう
    解決したらPullRequest

    ドキュメントの改善
    ハードルが低い


    View full-size slide

  39. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    動かすことで理解が深まる
    GCP
    はじめての利用


    Kubernetes
    仕組み

    Manifest

    Resources


    View full-size slide

  40. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    動かすことで理解が深まる
    commands
    kubectl

    docker

    gcloud


    View full-size slide

  41. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    さいごに
    To be
    continued!!

    View full-size slide

  42. Compose on Kubernetes をGKEで動かそう - Cloud Native Kansai #03 Powered by Rabbit 2.2.1
    さいごに
    ありがとう
    ございました

    View full-size slide