Stork リファレンスガイド
このガイドは、 Stork 入門ガイドと対です。QuarkusでのSmallRye Stork統合の設定と使用方法について説明しています。
この技術は、previewと考えられています。 preview では、下位互換性やエコシステムでの存在は保証されていません。具体的な改善には設定や API の変更が必要になるかもしれませんが、 stable になるための計画は現在進行中です。フィードバックは メーリングリスト や GitHub の課題管理 で受け付けています。 とりうるステータスの完全なリストについては、 FAQの項目 を参照してください。 |
対応クライアント
現在のStork統合で対応しているのは次の通りです:
-
リアクティブRESTクライアント
-
gRPCクライアント
注意: gRPCクライアント統合は、統計ベースのロードバランサーをサポートしていません。
利用可能なサービスディスカバリーとセレクション
提供されるサービスディスカバリーとセレクションについては、 SmallRye Storkのウェブサイトをご確認ください。
KubernetesでのStorkの使用
Storkは、Kubernetesがデフォルトで提供しているものを超える、Kubernetesのサービスディスカバリーサポートを提供します。これは、KubernetesのサービスをバックアップしているすべてのPodを探しますが、Kubernetesのようにラウンドロビンを適用するのではなく、Storkのロードバランサーを使用してポッドを選択するオプションを提供します。
この機能を使用するには、プロジェクトに以下の依存関係を追加します。
<dependency>
<groupId>io.smallrye.stork</groupId>
<artifactId>stork-service-discovery-kubernetes</artifactId>
</dependency>
implementation("io.smallrye.stork:stork-service-discovery-kubernetes")
Kubernetes Serviceとして公開される予定の各サービスについて、ルックアップを設定します。
quarkus.stork.my-service.service-discovery.type=kubernetes
quarkus.stork.my-service.service-discovery.k8s-namespace=my-namespace
Storkは、指定された名前(前の例では my-service
)のKubernetes Serviceを指定された名前空間で探します。StorkはKubernetes ServiceのIPを直接使用し、選択とバランシングをKubernetesに任せるのではなく、サービスを検査し、サービスを提供しているポッドのリストを取得します。そして、インスタンスを選択することができます。
KubernetesでStorkを使う詳しい例は、 Kubernetes で Stork を使用 をお読みください。
Storkの拡張
Storkは拡張可能です。独自のサービスディスカバリプロバイダーやサービスセレクションプロバイダーを実装することができます。
カスタムのサービスディスカバリとサービスセレクションについては、こちらをご覧ください:
Configure Stork observability
メトリクスの有効化
Stork metrics are automatically enabled when the application also uses the quarkus-micrometer
extension.
Micrometer collects the metrics of rest/grpc clients using Stork and the client using Stork programmatically.
例えば、メトリクスをPrometheusにエクスポートすると、以下のように取得できます。
# HELP stork_service_selection_failures_total The number of failures during service selection.
# TYPE stork_service_selection_failures_total counter
stork_service_selection_failures_total{service_name="hello-service",} 0.0
# HELP stork_service_selection_duration_seconds The duration of the selection operation
# TYPE stork_service_selection_duration_seconds summary
stork_service_selection_duration_seconds_count{service_name="hello-service",} 13.0
stork_service_selection_duration_seconds_sum{service_name="hello-service",} 0.001049291
# HELP stork_service_selection_duration_seconds_max The duration of the selection operation
# TYPE stork_service_selection_duration_seconds_max gauge
stork_service_selection_duration_seconds_max{service_name="hello-service",} 0.0
# HELP stork_overall_duration_seconds_max The total duration of the Stork service discovery and selection operations
# TYPE stork_overall_duration_seconds_max gauge
stork_overall_duration_seconds_max{service_name="hello-service",} 0.0
# HELP stork_overall_duration_seconds The total duration of the Stork service discovery and selection operations
# TYPE stork_overall_duration_seconds summary
stork_overall_duration_seconds_count{service_name="hello-service",} 13.0
stork_overall_duration_seconds_sum{service_name="hello-service",} 0.001049291
# HELP stork_service_discovery_failures_total The number of failures during service discovery
# TYPE stork_service_discovery_failures_total counter
stork_service_discovery_failures_total{service_name="hello-service",} 0.0
# HELP stork_service_discovery_duration_seconds_max The duration of the discovery operation
# TYPE stork_service_discovery_duration_seconds_max gauge
stork_service_discovery_duration_seconds_max{service_name="hello-service",} 0.0
# HELP stork_service_discovery_duration_seconds The duration of the discovery operation
# TYPE stork_service_discovery_duration_seconds summary
stork_service_discovery_duration_seconds_count{service_name="hello-service",} 13.0
stork_service_discovery_duration_seconds_sum{service_name="hello-service",} 6.585046209
# HELP stork_service_discovery_instances_count_total The number of service instances discovered
# TYPE stork_service_discovery_instances_count_total counter
stork_service_discovery_instances_count_total{service_name="hello-service",} 26.0
The Stork service name can be found in the tags.
The metrics contain both the service discovery (stork_service_discovery_*
) and the metrics about the service selection (stork_service_selection_*
) such as the number of service instances, failures, and durations.
設定リファレンス
ビルド時に固定される構成プロパティ - 他のすべての構成プロパティは実行時にオーバーライド可能
型 |
デフォルト |
|
---|---|---|
Configures the service discovery type, e.g. "consul". ServiceDiscoveryProvider for the type has to be available Environment variable: Show more |
string |
required |
ServiceDiscovery parameters. Check the documentation of the selected service discovery type for available parameters. Environment variable: Show more |
|
|
Configures load balancer type, e.g. "round-robin". A LoadBalancerProvider for the type has to be available Environment variable: Show more |
string |
|
Load Balancer parameters. Check the documentation of the selected load balancer type for available parameters Environment variable: Show more |
|
|
ServiceRegistrar configuration for the service This configuration section is optional |
型 |
デフォルト |
Configures service registrar type, e.g. "consul". A ServiceRegistrarProvider for the type has to be available Environment variable: Show more |
string |
required |
Service Registrar parameters. Check the documentation of the selected registrar type for available parameters Environment variable: Show more |
|