Quick Start Guide¶
This section is a step-by-step guide to creating, deploying, and invoking an API using the WSO2 Kubernetes Gateway 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 Kubernetes Gateway¶
There are 3 components which you need to setup to get the Kubernetes Gateway working with APIM. They are,
Setup WSO2 API Manager Control Plane 4.5.0¶
Setup WSO2 API Manager 4.5.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.console helm repo add wso2apim https://github.com/wso2/helm-apim/releases/download/acp-4.5.0 -
Execute the following command to update the helm repositories.
console helm repo update -
Consider
apimas the<chart-name>for this guide. As the--versionof 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-acp --version 4.5.0-1 -f https://raw.githubusercontent.com/wso2/apk/main/helm-charts/samples/apim/cp/4.5.0-values.yaml -n apkhelm install <chart-name> <repository-name>/wso2am-acp --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 Advanced Configuration for APIM for more information.
Setup WSO2 Kubernetes Gateway 1.3.0¶
-
Create a new helm repository with the latest Kubernetes Gateway release using the following command. Let’s consider the
<repository-name>aswso2apk.console helm repo add wso2apk https://github.com/wso2/apk/releases/download/1.3.0-1 -
Execute the following command to update the helm repositories.
console helm repo update -
Install the Kubernetes Gateway components and start WSO2 Kubernetes Gateway. Consider
apkas the<chart-name>for this guide. As the--versionof 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.3.0-1 -f https://raw.githubusercontent.com/wso2/apk/refs/tags/1.3.0-1/helm-charts/samples/apk/1.3.0-1-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 Advanced Configuration for Kubernetes Gateway for more information.
Setup WSO2 Kubernetes Gateway Agent 1.3.0¶
-
Create a new helm repository with the latest kubernetes gateway agent release using the following command. Let’s consider the
<repository-name>aswso2apkagentfor this guide.console helm repo add wso2apkagent https://github.com/wso2/product-apim-tooling/releases/download/1.3.0 -
Execute the following command to update the helm repositories.
console helm repo update -
Install the Kubernetes Gateway Agent components and start WSO2 Kubernetes Gateway. Consider
apkas the<chart-name>for this guide. As the--versionof 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.3.0 -f https://raw.githubusercontent.com/wso2/apk/main/helm-charts/samples/apim-apk-agent/1.3.0-values.yaml -n apkhelm install <chart-name> <repository-name>/apim-apk-agent --version <version-of-APK-Agent> -f <path-to-values.yaml-file>
Note
Please refer to the Advanced 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 APIbutton and then useImport Open APIoption. - Provide the OpenAPI definition of the API and click
Next. Select OpenAPI URL and provide the below link as theURL. ClickNext.http https://raw.githubusercontent.com/wso2/docs-apk/refs/heads/1.3.0/en/docs/assets/files/get-started/SampleAPIDefinition.json - Edit the information as given below and click Create.
| Field | Sample value |
|---|---|
| Name | SampleService |
| Context | /sample-api |
| Version | 0.1.0 |
| Endpoint | https://dev-tools.wso2.com/gs/helpers/v1.0 |
- Navigate to the Deploy section and click Deployments.
- Click Deploy New Revision.
- Optionally, provide a description for the revision.
- Select the Kubernetes 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 Kubernetes Gateway, execute the following command. You will see the status of the deployed apis as follows once completed.
bash
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
Applicationstab and then useADD NEW APPLICATIONoption. -
Provide the information as given below and click
Save.Field Value Application Name SampleServiceApp Per Token Quota 10PerMin Description Sample Service Application -
Click Subscriptions to subscribe to the created SampleService 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 kubernetes gateway, execute the following command. You will see the status of the deployed application as follows once completed.
bash 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, un-deployment, 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.
bash
curl -X GET "https://default.gw.wso2.com:9095/sample-api/0.1.0/uuid" -H "Authorization: Bearer <access-token>" -k