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

API Gateway

kumakumakkk
October 18, 2020

API Gateway

GDG Devfest 2020 Tokyoで発表された資料です。
資料にデモ動画が使用されているのですが、Speaker Deckでは表示できません。講演の録画にデモ動画も含まれているので、そちらをご覧ください。
https://youtu.be/Q0BH0vQFxWQ

kumakumakkk

October 18, 2020
Tweet

More Decks by kumakumakkk

Other Decks in Technology

Transcript

  1. API Gateway
    Kuma Arakawa
    Google Developers Expert
    (Cloud / Google Workspace)

    View Slide

  2. Kuma Arakawa
    twitter: @kumakumakkk
    https://kuma.bio

    View Slide

  3. 1. Google Cloud Buildpacks
    2. Cloud Run (managed)
    3. API Gateway
    今日お話すること

    View Slide

  4. Google Cloud
    Buildpacks

    View Slide

  5. FROM ubuntu:14.10
    ENV SRC_DIR=/go/src/github.com/someprogram
    ENV GOBIN=/go/bin
    WORKDIR $GOBIN
    ADD . $SRC_DIR
    RUN cd /go/src;
    RUN go install github.com/someprogram/;
    ENTRYPOINT ["./someprogram"]
    EXPOSE 8080

    View Slide

  6. FROM ubuntu:14.10
    ENV SRC_DIR=/go/src/github.com/someprogram
    ENV GOBIN=/go/bin
    WORKDIR $GOBIN
    ADD . $SRC_DIR
    RUN cd /go/src;
    RUN go install github.com/someprogram/;
    ENTRYPOINT ["./someprogram"]
    EXPOSE 8080
    数百の脆弱性

    View Slide

  7. 既知の脆弱性が含まれるDockerfileの割合
    44%
    Source: The state of open source security report 2019 by snyt

    View Slide

  8. Demo1

    View Slide

  9. Buildpacks create containers
    without a dockerfile.
    Source code OCI
    Container

    View Slide

  10. 1. CNCF Cloud Native Sandbox Project
    2. Dockerfileのメンテからの開放
    3. コンテナに移行しやすい環境を簡単に構築
    Buildpacks

    View Slide

  11. 1. AppEngine, Functions → コンテナ化
    2. Cloud Buildsなど多数のGCPプロダクトが対応
    3. ベンダーロックからの開放
    Google Cloud Buildpacks
    https://github.com/GoogleCloudPlatform/buildpacks

    View Slide

  12. API Gateway

    View Slide

  13. 1. Goで書かれたアプリの挙動をローカルで確認
    2. Cloud BuildsとBuildpacksを使ってコンテナ化
    3. 作成したコンテナをCloud Runにデプロイ
    デモ振り返り

    View Slide

  14. クライアント
    Customers
    API

    View Slide

  15. クライアント
    OrderHistory
    API
    Customers
    API
    OderDetail
    API

    View Slide

  16. クライアント
    OrderHistory
    API
    Customers
    API
    OderDetail
    API

    View Slide

  17. クライアント
    OrderHistory
    API
    Customers
    API
    OderDetail
    API
    API Gateway
    (Open API)

    View Slide

  18. Demo2

    View Slide

  19. 1. OPENAPI Specを定義
    2. x-google-backend でバックエンドにルーティング
    3. APIを作成しGatewayを作成
    デモ振り返り

    View Slide

  20. クライアント
    OrderHistory
    API
    Customers
    API
    OderDetail
    API
    API Gateway
    (Open API)

    View Slide

  21. クライアント
    OrderHistory
    API
    Customers
    API
    OderDetail
    API
    API Gateway
    (Open API)
    API_KEY

    View Slide

  22. Demo3

    View Slide

  23. クライアント
    OrderHistory
    API
    Customers
    API
    OderDetail
    API
    API Gateway
    (Open API)

    View Slide

  24. securityDefinitions:
    your_custom_auth_id:
    authorizationUrl: ""
    flow: "implicit"
    type: "oauth2"
    x-google-issuer: "issuer of the token"
    x-google-jwks_uri: "url to the public key"
    x-google-audiences: "YOUR-CLIENT-ID"
    security:
    - your_custom_auth_id: []

    View Slide

  25. securityDefinitions:
    firebase:
    authorizationUrl: ""
    flow: "implicit"
    type: "oauth2"
    x-google-issuer: "https://securetoken.google.com/YOUR-PROJECT-ID"
    x-google-jwks_uri:
    "https://www.googleapis.com/service_accounts/v1/metadata/x509/[email protected]"
    x-google-audiences: "YOUR-PROJECT-ID"
    security:
    - firebase: []

    View Slide

  26. 考察

    View Slide

  27. HTTP(S)
    Load Balancer

    View Slide

  28. https://www.youtube.com/watch?v=7FoSrWEDx-g

    View Slide

  29. 1. API GatewayはOPENAPIに準拠している
    2. 認証周りをバックエンドから切り離せる
    3. モニタリングも楽
    4. GCLBとの連携も今後出てきそう
    考察

    View Slide

  30. View Slide

  31. まとめ

    View Slide

  32. 1. Buildpacksは積極的に使っていこう
    2. jwt/OPENAPIを使っている場合はAPI Gatewayは
    有効
    3. 今後の発展に期待!!!!!!
    まとめ

    View Slide