이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Administering Red Hat OpenShift API Management
Administering Red Hat OpenShift API Management.
Abstract
Making open source more inclusive 링크 복사링크가 클립보드에 복사되었습니다!
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Chapter 1. Administering OpenShift API Management 링크 복사링크가 클립보드에 복사되었습니다!
You can perform configuration and monitoring tasks for managed services. With OpenShift API Management you can manage network configurations, define policies, monitor API usage, and update notification settings.
1.1. Overview of rate limiting, alerting, and monitoring in OpenShift API Management 링크 복사링크가 클립보드에 복사되었습니다!
Red Hat OpenShift API Management provides a limited number of API calls. The API request hard limits are set as part of your Red Hat OpenShift API Management purchase.
You are alerted to ensure you do not exceed the set API usage hard limit. OpenShift API Management uses a tiered approach for alerting customers when the API usage is close to the hard limit, to ensure request calls are not rejected and service is not interrupted.
An email notification is sent to the email address provided during the OpenShift API Management installation. The email notification includes a link to the Grafana dashboard, which provides a visualization of your API usage.
You can also access the Grafana dashboard through the OpenShift Dedicated console. To access the dashboard, click the application launcher in OpenShift Dedicated and then click API Management Dashboards in the OpenShift Managed Services drop-down menu.
A notification is sent in the following instances:
- If API usage is between 80% and 90% for a period of 4 hours, a notification is sent every 4 hours.
- If API usage is between 90% and 95% for a period of 2 hours, a notification is sent every 2 hours.
- If API usage is over 95% for a period of 30 minutes, a notification is sent every 30 minutes.
OpenShift API Management offers you the flexibility to share rate limiting quotas across multiple environments. You can divide a purchased OpenShift API Management subscription level across multiple OpenShift Dedicated environments. For example, if a 10 million API calls per day subscription level is selected, you can allocate 5 million API calls per day to both a stage environment and a production environment. For more information on increasing your Red Hat OpenShift API Management subscription level, refer to the service definition.
1.2. Monitoring service capacity with Grafana 링크 복사링크가 클립보드에 복사되었습니다!
You can monitor the service capacity and API usage of OpenShift API Management with Grafana. Access the Grafana dashboard from the OpenShift Dedicated console, to monitor the OpenShift API Management API rate limits for the following durations:
- last minute
- last 24 hours
In the dashboard, you can view, share, and inspect the data for the OpenShift API Management API requests.
Prerequisites
- Red Hat OpenShift API Management was added to your OpenShift Dedicated cluster.
Procedure
- Click the application launcher in OpenShift Dedicated.
- Click API Management Dashboards in the OpenShift Managed Services drop-down menu.
- You are prompted to log in. Click Log in with OpenShift.
- Enter login credentials, if prompted.
- Click Allow selected permissions to authorize monitoring access.
- In the Grafana console, click the Dashboards dropdown menu from the main menu to access the available dashboards and folders.
- Click Manage.
- Click redhat-rhoam-customer-monitoring-operator to open the folder.
Click Rate Limiting to access the monitoring data.
NoteAlternatively, click Home to search for a dashboard by name.
Chapter 2. Network policies 링크 복사링크가 클립보드에 복사되었습니다!
A cluster hosts two types of projects:
- Projects associated with managed services. These projects support inbound and outbound connections.
- User projects. These projects support communication from managed services.
In OpenShift Dedicated, there are two approaches to enabling communications:
- Using network policies
-
Using the
join-projectoption of theoccommand
In OpenShift API Management, you can use network policies to enable communication and allow 3scale to communicate directly with the service endpoint, instead of the external URL.
You cannot use the join-projects option of the oc command with managed services projects.
2.1. Enabling communication between managed services and customer applications 링크 복사링크가 클립보드에 복사되었습니다!
You can create NetworkPolicy objects to define granular rules describing the Ingress network traffic that is allowed for projects in your cluster. By default, when you create projects in a cluster, communication between the projects is disabled.
This procedure describes how to enable communication for a project so that managed services, such as 3scale, can access customer applications.
Prerequisites
-
You have installed the OpenShift command-line interface (CLI), commonly known as
oc.
Procedure
-
Log in to the cluster using the
oclogin command. Use the following command to change the project:
oc project <project_name>
$ oc project <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where
<project_name>is the name of a project that you want to accept communications from other projects.Create a
NetworkPolicyobject:-
Create a
allow-from-middleware-namespaces.yamlfile. Define a policy in the file you just created, such as in the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to create the policy object:
oc create -f allow-from-middleware-namespaces.yaml -n <project> networkpolicy "allow-from-middleware-namespaces" created
$ oc create -f allow-from-middleware-namespaces.yaml -n <project> networkpolicy "allow-from-middleware-namespaces" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Create a
2.2. Enabling communication between managed services and projects 링크 복사링크가 클립보드에 복사되었습니다!
By default, when you create projects in a cluster, communication between the projects is disabled. Use this procedure to enable communication in a project.
Prerequisites
-
You have installed the OpenShift command-line interface (CLI), commonly known as
oc.
Procedure
-
Log in to the cluster using the
oclogin command. Use the following command to change the project:
oc project <project_name>
$ oc project <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where
<project_name>is the name of a project that you want to accept communications from other projects.Create a NetworkPolicy object:
-
Create a
NetworkPolicy.yamlfile. Define a policy in the file you just created, such as in the following example.
This policy enables incoming communication for all projects in the cluster:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis policy configuration enables this project to communicate with all projects in the cluster.
Run the following command to create the policy object:
oc create -f <policy-name>.yaml -n <project>
$ oc create -f <policy-name>.yaml -n <project>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Create a
2.3. Enabling communication between customer applications 링크 복사링크가 클립보드에 복사되었습니다!
You can enable communication between user applications.
Prerequisites
-
You have installed the OpenShift command-line interface (CLI), commonly known as
oc.
Procedure
-
Log in to the cluster using the
oclogin command. Use the following command to change the project:
oc project <project_name>
$ oc project <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow <project_name>is the name of a project that you want to accept communications from.Create a NetworkPolicy object:
-
Create a
allow-from-myproject-namespace.yamlfile. Define a policy in the file you just created, such as in the following example.
This policy enables incoming communication for a specific project (
myproject):Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Create a
Run the following commands to create the policy object:
oc create -f allow-from-myproject-namespace.yaml -n <project> networkpolicy "allow-from-myproject-namespace" created
$ oc create -f allow-from-myproject-namespace.yaml -n <project> networkpolicy "allow-from-myproject-namespace" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.4. Disabling communication from a managed service to a project 링크 복사링크가 클립보드에 복사되었습니다!
By default, projects are created with a template that allows communication from a managed service. For example, 3scale can communicate with all of your projects.
You can disable the communication from a managed service to a project.
Prerequisites
-
You have installed the OpenShift command-line interface (CLI), commonly known as
oc - You have a project you want to isolate from the managed services.
Procedure
-
Log in to the cluster using the
oclogin command. Use the following command to change the project:
oc project <project_name>
$ oc project <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where
<project_name>is the name of a project that you want to isolate from the managed services.Create a NetworkPolicy object:
-
Create a
deny-all.yamlfile. Define a policy in the file you just created, such as in the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to create the policy object:
oc create -f <policy-name>.yaml -n <project>
$ oc create -f <policy-name>.yaml -n <project>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Create a
Chapter 3. Defining methods and metrics 링크 복사링크가 클립보드에 복사되었습니다!
An application plan sets limits and pricing rules for consumer access to your API. To enable enforcement of limits and rules, designate methods in your API for which to collect individual usage data or add metrics. Add a mapping rule to each designated method and each custom metric. The mapping rule specifies details about the usage data that you want to capture.
For more information about methods and metrics, see Designating methods and adding metrics for capturing usage details.
3.1. Adding methods to products and backends 링크 복사링크가 클립보드에 복사되었습니다!
Adding a method to a product or backend means that you are designating a method in your API for which you want to capture individual usage details. An application plan provides the ability to set a limit for each method that you add to a product or backend. The procedure for adding a method or metric to a product is similar to adding a method or metric to a backend.
Procedure
- Navigate to [Your_product_name] > Integration > Methods & Metrics or [Your_backend_name] > Methods & Metrics.
- Click New method.
In the Friendly name field, enter a short description of the method. This name is displayed in different sections of the 3scale Admin Portal. The friendly name must be unique for the product.
ImportantBe careful with changing the system name of the methods or deleting them. These changes can break your already deployed 3scale integration if there are mapping rules pointing to the previous system name of the method.
In the System name field, enter the name of the method in your API to use to report the usage through the 3scale Service Management API. The system name must conform to these rules:
- Unique in the product or backend
-
Contain only alphanumeric characters, underscore
_, hyphen-or forward slash/ - No spaces
Otherwise, you are free to decide what the system name looks like. It can be the same as the endpoint (
/status), or, for example, it can include the method and the path (GET_/status).- Optional: In the Description field, enter a more detailed description of the method.
- Click Create Method.
Verification steps
- Added methods are available in your application plans.
3.2. Adding metrics to products and backends 링크 복사링크가 클립보드에 복사되었습니다!
Adding a metric specifies a usage unit that you want to capture for all calls to your API. An application plan provides the ability to set a limit for each metric that you add to a product or backend. The procedure for adding a method or metric to a product is similar to adding a method or metric to a backend.
Procedure
- Navigate to [Your_product_name] > Integration > Methods & Metrics or [Your_backend_name] > Methods & Metrics.
- Click New metric.
In the Friendly name field, enter a short description of the metric. This name is displayed in different sections of the 3scale Admin Portal. The friendly name must be unique for the product.
ImportantBe careful with changing the system name of the metrics or deleting them. These changes can break your already deployed 3scale integration if there are mapping rules pointing to the previous system name of the metric.
In the System name field, enter the name of the metric in your API to use to report the usage through the 3scale Service Management API. The system name must conform to these rules:
- Unique in the product or backend
-
Contain only alphanumeric characters, underscore
_, hyphen-or forward slash/ - No spaces
Otherwise, you are free to decide what the system name looks like.
In the Unit field, enter the unit.
- Use a singular noun, for example, hit. The singular will become plural in the analytics charts.
- Optional: In the Description field, enter a more detailed description of the metric.
- Click Create Metric.
Verification steps
- Added metrics are available in your application plans.
3.3. Alternatives for importing methods and metrics 링크 복사링크가 클립보드에 복사되었습니다!
If your API has multiple endpoints, there are two ways to automatically designate methods and add metrics to 3scale products and backends:
3.4. Adding mapping rules to methods and metrics 링크 복사링크가 클립보드에 복사되었습니다!
Mapping rules are operations that are mapped to previously created methods and metrics in your products and backends.
Mapping rules are required in your previously created methods, however, they are optional for metrics.
Procedure
- Navigate to [Your_product_name] > Integration > Mapping Rules.
- Click Add Mapping Rule.
-
The Verb field is pre-populated with the HTTP method,
GET, however you can select other options from the dropdown list. -
In the Pattern field, add a valid URL that starts with an forward slash
/. The URL can be from a wildcard you specified inside curly brackets{}. - In the Metric or Method to increment field, select from one of your previously created methods or metrics.
-
The Increment by field is pre-populated with
1, however, change this to suit your own needs. - Click the Create Mapping Rule button.
Verification steps
- To verify your mapping rules, navigate to [Your_product_name] > Integration > Methods & Metrics. Each method and metric should have a check mark in the Mapped column.