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 Slide

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

    @masayuki14

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

    Webエンジニア

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


    View Slide

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

    View Slide

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

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


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

    View Slide

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

    ソーシャルゲーム開発

    Web系システム

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

    View Slide

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

    CTF - セキュリティ


    View Slide

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

    View 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 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 Slide

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

    View 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 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 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 Slide

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

    View Slide

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

    View 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 Slide

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

    View Slide

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

    View Slide

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

    どうしよう(いまここ)

    View Slide

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

    レジストリ使おう

    Docker/CLI 最新版必要

    GCP $300 トライアル

    コントリビュートしよう

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

    View Slide

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

    View Slide

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


    GCP まわりもわかる
    gcloud

    kubectl


    View Slide

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

    入門書として良い

    時間を買うと思えば安い

    View Slide

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


    Compose on k8s
    build できない


    View 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 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 Slide

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

    Quay

    View 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 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 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 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 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 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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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


    バグレポート

    View Slide

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

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


    View Slide

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


    Kubernetes
    仕組み

    Manifest

    Resources


    View Slide

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

    docker

    gcloud


    View Slide

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

    View Slide

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

    View Slide