第6章 機能: operator を使用した 3scale のサービスおよび設定のプロビジョニング
本章では、3scale operator の機能について説明します。これは、OpenShift Container Platform (OCP) ユーザーインターフェイスを介して 3scale operator を使用して 3scale サービスおよび設定をプロビジョニングするものです。
3scale operator の機能は、テクノロジープレビューの機能としてのみ提供されます。テクノロジープレビューの機能は、Red Hat の実稼働環境のサービスレベルアグリーメント (SLA) の対象外であり、機能的に完全ではないことがあります。Red Hat は実稼働環境でこれらを使用することを推奨していません。テクノロジープレビューの機能は、最新の製品機能をいち早く提供して、開発段階で機能のテストを行いフィードバックを提供していただくことを目的としています。Red Hat のテクノロジープレビュー機能のサポート範囲に関する詳細は、テクノロジープレビュー機能のサポート範囲 を参照してください。
前提条件
- オンプレミス型 3scale 2.8 インスタンスの管理者権限を持つユーザーアカウント
- 3scale operator がインストール されている必要があります。
OpenShift Container Platform 4 および OpenShift クラスターの管理者権限を持つユーザーアカウント
- 注記: OCP 4 は、operator を使用した 3scale のデプロイメントのみをサポートしています。
- サポート対象設定の情報については、Red Hat 3scale API Management Supported Configurations のアーティクルを参照してください。
3scale operator を使用して 3scale で API 設定を更新する場合は、カスタムリソース定義 (CRD) が信頼できるソースです。管理ユーザーインターフェイスに変更が加えられると、それらは永続化されず、最終的に CRD の定義で上書きされます。
以降のセクションでは、capabilities に関連するカスタムリソースのデプロイ方法、オプションのテナントカスタムリソースのデプロイ方法、およびカスタムリソースの削除方法について説明します。
6.1. capabilities に関連するカスタムリソースのデプロイ リンクのコピーリンクがクリップボードにコピーされました!
新しく作成したテナントで Openshift Container Platform を使用し、API、メトリクス、および マッピングルール を設定します。
6.1.1. API の作成 リンクのコピーリンクがクリップボードにコピーされました!
以下の手順により、api: api01 というラベルの API を作成します。
手順
Catalog > Installed Operators の順にクリックします。
- Installed Operators のリストで、3scale Operator をクリックします。
- API タブをクリックします。
- Create API をクリックします。
サンプルのコンテンツを消去して以下の YAML 定義をエディターに追加し、続いて Create をクリックします。
apiVersion: capabilities.3scale.net/v1alpha1 kind: API metadata: creationTimestamp: 2019-01-25T13:28:41Z generation: 1 labels: environment: testing name: api01 spec: planSelector: matchLabels: api: api01 description: api01 integrationMethod: apicastHosted: apiTestGetRequest: / authenticationSettings: credentials: apiKey: authParameterName: user-key credentialsLocation: headers errors: authenticationFailed: contentType: text/plain; charset=us-ascii responseBody: Authentication failed responseCode: 403 authenticationMissing: contentType: text/plain; charset=us-ascii responseBody: Authentication Missing responseCode: 403 hostHeader: "" secretToken: Shared_secret_sent_from_proxy_to_API_backend_9603f637ca51ccfe mappingRulesSelector: matchLabels: api: api01 privateBaseURL: https://echo-api.3scale.net:443 metricSelector: matchLabels: api: api01apiVersion: capabilities.3scale.net/v1alpha1 kind: API metadata: creationTimestamp: 2019-01-25T13:28:41Z generation: 1 labels: environment: testing name: api01 spec: planSelector: matchLabels: api: api01 description: api01 integrationMethod: apicastHosted: apiTestGetRequest: / authenticationSettings: credentials: apiKey: authParameterName: user-key credentialsLocation: headers errors: authenticationFailed: contentType: text/plain; charset=us-ascii responseBody: Authentication failed responseCode: 403 authenticationMissing: contentType: text/plain; charset=us-ascii responseBody: Authentication Missing responseCode: 403 hostHeader: "" secretToken: Shared_secret_sent_from_proxy_to_API_backend_9603f637ca51ccfe mappingRulesSelector: matchLabels: api: api01 privateBaseURL: https://echo-api.3scale.net:443 metricSelector: matchLabels: api: api01Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注記すべてのセレクター (metric、plan、mappingrules) で、特定のラベル
api: api01が使用されます。複雑なシナリオに対応するために、さらにラベルを追加してセレクターを設定することで、この設定を変更することができます。
6.1.2. プランの追加 リンクのコピーリンクがクリップボードにコピーされました!
以下の手順により、api: api01 というラベルのプランを追加します。
手順
Catalog > Installed Operators の順にクリックします。
- Installed Operators のリストで、3scale Operator をクリックします。
- Plan タブをクリックします。
- Create Plan をクリックします。
サンプルのコンテンツを消去し、以下の YAML 定義をエディターに追加してから、Create をクリックします。
apiVersion: capabilities.3scale.net/v1alpha1 kind: Plan metadata: labels: api: api01 name: plan01 spec: approvalRequired: false default: true costs: costMonth: 0 setupFee: 0 limitSelector: matchLabels: api: api01 trialPeriod: 0apiVersion: capabilities.3scale.net/v1alpha1 kind: Plan metadata: labels: api: api01 name: plan01 spec: approvalRequired: false default: true costs: costMonth: 0 setupFee: 0 limitSelector: matchLabels: api: api01 trialPeriod: 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.1.3. メトリクスの追加 リンクのコピーリンクがクリップボードにコピーされました!
以下の手順により、metric01 というメトリクスを追加します。
手順
Catalog > Installed Operators の順にクリックします。
- Installed Operators のリストで、3scale Operator をクリックします。
- Metric タブをクリックします。
- Create Metric をクリックします。
サンプルのコンテンツを消去し、以下の YAML 定義をエディターに追加してから、Create をクリックします。
apiVersion: capabilities.3scale.net/v1alpha1 kind: Metric metadata: labels: api: api01 name: metric01 spec: description: metric01 unit: hit incrementHits: falseapiVersion: capabilities.3scale.net/v1alpha1 kind: Metric metadata: labels: api: api01 name: metric01 spec: description: metric01 unit: hit incrementHits: falseCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.1.4. 制限の設定 リンクのコピーリンクがクリップボードにコピーされました!
以下の手順により、メトリクスに 1 日あたり 10 ヒットという制限を設定します。
手順
Catalog > Installed Operators の順にクリックします。
- Installed Operators のリストで、3scale Operator をクリックします。
- Limit タブをクリックします。
- Create Limit をクリックします。
サンプルのコンテンツを消去し、以下の YAML 定義をエディターに追加してから、Create をクリックします。
apiVersion: capabilities.3scale.net/v1alpha1 kind: Limit metadata: labels: api: api01 name: plan01-metric01-day-10 spec: description: Limit for metric01 in plan01 maxValue: 10 metricRef: name: metric01 period: dayapiVersion: capabilities.3scale.net/v1alpha1 kind: Limit metadata: labels: api: api01 name: plan01-metric01-day-10 spec: description: Limit for metric01 in plan01 maxValue: 10 metricRef: name: metric01 period: dayCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.1.5. マッピングルールの追加 リンクのコピーリンクがクリップボードにコピーされました!
以下の手順により、metric01 のカウントを増加させる MappingRule を追加します。
手順
Catalog > Installed Operators の順にクリックします。
- Installed Operators のリストで、3scale Operator をクリックします。
- MappingRule タブをクリックします。
- Create Mapping Rule をクリックします。
サンプルのコンテンツを消去し、以下の YAML 定義をエディターに追加してから、Create をクリックします。
apiVersion: capabilities.3scale.net/v1alpha1 kind: MappingRule metadata: labels: api: api01 name: metric01-get-path01 spec: increment: 1 method: GET metricRef: name: metric01 path: /path01apiVersion: capabilities.3scale.net/v1alpha1 kind: MappingRule metadata: labels: api: api01 name: metric01-get-path01 spec: increment: 1 method: GET metricRef: name: metric01 path: /path01Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.1.6. バインディングの作成 リンクのコピーリンクがクリップボードにコピーされました!
以下の手順により、バインディングオブジェクトを使用して、作成済みの、API、プラン、メトリクス、設定制限、およびマッピングルールを結合します。テナントコントローラーで作成されたクレデンシャルを使用します。
手順
Catalog > Installed Operators の順にクリックします。
- Installed Operators のリストで、3scale Operator をクリックします。
- Binding タブをクリックします。
- Create Binding をクリックします。
サンプルのコンテンツを消去し、以下の YAML 定義をエディターに追加してから、Create をクリックします。
apiVersion: capabilities.3scale.net/v1alpha1 kind: Binding metadata: name: mytestingbinding spec: credentialsRef: name: ecorp-tenant-secret APISelector: matchLabels: environment: testingapiVersion: capabilities.3scale.net/v1alpha1 kind: Binding metadata: name: mytestingbinding spec: credentialsRef: name: ecorp-tenant-secret APISelector: matchLabels: environment: testingCopy to Clipboard Copied! Toggle word wrap Toggle overflow バインディングオブジェクトは、
ecorp-tenant-secretを参照して、environment: stagingのラベルが設定された API オブジェクトを作成します。- 新しい 3scale テナントに移動し、前のステップで実行したすべての設定が作成されていることを確認します。