Skip to content

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.

  1. Create a new helm repository with the latest apim release using the following command. Let’s consider the <repository-name> as wso2apim.

    helm repo add wso2apim https://github.com/wso2/helm-apim/releases/download/cp-4.3.0
    
  2. Execute the following command to update the helm repositories.

    helm repo update
    
  3. 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>
    
  4. 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

  1. Create a new helm repository with the latest apk release using the following command. Let’s consider the <repository-name> as wso2apk.

    helm repo add wso2apk https://github.com/wso2/apk/releases/download/1.1.0
    
  2. Execute the following command to update the helm repositories.

    helm repo update
    
  3. 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

  1. Create a new helm repository with the latest apim apk agent release using the following command. Let’s consider the <repository-name> as wso2apkagent for this guide.

    helm repo add wso2apkagent https://github.com/wso2/product-apim-tooling/releases/download/1.1.0
    
  2. Execute the following command to update the helm repositories.

    helm repo update
    
  3. 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

  1. Login to the Publisher Console (https://am.wso2.com/publisher) of the WSO2 API Manager.
  2. Click on the REST API button and then use Import Open API option.
  3. Provide the OpenAPI definition of the API and click Next. Select OpenAPI URL and provide https://petstore3.swagger.io/api/v3/openapi.json as the URL. Click Next.
  4. 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
  1. Navigate to the Deploy section and click Deployments.
  2. Click Deploy New Revision.
  3. Optionally, provide a description for the revision.
  4. Select the APK Gateways in which you want to deploy the API and click Deploy.
  5. Navigate to Life Cycle tab. Then click Publish to publish the API.
  6. 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

  1. Login to the Developer Portal (https://am.wso2.com/devportal) of the WSO2 API Manager.
  2. Click on the Applications tab and then use ADD NEW APPLICATION option.
  3. Provide the information as given below and click Save.

    FieldValue
    Application NameSwaggerPetstoreApp
    Per Token Quota10PerMin
    DescriptionPetstore Application

  4. Click Subscriptions to subscribe to the created SwaggerPetstore API.

  5. 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.
  6. Click Generate Keys to create an application Access Token with relevant scopes.
  7. 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