The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

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のロードバランサーを使用してポッドを選択するオプションを提供します。

この機能を使用するには、プロジェクトに以下の依存関係を追加します。

pom.xml
<dependency>
    <groupId>io.smallrye.stork</groupId>
    <artifactId>stork-service-discovery-kubernetes</artifactId>
</dependency>
build.gradle
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は拡張可能です。独自のサービスディスカバリプロバイダーやサービスセレクションプロバイダーを実装することができます。

カスタムのサービスディスカバリとサービスセレクションについては、こちらをご覧ください:

Stork のオブザーバビリティの設定

メトリクスの有効化

Stork のメトリクスは、アプリケーションが quarkus-micrometer エクステンションも利用している場合に自動的に有効化されます。

MicrometerはStorkを使用するrest/grpcクライアントとStorkを使用するクライアントのメトリクスをプログラムで収集します。

例えば、メトリクスを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

Stork のサービス名は タグ に記載されています。

メトリックスには、サービスディスカバリー ( stork_service_discovery_* ) とサービスセレクション ( stork_service_selection_* ) に関するメトリックス (サービスインスタンス数、失敗数、持続時間など) の両方が含まれます。

メトリクスの無効か

quarkus-micrometer が使用されているときに Stork メトリクスを無効にするには、アプリケーション設定に以下のプロパティを追加します:

quarkus.micrometer.binder.stork.enabled=false

設定リファレンス

ビルド時に固定される構成プロパティ - 他のすべての構成プロパティは実行時にオーバーライド可能

Configuration for the service

デフォルト

Configures the service discovery type, e.g. "consul". ServiceDiscoveryProvider for the type has to be available

Environment variable: QUARKUS_STORK__SERVICE_NAME__SERVICE_DISCOVERY_TYPE

Show more

string

required

ServiceDiscovery parameters. Check the documentation of the selected service discovery type for available parameters.

Environment variable: QUARKUS_STORK__SERVICE_NAME__SERVICE_DISCOVERY

Show more

Map<String,String>

Configures load balancer type, e.g. "round-robin". A LoadBalancerProvider for the type has to be available

Environment variable: QUARKUS_STORK__SERVICE_NAME__LOAD_BALANCER_TYPE

Show more

string

round-robin

Load Balancer parameters. Check the documentation of the selected load balancer type for available parameters

Environment variable: QUARKUS_STORK__SERVICE_NAME__LOAD_BALANCER

Show more

Map<String,String>

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: QUARKUS_STORK__SERVICE_NAME__SERVICE_REGISTRAR_TYPE

Show more

string

required

Service Registrar parameters. Check the documentation of the selected registrar type for available parameters

Environment variable: QUARKUS_STORK__SERVICE_NAME__SERVICE_REGISTRAR

Show more

Map<String,String>

関連コンテンツ