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

Cloud Runを最速で体験する方法

Yamato
April 15, 2023

Cloud Runを最速で体験する方法

Yamato

April 15, 2023
Tweet

More Decks by Yamato

Other Decks in Programming

Transcript

  1. Cloud Runを最速で体験する方法
    20230415 北海道LT大会
    @yamato_sorariku
    #北海道LT大会
    1

    View Slide

  2. 自己紹介
    @yamato_sorariku
    お仕事
    WEBエンジニア
    クラウドインフラエンジニア
    データエンジニア
    推しのマネージドサービス
    Cloud Run
    #北海道LT大会
    2

    View Slide

  3. Cloud Run 最速体験
    #北海道LT大会
    3

    View Slide

  4. 最速体験コマンド
    gcloud run deploy hello \
    --image=us-docker.pkg.dev/cloudrun/container/hello \ #
    デプロイするイメージを指定
    --allow-unauthenticated \ #
    認証せず誰でもアクセス可能なようにする
    --max-instances=1 \ #
    インスタンスは最大1
    つ(
    爆死対策)
    --region=asia-northeast1 #
    起動するリージョンの指定(
    東京を指定)
    #北海道LT大会
    4

    View Slide

  5. 実行
    ~ ❯❯❯ \time gcloud run deploy hello \
    --image=us-docker.pkg.dev/cloudrun/container/hello \
    --allow-unauthenticated \
    --max-instances=1 \
    --region=asia-northeast1
    Deploying container to Cloud Run service [hello] in project [■■■■■■■■] region [asia-northeast1]
    ✓ Deploying new service... Done.
    ✓ Creating Revision... Creating Service.
    ✓ Routing traffic...
    ✓ Setting IAM Policy...
    Done.
    Service [hello] revision [hello-00001-geb] has been deployed and is serving 100 percent of traffic.
    Service URL: https://hello-■■■■■■■■-an.a.run.app
    13.94 real 0.69 user 0.11 sys
    #北海道LT大会
    5

    View Slide

  6. 起動!
    #北海道LT大会
    6

    View Slide


  7. #北海道LT大会
    7

    View Slide

  8. Cloud Runとは?
    #北海道LT大会
    8

    View Slide

  9. Cloud Run とは
    Google Cloud が提供するマネージドサービスの一つ
    コンテナイメージをデプロイできるので、言語による制限もなくWEBアプリケーションを構築できる。
    https://cloud.google.com/run/docs/overview/what-is-cloud-run?hl=ja
    #北海道LT大会
    9

    View Slide

  10. いいところ
    #北海道LT大会
    10

    View Slide

  11. デプロイしたらアクセス可能なエンドポイントが自動的にできる
    しかもTLSも設定済みなので、最初から https://{
    サービス名とか}.run.app
    でアプリにアクセスできる
    #北海道LT大会
    11

    View Slide

  12. 低コスト
    趣味程度に触る程度であれば、無料枠に収まる
    Cloud Runの料金はCPUとメモリの利用時間に対して課金される。
    (プラス ネットワークの下り転送量も課金されます。)
    無料枠は
    毎月最初の 180,000 vCPU 秒
    毎月最初の 360,000 GiB 秒
    毎月 200 万リクエスト
    #北海道LT大会
    12

    View Slide

  13. 概算コスト
    リージョン: 東京
    CPU: 2 vCPU
    Memory: 2GiB
    同時実行数: 5
    リクエスト処理時間: 2,000ms
    リクエスト数: 300,000/月 = 約400/時
    転送量: 約30GB(リクエストあたり1MBで計算)
    #北海道LT大会
    13

    View Slide

  14. ブルーグリーンデプロイやカナリアリリース、ロールバックも可能
    リビジョン(デプロイ実行ごとに作成される履歴にようなもの)
    #北海道LT大会
    14

    View Slide

  15. カナリアリリース
    #北海道LT大会
    15

    View Slide

  16. カナリアリリース
    #北海道LT大会
    16

    View Slide

  17. カナリアリリース
    #北海道LT大会
    17

    View Slide

  18. ブルーグリーンデプロイ
    #北海道LT大会
    18

    View Slide

  19. #北海道LT大会
    19

    View Slide

  20. ブルーグリーンデプロイ
    #北海道LT大会
    20

    View Slide

  21. ロールバック
    #北海道LT大会
    21

    View Slide

  22. ロールバック
    #北海道LT大会
    22

    View Slide

  23. まとめ
    Cloud Run はいいぞ!
    #北海道LT大会
    23

    View Slide