Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transrate gRPC #5

Merged
merged 10 commits into from
Apr 5, 2020
Merged
26 changes: 12 additions & 14 deletions content/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ publishDate: "2019-12-31"
categories: ["Traffic Management"]
---

[gRPC](https://grpc.io/) is a communication protocol for services, built on [HTTP/2](https://www.cncf.io/blog/2018/08/31/grpc-on-http-2-engineering-a-robust-high-performance-protocol/). Unlike REST over HTTP/1, which is based on [resources](https://en.wikipedia.org/wiki/Representational_state_transfer), gRPC is based on [Service Definitions](https://grpc.io/docs/guides/concepts/). You specify service definitions in a format called [protocol buffers](https://developers.google.com/protocol-buffers/) ("proto"), which can be serialized into an small binary format for transmission.
[gRPC](https://grpc.io/) はサービス間通信のプロトコルで、[HTTP/2](https://www.cncf.io/blog/2018/08/31/grpc-on-http-2-engineering-a-robust-high-performance-protocol/) 上で動作します。[resources](https://en.wikipedia.org/wiki/Representational_state_transfer) ベースの HTTP/1 上で動作する REST と異なり、gRPC は [Service Definitions](https://grpc.io/docs/guides/concepts/) ベースです。データの通信や永続化のための小さなバイナリフォーマットへシリアライズすることができる [protocol buffers](https://developers.google.com/protocol-buffers/) ("proto") と呼ばれるフォーマットで service definitions を指定します。

With gRPC, you can generate boilerplate code from `.proto` files into [multiple programming languages](https://grpc.io/docs/quickstart/), making gRPC an ideal choice for polyglot microservices.
gRPC では `.proto` ファイルから [multiple programming languages](https://grpc.io/docs/quickstart/) へのボイラープレートコードを生成することができます。このため、gRPC は 多言語での microservices のための理想的な選択となるでしょう。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[protocol buffers](https://developers.google.com/protocol-buffers/)
[protocol buffers](https://developers.google.com/protocol-buffers?hl=ja)
現状ほとんど和訳されてませんが,一応...

[resources](https://en.wikipedia.org/wiki/Representational_state_transfer)
[resources](https://ja.wikipedia.org/wiki/Representational_State_Transfer)
説明の構成は異なりますが,大まかな意味は同じですし,英語版には無いRPCへの言及もありますので,個人的には日本語版リンクにしても良いと思います。英語版の方が妥当と判断されたらこのままで結構です。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日本語版が Outdated じゃないかどうかだけ気になりますねえ。まぁそうであればそっちはそっちで原点にあたってもらえればいいんですが。ちょっと中身確認して判断します。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2件とも対応しました 👍
d9d1a4c
52109e1


While gRPC supports some networking use cases like [TLS](https://grpc.io/docs/guides/auth/) and [client-side load balancing](https://grpc.io/blog/loadbalancing/), adding Istio to a gRPC architecture can be useful for collecting telemetry, adding traffic rules, and setting [RPC-level authorization](https://istio.io/blog/2018/istio-authorization/#rpc-level-authorization). Istio can also provide a useful management layer if your traffic is a mix of HTTP, TCP, gRPC, and database protocols, because you can use the same Istio APIs for all traffic types.
gRPC [TLS](https://grpc.io/docs/guides/auth/) [client-side load balancing](https://grpc.io/blog/loadbalancing/) のようなユースケースをサポートしています。さらに gRPC のアーキテクチャに Istio を組み込むことはメトリクスの収集、トラフィックルールの追加、[RPC-level authorization](https://istio.io/blog/2018/istio-authorization/#rpc-level-authorization) といった利点があります。すべてのトラフィックタイプに同一の Istio API を使用できるため、トラフィックが HTTP, TCP, gRPC, そして データベースプロトコルの間で混在している場合でも、Istio は 便利な管理レイヤーを追加できます。

[Istio](https://istio.io/about/feature-stages/#traffic-management) and its data plane proxy, [Envoy](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/other_protocols/grpc#arch-overview-grpc), both support gRPC. Let's see how to manage gRPC traffic with Istio.
[Istio](https://istio.io/about/feature-stages/#traffic-management) とそのデータプレーンプロキシーである [Envoy](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/other_protocols/grpc#arch-overview-grpc) の両方が gRPC をサポートします。Istio を用いてどのように gRPC トラフィックを管理するか見てみましょう。

![grpc](/images/grpc.png)

Here, we're running two gRPC Services, `client` and `server`. `client` makes an RPC call to the `server`'s `/SayHello` function every 2 seconds.
このように、`client` `server` の2つの gRPC サービスがあります。`client` RPC コールを `server``/SayHello` function へ2秒ごとに行います。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function は訳したほうがよさそうです

chaspy marked this conversation as resolved.
Show resolved Hide resolved


Adding Istio to gRPC Kubernetes services has one pre-requisite: [labeling](https://istio.io/docs/setup/kubernetes/additional-setup/requirements/) your Kubernetes Service ports. The server's port is labeled as follows:
Istio を gRPC Kubernetes サービスへ追加するためには要件があります。Kubernetes の Service ports の [labeling](https://istio.io/docs/setup/kubernetes/additional-setup/requirements/) です。server のポートは以下のようにラベル付けされます。

```YAML
apiVersion: v1
Expand All @@ -34,15 +33,15 @@ spec:
port: 8080
```

Once we deploy the app, we can see this traffic between client and server in a [service graph](https://www.kiali.io/):
アプリケーションをデプロイすると、[service graph](https://www.kiali.io/) で client と server の間のトラフィックを見ることができます。

![kiali](/images/grpc-kiali.png)

We can also view the server's gRPC traffic metrics in Grafana:
servergRPC トラフィックメトリクスを Grafana でも見ることができます。

![](/images/grpc-server-healthy.png)

Then, we can apply an Istio traffic rule to inject a 10-second delay [fault](https://istio.io/docs/tasks/traffic-management/fault-injection/) into `server`. You might apply this rule in a chaos testing scenario, to test the resiliency of this application.
また、10秒の delay [fault](https://istio.io/docs/tasks/traffic-management/fault-injection/) `server` へ挿入するための Istio のトラフィックルールを適用できます。アプリケーションの回復性をテストするために、カオステストシナリオでこのルールを適用できるかもしれません。
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delay fault、遅延故障にすべきですかね、、、

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faultを残すのであれば 10秒遅延させる [fault] とかでどうでしょう?

chaspy marked this conversation as resolved.
Show resolved Hide resolved

```YAML
apiVersion: networking.istio.io/v1alpha3
Expand All @@ -64,11 +63,10 @@ spec:
subset: v1
```

This causes the client RPC to time out (`Outgoing Request Duration`):
これは client RPC にタイムアウト(`Outgoing Request Duration`)を起こします。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これにより(略) とかのほうが流れが読みやすいかも?

chaspy marked this conversation as resolved.
Show resolved Hide resolved

![](/images/grpc-grafana-client-fault-inject.png)


To learn more about gRPC and Istio:
gRPC と Istio についてさらに学ぶために:
- [Istio docs - Traffic Management](https://istio.io/docs/concepts/traffic-management/#traffic-routing-and-configuration)
- [Blog post - gRPC + Istio + Cloud Internal Load Balancer](https://cloud.google.com/solutions/using-istio-for-internal-load-balancing-of-grpc-services)
- [Blog post - gRPC + Istio + Cloud Internal Load Balancer](https://cloud.google.com/solutions/using-istio-for-internal-load-balancing-of-grpc-services)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Blog post - gRPC + Istio + Cloud Internal Load Balancer](https://cloud.google.com/solutions/using-istio-for-internal-load-balancing-of-grpc-services)
[ブログ - Istio を使用して内部 gRPC サービスを負荷分散する](https://cloud.google.com/solutions/using-istio-for-internal-load-balancing-of-grpc-services?hl=ja)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちょうどこんな感じです!! @t-ide

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

リンク先に日本語版があるかどうかを探すのが若干面倒ですね 😅

  • istio.io 日本語はないはず
  • en.wikipedia.org 日本語あるかも
  • www.cncf.io/blog
  • developers.google.com あるかも
  • grpc.io/blog あるかも?
  • www.envoyproxy.io/docs ないと思う
  • cloud.google.com ^で書いてくれてるようにある

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed 👍
2fa883b

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.