Questo contenuto non è disponibile nella lingua selezionata.
Chapter 7. Using the 3scale API Management operator to configure and provision 3scale
As a Red Hat 3scale API Management administrator, you can use the 3scale operator to configure 3scale services and provision 3scale resources. You use the operator in the OpenShift Container Platform (OCP) user interface. Using the operator is an alternative to configuring and provisioning 3scale in the Admin Portal or by using the 3scale internal API.
When you use the 3scale operator to configure a service or provision a resource the only way to update that service or resource is to update its custom resource (CR).
In the Admin Portal, services and resources are visible, but do not make updates there. Likewise, do not make updates using the internal 3scale API to update services and resources. Making updates using methods other than a CR will cause the operator to revert changes, keeping the configuration unchanged.
This chapter includes details about how operator application capabilities work and how to use the operator to deploy custom resources:
Additionally, there is information about the limitations of capabilities when using the 3scale operator.
7.1. General prerequisites Copia collegamentoCollegamento copiato negli appunti!
To configure and provision 3scale by using the 3scale operator, these are the required elements:
- A user account with administrator privileges for 3scale API Management 2.14 On-Premises instance
- 3scale API Management operator installed.
OpenShift Container Platform 4 with a user account that has administrator privileges in the OpenShift cluster.
- For more information about supported configurations, see the Red Hat 3scale API Management Supported Configurations page.
7.2. Application capabilities via the 3scale API Management operator Copia collegamentoCollegamento copiato negli appunti!
The 3scale operator contains these featured capabilities:
- Allows interaction with the underlying Red Hat 3scale API Management solution.
- Manages the 3scale application declaratively using custom resources from OpenShift.
The diagram below shows 3scale entities and relations that are eligible for management using OpenShift custom resources in a declarative way. Products contain one or more backends. At the product level, you can configure applications, application plans, as well as mapping rules. At the backend level, you can set up metrics, methods and mapping rules for each backend.
The 3scale operator provides custom resource definitions and their relations, which are visible in the following diagram.
7.3. Deploying your first 3scale API Management product and backend Copia collegamentoCollegamento copiato negli appunti!
Using OpenShift Container Platform (OCP) in your newly created tenant, you will deploy your first 3scale product and backend with the minimum required configuration.
Prerequisites
The same installation requirements as listed in General prerequisites, with these considerations:
- The 3scale account can be local in the working OpenShift namespace or a remote installation.
- The required parameters from this account are the 3scale Admin Portal URL address and the access token.
Procedure
Create a secret for the 3scale provider account using the credentials from the 3scale Admin Portal. For example:
adminURL=https://3scale-admin.example.comandtoken=123456.oc create secret generic threescale-provider-account --from-literal=adminURL=https://3scale-admin.example.com --from-literal=token=123456
$ oc create secret generic threescale-provider-account --from-literal=adminURL=https://3scale-admin.example.com --from-literal=token=123456Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the 3scale backend with the upstream API URL:
Create a YAML file with the following content:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Once you create the file, the operator will confirm if the step was successful.
- For more details about the fields of Backend custom resource (CR) and possible values, see the Backend custom resource definition (CRD) reference.
Create a custom resource:
oc create -f backend1.yaml
$ oc create -f backend1.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure the 3scale product:
Create a product with all the default settings applied to the previously created backend:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Once you create the file, the operator will confirm if the step was successful.
- For more details about the fields of the Product CR and possible values, see the Product CRD Reference.
Create a custom resource:
oc create -f product1.yaml
$ oc create -f product1.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Additionally, you can update an existing product CRD to link to a backend:
oc apply -f product.yaml
$ oc apply -f product.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Created custom resources will take a few seconds to populate your 3scale instance. To confirm when resources are synchronized, you can choose one of these alternatives:
- Verify the status field of the object.
Use the
oc waitcommands:oc wait --for=condition=Synced --timeout=-1s backend/backend1 oc wait --for=condition=Synced --timeout=-1s product/product1
$ oc wait --for=condition=Synced --timeout=-1s backend/backend1 $ oc wait --for=condition=Synced --timeout=-1s product/product1Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.4. Promoting a product’s APIcast configuration Copia collegamentoCollegamento copiato negli appunti!
Using the 3scale operator, you can promote the product’s APIcast configuration to staging or production. The ProxyConfigPromote custom resource (CR) promotes the latest APIcast configuration to the staging environment. Optionally, you can configure the ProxyConfigPromote CR to promote to the production environment as well.
ProxyConfigPromote objects only take effect when created. After creation, any updates on them are not reconciled.
Prerequisites
The same installation requirements as listed in General prerequisites, including:
- Have a product CR already created.
Procedure
Create and save a YAML file with the following content:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To promote the APIcast configuration to the production environment, set the optional field
spec.productiontotrue:Copy to Clipboard Copied! Toggle word wrap Toggle overflow To delete the
ProxyConfigPromote objectafter a successful promotion, set the optional fieldspec.deleteCRtotrue:Copy to Clipboard Copied! Toggle word wrap Toggle overflow To check the status condition of the file, type the following command:
oc get proxyconfigpromote proxyconfigpromote-sample -o yaml
oc get proxyconfigpromote proxyconfigpromote-sample -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow The output should show the status is
Ready:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you do not make changes in the proxy configuration, you get a
Failedoutput status of the ProxyConfigPromote CR with the following message:can’t promote to production as no product changes detected, delete the proxyConfigPromote CR or introduce changes to stage env first to proceed. Follow those instructions to complete the procedure.
Create the custom resource:
oc create -f proxyconfigpromote-sample.yaml
oc create -f proxyconfigpromote-sample.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
proxyconfigpromote.capabilities.3scale.net/proxyconfigpromote-sample created
proxyconfigpromote.capabilities.3scale.net/proxyconfigpromote-sample createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
7.5. How the 3scale API Management operator identifies the tenant that a custom resource links to Copia collegamentoCollegamento copiato negli appunti!
You can deploy 3scale custom resources (CRs) to manage a variety of 3scale objects. A 3scale CR links to exactly one tenant.
If the 3scale operator is installed in the same namespace as 3scale the default behavior is that a 3scale CR links to that 3scale instance’s default tenant. To link a 3scale CR to a different tenant, you can do one of the following:
Create the
threescale-provider-accountsecret in the namespace that contains the 3scale CR. When you deploy a 3scale CR, the operator reads this secret to identify the tenant that the CR links to. For the operator to use this secret, one of the following must be true:-
The 3scale CR specifies the
spec.providerAccountReffield as null. The 3scale CR omits the
spec.providerAccountReffield.The
threescale-provider-accountsecret identifies the tenant that the CR links to. The secret must contain a reference to a 3scale instance in the form of a URL and credentials for accessing a tenant in that 3scale instance in the form of a token. For example:$ oc create secret generic threescale-provider-account --from-literal=adminURL=https://3scale-admin.example.com --from-literal=token=123456
$ oc create secret generic threescale-provider-account --from-literal=adminURL=https://3scale-admin.example.com --from-literal=token=123456Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
threescale-provider-accountsecret can identify any tenant in any 3scale instance as long as the HTTP connection is available. In other words, a 3scale CR and the 3scale instance that contains the tenant that the CR links to can be in different namespaces, or in different OpenShift clusters.
-
The 3scale CR specifies the
In the 3scale CR, specify
spec.providerAccountRefand set it to the name of a local reference to an OpenShiftSecretthat identifies the tenant. In the following 3scaleDeveloperAccountCR example,mytenantis the secret:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the secret:
-
adminURLspecifies the URL for a 3scale instance that can be in any namespace. tokenspecifies credentials for access to one tenant in that 3scale instance. This tenant can be the default tenant or any other tenant in that instance.Typically, when you deploy a tenant CR you create this secret. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
If the 3scale operator cannot identify the tenant that a CR links to, the operator generates an error message.
7.6. Deploying 3scale API Management OpenAPI custom resources Copia collegamentoCollegamento copiato negli appunti!
An OpenAPI custom resource (CR) is one way to import an OpenAPI Specification (OAS) document that you can use for ActiveDocs in the Developer Portal. The OAS is a standard that does not tie you to using one particular programming language for your APIs. Humans and computers can more easily understand the capabilities of the API product without source code access, documentation, or network traffic inspection.
Prerequisites
- A user account with administrator privileges for a 3scale 2.14 On-Premises instance.
- An OAS document that defines your API.
-
An understanding of how an
OpenAPICR links to a tenant. -
apiKeyandopenIdConnect/oauth2are the supported security schemes.
OpenID Connect and OAuth2 limitations
To configure 3scale in the OpenAPI specification, you must provide the following data in the OpenAPI custom resource (CR):
OpenID Connect (OIDC)
issuerType:-
Define the issuer type, which defaults to
rest. You can override this parameter in the OpenAPI CR.
-
Define the issuer type, which defaults to
Define the
issuerEndpoint, as a plain value URL, or theissuerEndpointRefsecret with theissuerEndpointURL.-
If you define the
issuerEndpointplain value in the CR, it takes precedence overissuerEndpointRefsecret. -
The
issuerEndpointformat depends on the OpenID Provider setup. For Red Hat Single Sign-On it ishttps://<CLIENT_ID>:<CLIENT_SECRET>@:/auth/realms/<REALM_NAME>.
-
If you define the
Flows Object:
-
When you define the
oauth2security scheme, the OpenAPI document includes the flows. However, when the security scheme is OpenID Connect, the OpenAPI document does not provide the flows. In this case, the OpenAPI CR can provide them.
-
When you define the
7.6.1. Deploying a 3scale OpenAPI custom resource that imports an OAS document from a secret Copia collegamentoCollegamento copiato negli appunti!
Deploy an OpenAPI custom resource (CR) so that you can create 3scale backends and products.
The operator reads only the content in the secret. The operator does not read the field name in the secret.
Prerequisites
You understand How the 3scale operator identifies the tenant that a custom resource links to.
Procedure
Define a secret that contains an OAS document. For example, you might create the
myoasdoc1.yamlwith this content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the secret. For example:
oc create secret generic myoasdoc1 --from-file myoasdoc1.yaml
$ oc create secret generic myoasdoc1 --from-file myoasdoc1.yaml secret/myoasdoc1 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Define your
OpenAPICR. Be sure to specify a reference to the secret that contains your OAS document. For example, you might create themyopenapicr1.yamlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the resource you just defined. For example:
oc create -f myopenapicr1.yaml
$ oc create -f myopenapicr1.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
openapi.capabilities.3scale.net/myopenapicr1 created
$ openapi.capabilities.3scale.net/myopenapicr1 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.6.2. Features of 3scale API Management OpenAPI custom resource definitions Copia collegamentoCollegamento copiato negli appunti!
Knowledge of the OpenAPI custom resource definition (CRD) deployment features will help you with configuration of the 3scale product, backend, and the subsequent creation of ActiveDocs for the Developer Portal.
The OAS document can be read from the following:
- The Kubernetes secret.
- The URL in both http and https formats.
-
In an OAS document, the
info.titlesetting must not exceed 215 characters. The operator uses this setting to create OpenShift object names, which have length limitations. -
Only the first
servers[0].urlelement in a server list is parsed as a private URL. The OpenAPI Specification (OAS) uses itsbasePathcomponent ofservers[0].urlelement. -
The
OpenAPICRD supports a single top level security requirement, however it does not support operational level security. -
The
OpenAPICRD supports theapiKeyand theopenIdConnect/oauth2security schemes.
7.6.3. Import rules when defining OpenAPI custom resources Copia collegamentoCollegamento copiato negli appunti!
The import rules specify how the OpenAPI Specification (OAS) works with 3scale when you are setting up an OpenAPI document for your 3scale deployment.
Product name
The default product system name is taken from the info.title field in the OpenAPI document. To override the product name in an OpenAPI document, specify the spec.productSystemName field in an OpenAPI custom resource (CR).
Private base URL
The private base URL is read from the OpenAPI CR servers[0].url field. You can override this by using the spec.privateBaseURL field in your OpenAPI CR.
3scale methods
Each operation that is defined in the imported OpenAPI document translates to one 3scale method at the product level. The method name is read from the operationId field of the operation object.
3scale mapping rules
Each operation that is defined in the imported OpenAPI document translates to one 3scale mapping rule at the product level. Previously existing mapping rules are replaced by those imported with the OpenAPI CR.
In an OpenAPI document, the paths object provides mapping rules for verb and pattern properties. 3scale methods are associated accordingly to the operationId.
The delta value is hard-coded to 1.
By default, Strict matching policy is configured. Matching policy can be switched to Prefix matching using the spec.PrefixMatching field of the OpenAPI CRD.
Authentication
Just one top level security requirement is supported. Operation level security requirements are not supported.
The supported security scheme is apiKey.
The apiKey security scheme type:
-
credentials location will be read from the OpenAPI document
infield of the security scheme object. -
Auth user key will be read from the OpenAPI document
namefield of the security scheme object.
The following is a partial example of OAS 3.0.2 with apiKey security requirement:
When the OpenAPI document does not specify any security requirements, the following applies:
-
The product authentication will be configured for
apiKey. -
credentials location will default to 3scale value
As query parameters (GET) or body parameters (POST/PUT/DELETE). -
The Auth user key defaults to 3scale value
user_key.
3scale Authentication Security can be set using the spec.privateAPIHostHeader and the spec.privateAPISecretToken fields of the OpenAPI CRD.
ActiveDocs
No 3scale ActiveDoc is created.
3scale product policy chain
The 3scale policy chain is the default one 3scale creates.
3scale deployment mode
By default, the configured 3scale deployment mode will be APIcast 3scale managed. However, when the spec.productionPublicBaseURL or the spec.stagingPublicBaseURL, or both fields are present in an OpenAPI CR, the product’s deployment mode is APIcast self-managed.
Example of a OpenAPI CR with custom public base URL:
7.6.4. Configuring OpenID Connect and OAuth2 Copia collegamentoCollegamento copiato negli appunti!
Red Hat 3scale API Management requires additional information not included in the OpenAPI Specification (OAS). You must provide this information in the OpenAPI custom resource (CR), specifically the following:
OpenID Connect Issuer Type
Defaults to
rest, but it can be overridden from the OpenAPI CR.OpenID Connect Issuer Endpoint Reference (Secret)
3scale requires that the issuer URL includes a client secret.
Flows object
When the security scheme is OAuth2, the flows are provided by the OpenAPI document. However, for the OpenID Connect (OIDC) security scheme, the OpenAPI document does not provide the flows.
There are 4 flows parameters for OIDC only:
-
standardFlowEnabled -
implicitFlowEnabled -
serviceAccountsEnabled -
directAccessGrantsEnabled.
-
OIDC issuer secret
- You have previously setup Issuer Client. RHSSO/keycloak realm and client are using it in the secret example.
-
issuerEndpointformat ishttps://<client-id>:<client-secret>@<host>:<port>/auth/realms/<realm-name>. The format is described in the3scale Portal/Products page - AUTHENTICATION SETTINGS - OpenID Connect Issuer. -
The <client-secret> value is taken from the Issuer Client in
Realm/Clients/ClientID/Credentials/Secret.
Procedure
Create the secret, for example,
my-secret.yaml, with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the secret with the following command:
oc apply -f my-secret.yaml
$ oc apply -f my-secret.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the OpenAPI CR for OIDC and OAuth2, for example,
openapi-example.yaml, with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the OpenAPI CR for OIDC and OAuth2 with the following command:
oc apply -f <openapi-cr-file>.yaml
$ oc apply -f <openapi-cr-file>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- The OIDC field is optional in the OpenAPI CR, applicable only for OpenID Connect.
-
issuerEndpointRefshould reference a secret containing theissuerEndpoint
| Field | Required | Description |
|
| no |
Valid values: [ |
|
| no |
|
|
| no |
The secret that contains |
|
| no |
JSON Web Token (JWT) Claim with ClientID that contains the clientID. Defaults to |
|
| no |
|
|
| no |
Flows object: When the security scheme is OAuth2, the flows are provided by the OpenAPI document. However, for the OIDC security scheme, the OpenAPI document does not provide the flows. In that case, the OpenAPI CR can provide those. There are 4 flows parameters for OIDC only: |
|
| no | Specifies custom gateway response on errors. See GatewayResponseSpec. |
-
Define the
issuerEndpointReforissuerEndpointin OIDC specification, however you can define both fields. -
If
issuerEndpointplain value is defined in the CR, it will be used as precedence overissuerEndpointRefsecret. The format of
issuerEndpointis determined on your OpenID Provider setup:In the 3scale Admin Portal, navigate to [Your_product_name] > Integration > Settings. Under Authentication, click the OpenID Connect Issuer option. Check the OpenID Connect Issuer Type.
The following is an OpenAPI CR example where
issuerEndpointis defined both as plain value and in secret. The plain value is used:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If the OpenAPI CR specification is OIDC, but the
securitySchemestype in OAS isoauth2, then the CR OIDC Authentication Flows parameters will be ignored, and Product OIDC Authentication Flows will be set to matchoauth2flows as defined in OAS:-
standardFlowEnabledis true if OAuth2authorizationCodeis defined -
implicitFlowEnabledis true if OAuth2implicitis defined -
serviceAccountsEnabledis true if OAuth2clientCredentialsis defined directAccessGrantsEnabledis true if OAuth2passwordis definedAn example of OAS
securitySchemesdefinition that allows selection of all Product OIDC Authentication Flows. Note: Define OIDC in the OpenAPI CR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Additional resources
7.6.5. Deploying a 3scale API Management OpenAPI custom resource that imports an OAS document from a URL Copia collegamentoCollegamento copiato negli appunti!
You can deploy an OpenAPI custom resource that imports an OAS document from a URL that you specify. You can then use this OAS document as the foundation for ActiveDocs for your API in the Developer Portal.
Prerequisites
If you are creating an
OpenAPIcustom resource that does not link to the default tenant in the 3scale instance that is in the same namespace then the namespace that will contain theOpenAPICR contains a secret that identifies the tenant that theOpenAPICR links to. The name of the secret is one of the following:-
threescale-provider-account - User defined
This secret contains the URL for a 3scale instance and a token that contains credentials for access to one tenant in that 3scale instance.
-
Procedure
- In your OpenShift account, navigate to Operators > Installed operators.
- Click the 3scale operator.
- Choose the YAML tab.
Create an
OpenAPIcustom resource (CR). For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Click Save. It takes a few seconds for the 3scale operator to create the
OpenAPICR.
Verification
-
In OpenShift, in the 3scale Product Overview page, confirm that the Synced condition is marked as
True. - Go to your 3scale account.
-
Confirm that the OAS document is present. For the example above, you would see a new OAS document named
openapi1.
7.6.6. Additional resources Copia collegamentoCollegamento copiato negli appunti!
7.7. Deploying 3scale API Management ActiveDoc custom resources Copia collegamentoCollegamento copiato negli appunti!
Red Hat 3scale API Management ActiveDocs are based on API definition documents that define RESTful web services that conform to the OpenAPI Specification. An ActiveDoc custom resource (CR) is one way to import an OpenAPI Specification (OAS) document that you can use for ActiveDocs in the Developer Portal. The OAS is a standard that does not tie you to using one particular programming language for your APIs. Humans and computers can more easily understand the capabilities of the API product without source code access, documentation, or network traffic inspection.
Prerequisites
- A user account with administrator privileges for a 3scale 2.14 On-Premises instance.
An OAS document that defines your API.
- OAS 3.0.2 is the only supported version with the ActiveDocs custom resource definition (CRD).
-
An understanding of how an
ActiveDocCR links to a tenant.
7.7.1. Deploying a 3scale API Management ActiveDoc custom resource that imports an OAS document from a secret Copia collegamentoCollegamento copiato negli appunti!
Deploy an ActiveDoc custom resource (CR) so that you can create 3scale backends and products.
The operator reads only the content in the secret. The operator does not read the field name in the secret. For example, data is structured in key: value pairs, where value represents the content of a file and key is the file name. The file name is ignored by the operator in this context of ActiveDoc CRD. The operator reads only the content of the file.
Prerequisites
- You understand How the 3scale API Management operator identifies the tenant that a custom resource links to.
Define a secret that contains an OAS (OpenAPI Specification) document. For example, you might create the
myoasdoc1.yamlwith this content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Create the secret. For example:
oc create secret generic myoasdoc1 --from-file myoasdoc1.yaml
$ oc create secret generic myoasdoc1 --from-file myoasdoc1.yaml secret/myoasdoc1 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Define your
ActiveDocCR. Be sure to specify a reference to the secret that contains your OAS document. For example, you might create themyactivedoccr1.yamlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the resource you just defined. For example:
oc create -f myactivedoccr1.yaml
$ oc create -f myactivedoccr1.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
activedoc.capabilities.3scale.net/myactivedoccr1 created
$ activedoc.capabilities.3scale.net/myactivedoccr1 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
- Log in to your Red Hat OpenShift Container Platform (OCP) administrator account.
- Navigate to Operators > Installed Operators.
- Click Red Hat Integration - 3scale.
- Click the Active Doc tab.
-
Confirm that the OAS document is present. For the example above, you would see a new OAS document named
myactivedoccr1.
7.7.2. Features of 3scale API Management ActiveDoc custom resource definitions Copia collegamentoCollegamento copiato negli appunti!
The ActiveDoc custom resource definition (CRD) concerns product documentation in the OpenAPI document format for developers. Knowledge of the ActiveDoc CRD deployment features help you with the creation of ActiveDocs for the Developer Portal.
An
ActiveDocCR, can read and OpenAPI document from either of the following:- Secret.
-
A URL in either
httporhttpsformat
-
Optionally, you can link the
ActiveDocCR with a 3scale product using theproductSystemNamefield. The value must be thesystem_nameof the 3scale product’s CR. -
You can publish or hide the
ActiveDocdocument in 3scale using thepublishedfield. By default, this is set to behidden. -
You can skip OpenAPI 3.0 validation using the
skipSwaggerValidationsfield. By default, theActiveDocCR is validated.
Additional resources
7.7.3. Deploying a 3scale API Management ActiveDoc custom resource that imports an OAS document from a URL Copia collegamentoCollegamento copiato negli appunti!
You can deploy an ActiveDoc custom resource (CR) that imports an OAS (OpenAPI Specification) document from a URL that you specify. You can then use this OAS document as the foundation for ActiveDocs for your API in the Developer Portal.
Prerequisites
Procedure
- In your OpenShift account, navigate to Operators > Installed operators.
- Click the 3scale operator.
- Click the Active Doc tab.
Create an
ActiveDocCR. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional. For self-managed APIcast, in the
ActiveDocCR, set theproductionPublicBaseURLandstagingPublicBaseURLfields to the URLs for your deployment. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Click Save. It takes a few seconds for the 3scale operator to create the
ActiveDocCR.
Verification
- Log in to your Red Hat OpenShift Container Platform (OCP) administrator account.
- Navigate to Operators > Installed Operators.
- Click Red Hat Integration 3scale.
- Click the Active Doc tab.
-
Confirm that the OAS document is present. For the example above, you would see a new OAS document named
myactivedoccr1.
7.7.4. Additional resources Copia collegamentoCollegamento copiato negli appunti!
7.11. Deploying 3scale API Management CustomPolicyDefinition custom resources Copia collegamentoCollegamento copiato negli appunti!
You can use a CustomPolicyDefinition custom resource definition (CRD) to configure your custom policy in a 3scale product from the Admin Portal.
When the 3scale operator finds a new CustomPolicyDefinition custom resource (CR), the operator identifies the tenant that owns the CR as described in How the 3scale API Management operator identifies the tenant that a custom resource links to.
Prerequisites
- The 3scale operator is installed.
- You have a custom policy file ready to be deployed.
- You have already injected the custom policy in the gateway.
Procedure
Define a
CustomPolicyDefinitionCR and save it in, for example, themy-apicast-custom-policy-definition.yamlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
CustomPolicyDefinitionCR:oc create -f my-apicast-custom-policy-definition.yaml
$ oc create -f my-apicast-custom-policy-definition.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
7.12. Deploying a tenant custom resource Copia collegamentoCollegamento copiato negli appunti!
A Tenant custom resource (CR) is also known as the Provider Account.
When you deploy an APIManager CR you are using the 3scale operator to deploy 3scale. A default 3scale installation includes a default tenant ready to be used. Optionally, you can create other tenants by deploying Tenant CR.
Prerequisites
- General prerequisites
-
An OpenShift role that has
createpermission in the newTenantCR’s namespace.
Procedure
Navigate to the OpenShift project in which 3scale is installed. For example, if the name of the project is
my-3scale-project, run the following command:oc project my-3scale-project
$ oc project my-3scale-projectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a secret that contains the password for the 3scale admin account for the new tenant. In the definition of the
TenantCR, set thepasswordCredentialsRefattribute to the name of this secret. In the example of aTenantCR definition in step 4,ADMIN_SECRETis the placeholder for this secret. The following command provides an example of creating the secret:oc create secret generic ecorp-admin-secret --from-literal=admin_password=<admin password value>
$ oc create secret generic ecorp-admin-secret --from-literal=admin_password=<admin password value>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the 3scale master account hostname. When you deploy 3scale by using the operator, the master account has a fixed URL with this pattern:
master.${wildcardDomain}If you have access to the namespace where 3scale is installed, you can obtain the master account hostname with this command:
oc get routes --field-selector=spec.to.name==system-master -o jsonpath="{.items[].spec.host}"$ oc get routes --field-selector=spec.to.name==system-master -o jsonpath="{.items[].spec.host}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the example of a
TenantCR definition in step 4,MASTER_HOSTNAMEis the placeholder for this name.Create a file that defines the new
TenantCR.In the definition of the
TenantCR, set themasterCredentialsRef.nameattribute tosystem-seed. You can perform tenant management tasks only by using the 3scale master account credentials, preferably an access token. During deployment of anAPIManagerCR, the operator creates the secret that contains master account credentials. The name of the secret issystem-seed.If 3scale is installed in cluster wide mode, you can deploy the new tenant in a namespace that is different from the namespace that contains 3scale. To do this, set
masterCredentialsRef.namespaceto the namespace that contains the 3scale installation.The following example assumes that 3scale is installed in cluster wide mode.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
TenantCR. For example, if you saved the previous example CR in themytenant.yamlfile, you would run:oc create -f mytenant.yaml
$ oc create -f mytenant.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow As a result of this command:
-
The operator deploys a tenant in the 3scale installation pointed to by the setting of the
spec.systemMasterUrlattribute. The 3scale operator creates a secret that contains credentials for the new tenant. The name of the secret is the value you specified for the
tenantSecretRef.nameattribute. This secret contains the new tenant`s admin URL and access token.As a reference, this is an example of the secret that the operator creates:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
You can now deploy
Product,Backend,OpenAPI,DeveloperAccount, andDeveloperUserCRs that link to your new tenant.
-
The operator deploys a tenant in the 3scale installation pointed to by the setting of the
Deleting a Tenant custom resource
To delete a deployed Tenant CR, you can specify the name of the file that contains the resource definition, for example:
oc delete -f mytenant.yaml
$ oc delete -f mytenant.yaml
Alternatively, you can run the oc delete command, specify the name in the Tenant CR and also specify the tenant’s namespace. For example:
oc delete tenant.capabilities.3scale.net mytenant -n mynamespace
$ oc delete tenant.capabilities.3scale.net mytenant -n mynamespace
When you delete a tenant, the 3scale operator does the following:
- Hides the tenant from the 3scale installation.
- Deletes the deployed custom resources that the tenant owns.
- Marks the tenant to be deleted after 15 days.
After you delete a tenant, you cannot recover it. You have 15 days to back up any resources that the tenant owned and you can do this only in the Admin Portal. After 15 days, 3scale deletes the tenant. To comply with data protection laws, some data is kept for future reference.
Do not delete a tenant in the Admin Portal if you deployed that tenant with a Tenant CR. If you do, the operator creates another tenant by using the CR for the tenant that you tried to delete.
Additional resources
7.13. Managing 3scale API Management developers by deploying custom resources Copia collegamentoCollegamento copiato negli appunti!
As a 3scale administrator, you can use custom resources (CRs) to deploy developer accounts that group together individual developer users. These accounts let you organize and manage developer access to 3scale-managed APIs in the Developer Portal.
A tenant can contain any number of developer accounts and each developer account links to exactly one tenant. A developer account can contain any number of developer users and each developer user links to exactly one developer account. The tenant plan determines any limits on how many developer accounts you can create and how many developer users can be grouped in each developer account.
To use developer custom resources, 3scale must have been installed by the 3scale operator. You can deploy developer custom resources in only the namespace that contains the 3scale operator. Deployment of developer custom resources is an alternative to managing developers by using the 3scale Admin Portal or the 3scale internal API.
When you create developer accounts or developer users by deploying custom resources you cannot use the Admin Portal or the internal 3scale API to update those developer accounts or developer users. It is important to be aware of this because after you deploy a developer CR, the Admin Portal displays the new developer account or new developer user in its Accounts page. If you try to use the Admin Portal or API to update a developer account or developer user that was deployed with a CR, the 3scale operator reverts the changes to reflect the deployed CR. This is a limitation that is expected to be removed in a future release. You can, however, use the Admin Portal or API to delete a developer account or developer user that you created by deploying a CR.
7.13.1. Prerequisites Copia collegamentoCollegamento copiato negli appunti!
- 3scale was installed by the 3scale operator.
-
Access token with read and write permissions in the
Account ManagementAPI scope, which provides administrator privileges for 3scale.
7.13.2. Managing 3scale API Management developer accounts by deploying DeveloperAccount custom resources Copia collegamentoCollegamento copiato negli appunti!
When you use the 3scale operator to install 3scale you can deploy DeveloperAccount and DeveloperUser custom resources (CRs). These custom resources let you create and update accounts for developer access to 3scale-managed APIs in the Developer Portal.
To deploy a new DeveloperAccount CR, you must also deploy a DeveloperUser CR for a user who has the admin role. The procedure provided here is for deploying a new DeveloperAccount CR. After you deploy a DeveloperAccount CR, the procedure for updating or deleting it is the same as for any other CR.
You can deploy custom resources only in the namespace that contains the 3scale operator.
Prerequisites
- An understanding of how the 3scale API Management operator identifies the tenant that a custom resource links to.
If you are creating a
DeveloperAccountCR that does not link to the default tenant in the 3scale instance that is in the same namespace, then the namespace that will contain theDeveloperAccountCR contains a secret that identifies the tenant that theDeveloperAccountCR links to. The name of the secret is one of the following:-
threescale-provider-account - User defined
This secret contains the URL for a 3scale instance and a token that contains credentials for access to one tenant in that 3scale instance.
-
-
You have the username, password, and email address for at least one developer user who will have the
adminrole in the newDeveloperAccountCR.
Procedure
In the namespace that contains the 3scale operator, create and save a resource file that defines a secret that contains the user name and password for a developer user who will have the
adminrole in the new developer account resource. For example, themyusername01.yamlfile might contain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the secret. For example:
oc create -f myusername01.yaml
$ oc create -f myusername01.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
secret/myusername01 created
$ secret/myusername01 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create and save a
.yamlfile that defines aDeveloperUserCR for a developer who has theadminrole. ThisDeveloperUserCR is required for the 3scale operator to deploy a newDeveloperAccountCR. For example, thedeveloperuser01.yamlfile might contain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In a
DeveloperUserCR:-
The developer user account name, user name, and email must be unique in the tenant that the containing
DeveloperAccountlinks to. -
The developer account name that you specify here must match the name of the
DeveloperAccountCR that you are deploying in this procedure. It does not matter whether you create theDeveloperAccountCR before or after you create thisDeveloperUserCR. -
The tenant that a
DeveloperUserCR links to must be the same tenant that the specifiedDeveloperAccountCR links to.
-
The developer user account name, user name, and email must be unique in the tenant that the containing
Create the resource you just defined. For example:
oc create -f developeruser01.yaml
$ oc create -f developeruser01.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
developeruser.capabilities.3scale.net/developeruser01 created
$ developeruser.capabilities.3scale.net/developeruser01 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create and save a
.yamlfile that defines aDeveloperAccountCR. In this.yamlfile, thespec.OrgNamefield must specify an organization name. For example, thedeveloperaccount01.yamlfile might contain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the resource you just defined. For example:
oc create -f developeraccount01.yaml
$ oc create -f developeraccount01.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
developeraccount.capabilities.3scale.net/developeraccount01 created
$ developeraccount.capabilities.3scale.net/developeraccount01 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
It takes a few seconds for the 3scale operator to update the 3scale configuration to reflect new or updated custom resources. To check whether the operator is propagating custom resource information successfully, check the DeveloperAccount CR status field or run the oc wait command, for example:
oc wait --for=condition=Ready --timeout=30s developeraccount/developeraccount1
$ oc wait --for=condition=Ready --timeout=30s developeraccount/developeraccount1
In case of failure, the custom resource’s status field indicates if the error is transient or permanent, and provides an error message that helps fix the problem.
Notify any new developer users that they can log in to the Developer Portal. You might also need to communicate their log-in credentials.
You can update a deployed DeveloperAccount CR in the same way that you update any other custom resource. For example, in the OpenShift project that contains the tenant that owns the DeveloperAccount CR that you want to update, you would run the following command to update the devaccount1 CR:
oc edit developeraccount devaccount1
$ oc edit developeraccount devaccount1
7.13.3. Managing 3scale API Management developer users by deploying DeveloperUser custom resources Copia collegamentoCollegamento copiato negli appunti!
When you use the 3scale operator to install 3scale you can deploy DeveloperUser custom resources (CRs) for managing developer access to 3scale-managed APIs in the Developer Portal. The procedure provided here is for deploying a new DeveloperUser CR. After you deploy a DeveloperUser CR, the procedure for updating or deleting it is the same as for any other CR.
You can deploy CRs only in the namespace that contains the 3scale operator.
Prerequisites
- An understanding of how the 3scale operator identifies the tenant that a custom resource links to.
There is at least one deployed
DeveloperAccountCR that contains at least one deployedDeveloperUserCR for a user who has theadminrole. If you are creating aDeveloperUserCR that does not link to the default tenant in the 3scale instance that is in the same namespace, then the namespace that will contain theDeveloperUserCR contains a secret that identifies the tenant that theDeveloperUserCR links to. The name of the secret is one of the following:-
threescale-provider-account - User defined
This secret contains the URL for a 3scale instance and a token that contains credentials for access to one tenant in that 3scale instance.
-
-
For a new
DeveloperUserCR, you have that developer’s username, password, and email address.
Procedure
In the namespace that contains the 3scale operator, create and save a resource file that defines a secret that contains the username and password for a developer user. For example, the
myusername02.yamlfile might contain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the secret. For example:
oc create -f myusername02.yaml
$ oc create -f myusername02.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
secret/myusername02 created
$ secret/myusername02 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create and save a
.yamlfile that defines aDeveloperUserCR. In thespec.rolefield, specifyadminormember. For example, thedeveloperuser02.yamlfile might contain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In a
DeveloperUserCR:-
The developer username (specified in the
metadata.namefield), the username, and email must be unique in the tenant that the containingDeveloperAccountlinks to. -
The
developerAccountReffield must specify the name of a deployedDeveloperAccountCR. -
The tenant that a
DeveloperUserCR links to must be the same tenant that the specifiedDeveloperAccountCR links to.
-
The developer username (specified in the
Create the resource you just defined. For example:
oc create -f developefuser02.yaml
$ oc create -f developefuser02.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the given example, the output would be:
developeruser.capabilities.3scale.net/developeruser02 created
$ developeruser.capabilities.3scale.net/developeruser02 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
It takes a few seconds for the 3scale operator to update the 3scale configuration to reflect new or updated custom resources. To check whether the operator is propagating custom resource information successfully, check the DeveloperUser CR status field or run the oc wait command, for example:
oc wait --for=condition=Ready --timeout=30s developeruser/developeruser02
$ oc wait --for=condition=Ready --timeout=30s developeruser/developeruser02
In case of failure, the custom resource’s status field indicates if the error is transient or permanent, and provides an error message that helps fix the problem.
Notify any new developer users that they can log in to the Developer Portal. You might also need to communicate their log-in credentials.
You can update a deployed DeveloperUser CR in the same way that you update any other custom resource.
7.13.4. Deleting DeveloperAccount or DeveloperUser custom resources Copia collegamentoCollegamento copiato negli appunti!
You can delete a 3scale developer entity by deleting the custom resource (CR) that manages it. When you delete a DeveloperAccount CR the 3scale operator also deletes any DeveloperUser CRs that link to the deleted DeveloperAccount CR.
The only way to delete a developer account or developer user defined by a custom resource is to follow the procedure described here. Do not use the Admin Portal nor the 3scale API to delete a developer entity that was deployed as a custom resource.
Prerequisites
3scale administrator permissions or an OpenShift role that has delete permissions in the namespace that contains the custom resource you want to delete. To confirm that you can delete a particular custom resource, run the
oc auth can-i deletecommand. For example, if the name in theDeveloperAccountCR isdevaccount1, run this command:oc auth can-i delete developeraccount.capabilities.3scale.net/devaccount1 -n my-namespace
$ oc auth can-i delete developeraccount.capabilities.3scale.net/devaccount1 -n my-namespaceCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
The
DeveloperAccountorDeveloperUserCR to be deleted links to a valid tenant.
Procedure
In the OpenShift project that contains the tenant that the custom resource links to, run the
oc deletecommand to delete aDeveloperAccountorDeveloperUserCR. For example, if you deployed aDeveloperAccountCR that was defined in thedevaccount1.yamlfile, you would run the following command:oc delete -f devaccount1.yaml
$ oc delete -f devaccount1.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, you can run the
oc deletecommand and specify the name of the CR as specified in its definition. For example:oc delete developeraccount.capabilities.3scale.net/devaccount1
$ oc delete developeraccount.capabilities.3scale.net/devaccount1Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.14. Limitations of 3scale API Management operator capabilities Copia collegamentoCollegamento copiato negli appunti!
In Red Hat 3scale API Management 2.14, 3scale operator contains these limitations with capabilities:
- Single Sign-On (SSO) authentication for the Admin Portal.
- SSO authentication for the Developer Portal.
- 3scale operator CRD holding OAS3 does not reference as source of truth for 3scale product configuration.
7.15. Additional resources Copia collegamentoCollegamento copiato negli appunti!
For more information, check the following guides: