マネージド サービス

サービスの検索

kf marketplace コマンドを使用して、アプリで使用するサービスを検索します。引数を指定せずにコマンドを実行すると、使用可能なすべてのサービスクラスが表示されます。サービスクラスは、MySQL データベースや Postfix SMTP リレーなどの特定の種類のサービスを表します。

$ kf marketplace
5 services can be used in Space "test", use the --service flag to list the plans for a service

Broker      Name        Space      Status  Description
minibroker  mariadb                Active  Helm Chart for mariadb
minibroker  mongodb                Active  Helm Chart for mongodb
minibroker  mysql                  Active  Helm Chart for mysql
minibroker  postgresql             Active  Helm Chart for postgresql
minibroker  redis                  Active  Helm Chart for redis

サービスクラスでは複数のプランを使用できます。通常、サービスプランは、ソフトウェアのバージョンまたは料金ティアに対応します。マーケットプレイス コマンドでサービス名を指定すると、特定のサービスのプランを表示できます。

$ kf marketplace --service mysql
Name    Free  Status  Description
5-7-14  true  Active  Fast, reliable, scalable, and easy to use open-source relational database system.
5-7-27  true  Active  Fast, reliable, scalable, and easy to use open-source relational database system.
5-7-28  true  Active  Fast, reliable, scalable, and easy to use open-source relational database system.

サービスのプロビジョニング

プロビジョニングするサービスクラスとプランを特定した後、kf create-service を使用してサービスのインスタンスを作成できます。

$ kf create-service mysql 5-7-28 my-db
Creating service instance "my-db" in Space "test"
Waiting for service instance to become ready...
Success

サービスは 1 つのスペースの中にプロビジョニングされます。現在のスペース内のサービスを表示するには、kf services を実行します。

$ kf services
Listing services in Space: "test"
Name   ClassName  PlanName  Age   Ready  Reason
my-db  mysql      5-7-28    111s  True   <nil>

サービスは、kf delete-service を使用して削除できます。

$ kf delete-service my-db

サービスのバインド

サービスが作成されると、アプリにバインドすることで App 内に認証情報が送られ、サービスを使用できるようになります。バインディングは、kf bind-service を使用して作成できます。

$ kf bind-service my-app my-db
Creating service instance binding "binding-my-app-my-db" in Space "test"
Waiting for service instance binding to become ready...
Success

kf bindings コマンドを使用すると、スペース内のすべてのバインディングを一覧表示できます。

$ kf bindings
Listing bindings in Space: "test"
Name                  App     Service  Age  Ready
binding-my-app-my-db  my-app  my-db    82s  True

サービスがバインドされると、kf restart を使用してアプリを再起動することにより、認証情報が VCAP_SERVICES 環境変数に追加されます。

サービス バインディングは kf unbind-service コマンドで削除できます。

$ kf unbind-service my-app my-db