Quick Start Guide¶
This section is a step-by-step guide to creating, deploying, and invoking an API using the WSO2 APK with APIM Control Plane.
Create Kubernetes namespace¶
kubectl create ns apk
Configure the hosts file¶
Add a hostname mapping to the /etc/hosts
file as follows.
IP | Domain name |
---|---|
127.0.0.1 | api.am.wso2.com |
127.0.0.1 | am.wso2.com |
127.0.0.1 | idp.am.wso2.com |
127.0.0.1 | default.gw.wso2.com |
Step 1 - Setup APIM Control Plane with APK¶
There are 3 components which you need to setup to get the APK working with APIM. They are,
Setup WSO2 API Manager Control Plane 4.3.0¶
Setup WSO2 API Manager 4.3.0 in K8s cluster using Helm Charts.
-
Create a new helm repository with the latest apim release using the following command. Let’s consider the
<repository-name>
aswso2apim
.helm repo add wso2apim https://github.com/wso2/helm-apim/releases/download/cp-4.3.0
-
Execute the following command to update the helm repositories.
helm repo update
-
Consider
apim
as the<chart-name>
for this guide. As the--version
of this command, use the version of the release you used in point 1 above. It will take a few minutes for the deployment to complete.helm install apim wso2apim/wso2am-cp --version 4.3.0 -f https://raw.githubusercontent.com/wso2/apk/main/helm-charts/samples/apim/cp/values.yaml -n apk
helm install <chart-name> <repository-name>/wso2am-cp --version <version-of-APIM> -f <path-to-values.yaml-file>
-
Install NGINX Ingress Controller. Please refer to the NGINX Ingress Controller documentation for more information.
Note
Please refer to the Advance Configuration for APIM for more information.
Setup WSO2 APK Dataplane 1.1.0¶
-
Create a new helm repository with the latest apk release using the following command. Let’s consider the
<repository-name>
aswso2apk
.helm repo add wso2apk https://github.com/wso2/apk/releases/download/1.1.0
-
Execute the following command to update the helm repositories.
helm repo update
-
Install the APK components and start WSO2 API Platform For Kubernetes. Consider
apk
as the<chart-name>
for this guide. As the--version
of this command, use the version of the release you used in point 1 above. It will take a few minutes for the deployment to complete.
Note
If you already have an installation of the APK in your cluster, please remove the installation by following the steps specified in the Uninstall APK section.
helm install apk wso2apk/apk-helm --version 1.1.0 -f https://raw.githubusercontent.com/wso2/apk/main/helm-charts/samples/apk/cp-enabled-values.yaml -n apk
helm install <chart-name> <repository-name>/apk-helm --version <version-of-APK> -f <path-to-values.yaml-file>
Note
Please refer to the Advance Configuration for APK for more information.
Setup WSO2 APIM-APK Agent 1.1.0¶
-
Create a new helm repository with the latest apim apk agent release using the following command. Let’s consider the
<repository-name>
aswso2apkagent
for this guide.helm repo add wso2apkagent https://github.com/wso2/product-apim-tooling/releases/download/1.1.0
-
Execute the following command to update the helm repositories.
helm repo update
-
Install the APIM APK Agent components and start WSO2 API Platform For Kubernetes. Consider
apk
as the<chart-name>
for this guide. As the--version
of this command, use the version of the release you used in point 1 above. It will take a few minutes for the deployment to complete.helm install apim-apk-agent wso2apkagent/apim-apk-agent --version 1.1.0 -f https://raw.githubusercontent.com/wso2/apk/main/helm-charts/samples/apim-apk-agent/values.yaml -n apk
helm install <chart-name> <repository-name>/apim-apk-agent --version <version-of-APK-Agent> -f <path-to-values.yaml-file>
Note
Please refer to the Advance Configuration for agent for more information.
Verify the deployment¶
Now you can verify the deployment by executing the following command. You will see the status of the pods as follows once completed.
kubectl get pods -n apk
Step 2 - Create and Deploy the API¶
Create Deploy and Publish the API¶
- Login to the Publisher Console (https://am.wso2.com/publisher) of the WSO2 API Manager.
- Click on the
REST API
button and then useImport Open API
option. - Provide the OpenAPI definition of the API and click
Next
. Select OpenAPI URL and providehttps://petstore3.swagger.io/api/v3/openapi.json
as the URL. Click Next. - Edit the information as given below and click Create.
Field | Sample value |
---|---|
Name | SwaggerPetstore |
Context | /petstore |
Version | 1.0.0 |
Endpoint | https://petstore3.swagger.io/api/v3 |
- Navigate to the Deploy section and click Deployments.
- Click Deploy New Revision.
- Optionally, provide a description for the revision.
- Select the APK Gateways in which you want to deploy the API and click Deploy.
- Navigate to Life Cycle tab. Then click Publish to publish the API.
- To verify the API deployment in the APK Gateway, execute the following command. You will see the status of the deployed apis as follows once completed.
kubectl get apis -n apk
Create Application and Subscribe to the API¶
- Login to the Developer Portal (https://am.wso2.com/devportal) of the WSO2 API Manager.
- Click on the
Applications
tab and then useADD NEW APPLICATION
option. -
Provide the information as given below and click
Save
.Field Value Application Name SwaggerPetstoreApp Per Token Quota 10PerMin Description Petstore Application -
Click Subscriptions to subscribe to the created SwaggerPetstore API.
- Click Production Keys or Sandbox Keys based on the environment for which you need to generate keys. Let's assume that you are working in a production environment. Therefore, click Production Keys.
- Click Generate Keys to create an application Access Token with relevant scopes.
-
To verify the Application and Subscription creation in the APK Gateway, execute the following command. You will see the status of the deployed application as follows once completed.
kubectl get subscriptions -n apk kubectl get applications -n apk
Important
The database storage option is offered in APK for deployments with a high number of subscriptions and applications, especially for enterprise use cases. Because, by default, subscription and application-related data are stored as CRs (Custom Resources) in etcd. However, as the number of subscriptions and applications increases, it can lead to overutilization of etcd memory, subsequently degrading the performance of your API gateway. This degradation can impact the deployment, undeployment, and update times ultimately affecting the reliability of applications and subscriptions.
By opting for the database option offered in APK for deployments with high numbers of subscriptions and applications, you can mitigate issues related to etcd storage, such as memory overutilization and performance degradation. This ensures smoother deployment, undeployment, and update processes, ultimately enhancing the reliability of your applications and subscriptions. For further information and assistance, please contact our sales team https://wso2.com/contact/?ref=consulting.
Step 3 - Invoke the API¶
Use the following command to invoke the API using the access token generated in the previous step.
curl -X GET "https://default.gw.wso2.com:9095/petstore/1.0.0/pet/findByStatus?status=available" -H "Authorization: Bearer <access-token>" -k