Chapter 6. Capabilities: Provision of 3scale services and configurations via the operator
This document contains information about 3scale operator for capabilities, which involves provisioning 3scale services and configurations via the 3scale operator through the OpenShift Container Platform (OCP) user interface.
3scale operator for capabilities is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
Prerequisites
- A user account with administrator privileges for 3scale 2.8 On-Premises instance
- You must have the 3scale operator installed.
OpenShift Container Platform 4 with a user account that has administrator privileges in the OpenShift cluster.
- Note: OCP 4 supports deployment of 3scale using the operator only.
- For more information about supported configurations, see the Red Hat 3scale API Management Supported Configurations page.
When using the 3scale operator to update API configurations in 3scale, the custom resource definitions (CRDs) are the source of truth. If changes are made in the Admin user interface, they will not persist and eventually be overridden by the definition in the CRD.
The following sections explain how to deploy custom resources related to capabilities, deploy optional tenant custom resources, and how to delete custom resources:
6.1. Deploying custom resources related to capabilities
Using Openshift Container Platform in your newly created tenant, you will configure APIs, metrics and mapping rules.
6.1.1. Creating an API
The following procedure creates an API with the label api: api01
.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click the API tab.
- Click Create API.
Clear the sample content and add the following YAML definitions to the editor, then click 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: api01
NoteAll the selectors, (metric, plan, mappingrules) use a specific label
api: api01
. You can change this by adding more labels and configuring the selectors to cover complex scenarios.
6.1.2. Adding a plan
The following procedure adds a plan with the label api: api01
.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click the Plan tab.
- Click Create Plan.
Clear the sample content and add the following YAML definitions to the editor, then click 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: 0
6.1.3. Adding a metric
The following procedure adds a metric called metric01
.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click the Metric tab.
- Click Create Metric.
Clear the sample content and add the following YAML definitions to the editor, then click Create.
apiVersion: capabilities.3scale.net/v1alpha1 kind: Metric metadata: labels: api: api01 name: metric01 spec: description: metric01 unit: hit incrementHits: false
6.1.4. Setting a limit
The following procedure sets a limit with a limit of 10 hits per day for the metric.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click the Limit tab.
- Click Create Limit.
Clear the sample content and add the following YAML definitions to the editor, then click 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: day
6.1.5. Adding a mapping rule
The following procedure adds a MappingRule to increment metric01
.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click the MappingRule tab.
- Click Create Mapping Rule.
Clear the sample content and add the following YAML definitions to the editor, then click 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: /path01
6.1.6. Creating binding
The following procedure joins together with the binding object, the API, plan, metric, the set limit, and the mapping rules you previously created. Use the credential created by the Tenant Controller:
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click the Binding tab.
- Click Create Binding.
Clear the sample content and add the following YAML definitions to the editor, then click Create.
apiVersion: capabilities.3scale.net/v1alpha1 kind: Binding metadata: name: mytestingbinding spec: credentialsRef: name: ecorp-tenant-secret APISelector: matchLabels: environment: testing
The binding object references the
ecorp-tenant-secret
and creates the API objects that are labeled asenvironment: staging
.- Navigate to your new 3scale tenant to check that all you carried out in the preceding steps has been created.
6.2. Deploying optional tenants custom resource
Optionally, you may create other tenants deploying Tenant custom resource objects.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click the Tenant tab.
- Click Create Tenant.
Clear the sample content and add the following YAML definitions to the editor, then click Create.
apiVersion: capabilities.3scale.net/v1alpha1 kind: Tenant metadata: name: ecorp-tenant spec: username: admin systemMasterUrl: https://master.<wildcardDomain> email: admin@ecorp.com organizationName: ECorp masterCredentialsRef: name: system-seed passwordCredentialsRef: name: ecorp-admin-secret tenantSecretRef: name: ecorp-tenant-secret namespace: operator-test
Tenant provider_key and admin domain URL will be stored in a secret. You can specify the secret location by using
tenantSecretRef
tenant spec key.
6.3. Deleting created custom resources
The following procedure details how to delete the custom resources.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
Click the tab for the resource you wish to delete.
- You will see the resource listed if one has previously been created.
- Click the name to see the overview.
- Click Action > Delete.
- Confirm the deletion by clicking Delete or Cancel to return to the previous screen.
Alternatively, to delete the 3scale operator, its associated roles and service accounts, do the following.
Procedure
Click Catalog > Installed Operators.
- From the list of Installed Operators, click 3scale Operator.
- Click Action > Delete Cluster Service Version.
- Confirm the deletion by clicking Delete or Cancel to return to the previous screen.
6.4. Additional resources
- For more information, check the reference documentation: 3scale Operator Capabilities CRD Reference.