<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chandima Abeysinghe on Medium]]></title>
        <description><![CDATA[Stories by Chandima Abeysinghe on Medium]]></description>
        <link>https://medium.com/@chandimacba?source=rss-e695e8e5e07c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nus4gOek6VnSTvCd8JCqTw.jpeg</url>
            <title>Stories by Chandima Abeysinghe on Medium</title>
            <link>https://medium.com/@chandimacba?source=rss-e695e8e5e07c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 17:17:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chandimacba/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Enforce Throttling Policies for Token Endpoint in WSO2 API Manager: A Guide to Client…]]></title>
            <link>https://medium.com/@chandimacba/how-to-enforce-throttling-policies-for-token-endpoints-in-wso2-api-manager-a-guide-to-client-013114b40e13?source=rss-e695e8e5e07c------2</link>
            <guid isPermaLink="false">https://medium.com/p/013114b40e13</guid>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[throttling]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[token]]></category>
            <category><![CDATA[custom-throttling]]></category>
            <dc:creator><![CDATA[Chandima Abeysinghe]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 10:00:41 GMT</pubDate>
            <atom:updated>2024-10-09T16:19:20.087Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Enforce Throttling Policies for Token Endpoint in WSO2 API Manager: A Guide to Client ID-Based Throttling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t4e-batWSKMcIq3fV4KjFw.png" /></figure><p>In some cases, you may need to throttle token requests for specific client IDs when you notice that certain clients are overusing the token endpoint, affecting the performance of others. In such cases, Enforcing a throttling policy for the token endpoint in API Manager is essential for effectively managing the usage of Token API calls. This post will explore how to implement throttling policies for token requests using the client ID or other attributes present in the token request.</p><p>You may already be aware that starting from the WSO2 APIM 4.x.x release, the token API at [https://GW:8243/token], which was previously proxied through the Gateway server, is no longer accessible. Instead, you need to directly use the token endpoint provided by the control-plane (Key Manager) server via the servlet port [https://CP:9443/oauth2/token].</p><p>So, we cannot directly apply a throttling policy to the token endpoint provided by the control plane. However, if you’re using a Web Application Firewall (WAF), you can configure the necessary throttling policy for the token endpoint through the WAF. If your deployment doesn’t include a WAF, don’t worry — we’ll guide you on how to proxy the token endpoint through the Gateway server, similar to previous versions, allowing you to enforce a throttling policy on the token endpoint.</p><h3><strong>1. Creating and Deploying a Token API on the GW server.</strong></h3><p>First, we need to create a token API on the Gateway server that proxies the token endpoint provided by the control plane (Key Manager component).</p><p>Please note that if you have moved the token API [_TokenAPI.xml] from the older APIM product versions directly into APIM-4.x.x to maintain backward compatibility, it is advised not to use it. Doing so may lead to complications with this older token API, as APIM-4.x.x does not support file-based artifacts and it will impact the internal metadata retrieval process for this manually created API. Instead, you should use the following approach to create the token API on the Gateway server.</p><ul><li>Deploy a generic API with the following values through the PUBLISHER UI and set the endpoint as https://&lt;CP_HOSTNAME&gt;:9443/oauth2/token and with the API set as the default version.<br><br><strong>Name</strong>: TokenAPI<br><strong>Version</strong>: 1.0.0<br><strong>Context</strong>: /token<br><strong>Endpoint</strong>: https://&lt;CP_HOSTNAME&gt;:9443/oauth2/token</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*pUi1plP_HXTzR1gWx4ov3Q.png" /><figcaption>Create Token API</figcaption></figure><ul><li>Configure this API as the default API version. (This will allow you to invoke the token API without specifying version [https://GW:8243/token])<br>– Go to the Basic-Info section in the publisher portal under this API<br>– Mark the API as the default API version.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zIYN77Yc--sJJLl0hIRdCg.png" /><figcaption>Mark the API as the default API version</figcaption></figure><ul><li>Delete all the resources except the Post resource and remove the security from the Post resource by the following toggle</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DAxbFRBrygFGUD8nxOOOEw.png" /><figcaption>Resource configuration of the Token API</figcaption></figure><ul><li>Save and Deploy the API by creating a new API revision</li></ul><h3><strong>2. Enforce a throttling policy for this created token API</strong></h3><p>Since security for the token endpoint has been disabled and there are no applications interacting with it, we cannot implement <em>subscription policies</em> or <em>application throttling policies</em> for the token API. Instead, we can utilize either <em>advanced throttling policies</em> or <em>custom throttling policies</em>. However, the advanced throttling policy will only enable us to throttle requests based on either the request count or the bandwidth globally for all user requests and we do not have much control over the advanced throttling policy, so that, we can go with the <strong><em>custom throttling policy</em></strong> approach.</p><h4>- How Throttling Works in WSO2 API Manager</h4><p>Before implementing a custom throttling policy, it’s essential to understand how throttling operates internally in the API Manager (APIM) and the underlying concepts involved in the throttling process.</p><p><strong>Throttling Key (Key Template):</strong> A template that specifies how requests are grouped for throttling, it will be populated from specific attributes of an API request, such as the apiName, resourceKey, or userID. All the throttling decisions made by the throttling engine will be stored in the GW in memory against this throttling key. You can refer to the diagram <a href="https://apim.docs.wso2.com/en/4.2.0/design/rate-limiting/introducing-throttling-use-cases/#implications-on-applications-that-consume-apis">[1]</a> to see the various throttling keys used for different throttling policies.</p><p>Example:<br> Throttling Key: {appID}:{apiContext}/{apiVersion}<br> Sample Generated Key from the Template: 2:/pizzashack/1.0.0</p><p>This key is utilized for subscription throttling, allowing requests to be uniquely grouped and identified based on the relevant `appID`, API context, and its version.</p><p><strong>Throttling Request Data:</strong> The request information is sent by the Gateway (GW) server to the throttling engine in the Traffic Manager server. This data is transmitted through a binary stream and published asynchronously by the GW. The following is an example of a data set by the GW when it receives an API call.</p><pre>appKey:2:admin@carbon.super,<br>appTier:Unlimited,<br>apiKey:/pizzashack/1.0.0:1.0.0,<br>apiTier:,<br>subscriptionKey:2:/pizzashack/1.0.0:1.0.0:sample,<br>subscriptionTier:sample,<br>resourceKey:/pizzashack/1.0.0/1.0.0/menu:GET,<br>resourceTier:Unlimited,<br>userId:admin@carbon.super,<br>apiContext:/pizzashack/1.0.0,<br>apiVersion:1.0.0,<br>appTenant:carbon.super,<br>apiTenant:carbon.super,<br>appId:2,<br>apiName:PizzaShackAPI,<br>properties:{&quot;ipv6&quot;:0,&quot;ip&quot;:2130706433}</pre><p><strong>Throttling Decision Event: </strong>After the throttling engine makes a decision based on the throttling request data, the outcome is published to all gateway servers as a JMS event. This event includes the throttling key, whether the key has been throttled, and the expiry time of the decision. This decision will be maintained in the GW in memory against the throttling key until it expires.</p><pre>{<br>   &quot;event&quot;:{<br>      &quot;payloadData&quot;:{<br>         &quot;throttleKey&quot;:&quot;2:/pizzashack/1.0.0:1.0.0:sample&quot;,<br>         &quot;isThrottled&quot;:true,<br>         &quot;expiryTimeStamp&quot;:1728404220000<br>      }<br>   }<br>}</pre><p>At a high level, when an API request is received by the Gateway (GW) server, the throttling handler — responsible for managing all throttling events — generates multiple<strong> throttling keys</strong> related to the API request. It then checks whether any of these keys are present in the throttling decision map. If any of the keys are throttled, a throttled response is sent to the client. Otherwise, the <strong>throttling request data</strong> is asynchronously published by the GW server to the TM. Once the throttling engine makes a decision, it sends a Throttling Decision Event to all the Gateway (GW) servers. This event contains the throttling key, whether the key is throttled, and the expiry time of the decision. The GW servers then update their throttling decision maps with this information.</p><p>Now that you understand how throttling works in API Manager (APIM), we can proceed with building a custom throttling policy for the token endpoint. In this approach, we aim to throttle token requests based on specific information from the token request, such as the client ID. However, the current throttling request data being sent does not include this information; it only contains the following data.</p><pre>appKey:127.0.0.1:anonymous@carbon.super,<br>appTier:,<br>apiKey:/token/1.0.0:1.0.0,<br>apiTier:,<br>subscriptionKey:127.0.0.1:/token/1.0.0:1.0.0:Unauthenticated,<br>subscriptionTier:Unauthenticated,<br>resourceKey:/token/1.0.0/1.0.0/*:POST,<br>resourceTier:Unlimited,<br>userId:anonymous@carbon.super,<br>apiContext:/token/1.0.0,<br>apiVersion:1.0.0,<br>appTenant:,<br>apiTenant:carbon.super,<br>appId:127.0.0.1,<br>apiName:tokenAPI,<br>properties:{&quot;ipv6&quot;:0,&quot;ip&quot;:2130706433}</pre><p>Since we cannot write a custom throttling policy based on the token request information with the current throttling request data, we must first include the relevant token request details in the throttling data. Once we have added the token request information to the existing throttling request data, we can proceed with implementing the custom throttling policy.</p><h4><strong>2.1 Appending the token request info to the throttling request data</strong></h4><p>We can create a custom filter for the throttling handler, which allows us to process requests before they are handled by the throttling handler. This customer filter provides the flexibility to inject custom properties into the throttling request data. To achieve this, we can implement the custom filter using the <a href="https://github.com/wso2/carbon-apimgt/blob/47e3c46f7a2ed09de681b33817dd817befcf552c/components/apimgt/org.wso2.carbon.apimgt.common.gateway/src/main/java/org/wso2/carbon/apimgt/common/gateway/extensionlistener/ExtensionListener.java#L39"><strong>ExtensionListener</strong></a><strong>[2]</strong> interface.</p><p>To include custom properties in the throttling request data, you can create an ExtensionResponseDTO object. Use the setCustomProperty function to add your custom properties, passing in a property map. Additionally, ensure that the response status is set to “continue.”</p><p>Below is an example of how we retrieved the client ID from the authorization header in the token request and included it as a custom property. Please refer to the complete <a href="https://github.com/cbabey/samples-apim/tree/main/ThrottlingExtensionForTokenEndpoint">project</a>.</p><p><a href="https://github.com/cbabey/samples-apim/tree/main/ThrottlingExtensionForTokenEndpoint">samples-apim/ThrottlingExtensionForTokenEndpoint at main · cbabey/samples-apim</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/899085cfe08c911f6a886e53ba1fc68a/href">https://medium.com/media/899085cfe08c911f6a886e53ba1fc68a/href</a></iframe><p>You need to build the above maven project and add the jar into the &lt;APIM_HOME&gt;/repository/component/dropins directory in the GW servers.</p><p>To integrate the custom filter with the Gateway, include the following configuration in the deployment.toml file, directing it to your custom implementation.</p><pre>[[apim.extension.listener]]<br>type = &quot;THROTTLING&quot;<br>class = &quot;org.wso2.carbon.test.TokenThrottlingExtensionImpl&quot;</pre><p>Once we add the above custom filter, it will add the clientID as the custom property in the throttle request data.</p><pre>appKey:127.0.0.1:anonymous@carbon.super,<br>appTier:,<br>apiKey:/token/1.0.0:1.0.0,<br>apiTier:,<br>subscriptionKey:127.0.0.1:/token/1.0.0:1.0.0:Unauthenticated,<br>subscriptionTier:Unauthenticated,<br>resourceKey:/token/1.0.0/1.0.0/*:POST,<br>resourceTier:Unlimited,<br>userId:anonymous@carbon.super,<br>apiContext:/token/1.0.0,<br>apiVersion:1.0.0,<br>appTenant:,<br>apiTenant:carbon.super,<br>appId:127.0.0.1,<br>apiName:tokenAPI,<br>properties:{&quot;clientID&quot;:&quot;uARHqx1HfY6XGqKjfIY6_HTNIHIa&quot;,&quot;ipv6&quot;:0,&quot;ip&quot;:2130706433}</pre><p>With this custom property in place, we can now begin developing the custom throttling policy that utilizes the client ID.</p><h4><strong>2.2 Implementing the custom throttling policy based on the client ID.</strong></h4><p>Let’s implement a custom throttling policy that restricts a specific client ID to invoke the token endpoint a certain number of times within a defined time window. For example, with the following custom throttling policy, a particular client ID is allowed to make up to 20 requests per minute to the token endpoint.</p><p>Login to the admin portal and define the custom throttling policies with the following values.</p><p><strong>Name: </strong>ClientIDSpecificTokenThrottling<br><strong>thorttlingKey: </strong>$customProperty.clientID:$apiContext:$apiVersion<br><strong>Siddhi Query:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4d149f72c8ddeae7727cf950aa2c3e7/href">https://medium.com/media/b4d149f72c8ddeae7727cf950aa2c3e7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QFMuMobVPmUT7lCwHkXWKQ.png" /><figcaption>Adding the custom Thorttling Policy</figcaption></figure><p>This Siddhi query enforces throttling for the /token/1.0.0 API based on the client ID:</p><ol><li><strong>Step 1:</strong> From the RequestStream, it selects requests where apiContext == &#39;/token/1.0.0&#39; and apiVersion == &#39;1.0.0&#39;, marking them as isEligible. It generates a throttleKey by concatenating the clientID with the API context and version, then insert the results into EligibilityStream.</li><li><strong>Step 2:</strong> It processes events from EligibilityStream where isEligible == true, using a 1-minute time batch. It checks if the throttleKey appears 20 or more times within this period (indicating throttling) and inserts the result, including whether throttling occurred (isThrottled), into ResultStream.</li></ol><p>Once everything is set up, you can test by sending requests to the token endpoint using the same client. If you send more than 20 requests within a minute, the requests will be throttled and you will receive the following error message.</p><pre>{<br>    &quot;code&quot;: &quot;900806&quot;,<br>    &quot;message&quot;: &quot;Message throttled out&quot;,<br>    &quot;description&quot;: &quot;You have exceeded your quota .You can access API after 2024-Oct-09 08:36:53+0000 UTC&quot;,<br>    &quot;nextAccessTime&quot;: &quot;2024-Oct-09 08:36:53+0000 UTC&quot;<br>}</pre><p>With the above example, you can now create your own custom throttling policy based on the client ID. If you need additional attributes from the token request, such as the username or grant type (which are represented in the message body), you can retrieve the payload as a stream using `responseDTO.getPayload()`. This allows you to process the stream and extract the necessary attributes for your custom policy, which can then be added as custom properties in the throttling data request.</p><p>[1] <a href="https://apim.docs.wso2.com/en/4.2.0/design/rate-limiting/introducing-throttling-use-cases/#implications-on-applications-that-consume-apis">https://apim.docs.wso2.com/en/4.2.0/design/rate-limiting/introducing-throttling-use-cases/#implications-on-applications-that-consume-apis</a></p><p>[2] <a href="https://github.com/wso2/carbon-apimgt/blob/47e3c46f7a2ed09de681b33817dd817befcf552c/components/apimgt/org.wso2.carbon.apimgt.common.gateway/src/main/java/org/wso2/carbon/apimgt/common/gateway/extensionlistener/ExtensionListener.java#L39">https://github.com/wso2/carbon-apimgt/blob/47e3c46f7a2ed09de681b33817dd817befcf552c/components/apimgt/org.wso2.carbon.apimgt.common.gateway/src/main/java/org/wso2/carbon/apimgt/common/gateway/extensionlistener/ExtensionListener.java#L39</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=013114b40e13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enabling SSL Debug Logs for WSO2 Products Running on Containers (Docker/Kubernetes)]]></title>
            <link>https://medium.com/@chandimacba/enabling-ssl-debug-logs-for-wso2-products-running-on-containers-docker-kubernetes-63a3566e10cf?source=rss-e695e8e5e07c------2</link>
            <guid isPermaLink="false">https://medium.com/p/63a3566e10cf</guid>
            <dc:creator><![CDATA[Chandima Abeysinghe]]></dc:creator>
            <pubDate>Tue, 11 Jul 2023 16:48:44 GMT</pubDate>
            <atom:updated>2023-07-11T16:48:44.238Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4_lFAf66_Lw3kM-iM5m9nQ.png" /></figure><p>You might require to enable SSL debug logs in the WSO2 products in order to troubleshoot SSL/TLS-related issues. If your deployment is not a container-based deployment, you can easily enable SSL debug logs by using the following JVM parameters.</p><pre>./&lt;serverStartupScript&gt; -Djavax.net.debug=ssl:handshake</pre><p>If you are required to capture the complete debug logs other than the SSL handshake-related logs, you can use the following command.</p><pre>./&lt;serverStartupScript&gt; -Djavax.net.debug=ssl:all</pre><p>You can include this JVM parameter either alongside the startup script flags or add it to the startup script itself.</p><p>In the containerized deployment, you can define the above JVM parameter in the docker-entrypoint.sh. However, it will be required additional effort of rebuilding the docker image by updating the default docker-entrypoint.sh or will be required to have a config map to mount the updated docker-entrypoint.sh into the APIM pod if it is a Kuberetnes-based deployment.</p><p>To enable the SSL debug logs, we need to inject the -Djavax.net.debug JVM property.<strong> In the containerized deployment, You can simply Inject the JVM parameter to a Java application(WSO2 Products) by either using </strong><strong>Shell script arguments or using the </strong><strong>JAVA_OPTS environment variable.</strong></p><h3>Shell Script arguments</h3><p>The default docker-entrypoint.sh file is implemented to accept the shall script argument to start the server, it can be used to pass the JVM parameters during the server startup.</p><p>Here is an example of how the docker-entrypoint.sh file for the WSO2 APIM docker image might look:</p><pre># start WSO2 Carbon server<br>echo &quot;Start WSO2 Carbon server&quot; &gt;&amp;2<br>if [[ -z &quot;${PROFILE_NAME}&quot; ]]<br>then<br>  # start the server with the provided startup arguments<br>  sh ${WSO2_SERVER_HOME}/bin/api-manager.sh &quot;$@&quot;<br>else<br>  # start the server with the specified profile and provided startup arguments<br>  sh ${WSO2_SERVER_HOME}/bin/api-manager.sh -Dprofile=${PROFILE_NAME} &quot;$@&quot;<br>fi</pre><p>You can provide the JVM parameters as below:</p><pre>docker run -it -p 8280:8280 -p 8243:8243 -p 9443:9443  --name api-manager wso2/wso2am:4.1.0-multiarch &quot;-Djavax.net.debug=ssl:all&quot;</pre><p>In a Kubernetes-based deployment, you can provide the argument that needs to inject into the startup command by using the ‘args’ variable as shown below.</p><pre>spec:<br>      containers:<br>        - name: wso2am<br>          image: wso2/wso2am:4.0.0<br>          imagePullPolicy: Always<br>          args: [&quot;-Djavax.net.debug=ssl:all&quot;]</pre><h3>“JAVA_OPTS” environment variable.</h3><p>JAVA_OPTS is an environment variable that you can set to pass custom settings to the Java Virtual Machine (JVM) that runs Liquibase.</p><p>You can define JAVA_OPTS the environment as shown below in order to enable the SSL debug logs.</p><pre>docker run -it -p 8280:8280 -p 8243:8243 -p 9443:9443  --env JAVA_OPTS=&quot;-Djavax.net.debug=ssl&quot; --name api-manager wso2/wso2am:4.1.0-multiarch</pre><p>In a Kubernetes deployment, you can define the environment variable as below.</p><pre>env:<br>  - name: NODE_IP<br>    valueFrom:<br>      fieldRef:<br>        fieldPath: status.podIP<br>  - name: JVM_MEM_OPTS<br>    value: &#39;-Xms1024m -Xmx1024m&#39;<br>  - name: JAVA_OPTS<br>    value: &#39;-Djavax.net.debug=ssl:all&#39;</pre><p>In both scenarios, Debug logs can be found in the container logs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63a3566e10cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying WSO2 API Manager 4.0.0 on Kubernetes Local Cluster Running on Apple Mac with Silicon Chip]]></title>
            <link>https://medium.com/@chandimacba/deploying-wso2-api-manager-4-0-0-on-kubernetes-local-cluster-running-on-apple-mac-with-silicon-chip-809d5df20c46?source=rss-e695e8e5e07c------2</link>
            <guid isPermaLink="false">https://medium.com/p/809d5df20c46</guid>
            <category><![CDATA[apple-silicon]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[helm-chart]]></category>
            <category><![CDATA[m1-mac]]></category>
            <dc:creator><![CDATA[Chandima Abeysinghe]]></dc:creator>
            <pubDate>Tue, 11 Jul 2023 05:47:01 GMT</pubDate>
            <atom:updated>2023-07-15T16:06:54.501Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>You may require to gain hands-on experience deploying the WSO2 APIM server on a Local Kubernetes cluster before diving into your real Kubernetes playground.</p><p>However, if you are using a Mac M1, you may encounter a bunch of errors when attempting to deploy the APIM server using the <a href="https://github.com/wso2/kubernetes-apim/tree/4.0.x/simple/am-single">WSO2 Helm Charts</a>. If you’ve faced these issues before and already given up, fear not! 👍 this blog post will provide a comprehensive step-by-step approach to successfully deploying a single APIM server on a local Kubernetes cluster (<a href="https://rancherdesktop.io/">Rancher-Dekstop</a>) running on a Mac Silicon Chip machine.</p><h3>Prerequisites</h3><p>Before diving into the deployment process, ensure that you have the following prerequisites in place:</p><ol><li>Download and install the <a href="https://rancherdesktop.io/">Rancher Dekstop</a>, <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git</a>, and <a href="https://helm.sh/docs/intro/install/">Helm</a>.</li><li>Clone the <a href="https://github.com/wso2/kubernetes-apim/tree/master">WSO2 kubernetes-apim</a> git repository</li></ol><h3>Step 1: Set Up Kubernetes Cluster on Rancher Desktop</h3><ol><li>Launch Rancher Desktop, and Upon launching, the Rancher Desktop main window will be displayed.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/0*UmL3Mz2Q_Q-fp8BF" /></figure><p>2. To Enable the Kubernetes cluster, Open the Kubernetes configuration by clicking on the gear icon located at the top right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/0*02F8sU6rJNhpXh5z" /></figure><p><strong>Enable Kubernetes</strong>: ✅ (enable the Kubernetes cluster if it hasn’t been done already)</p><p><strong>Kubernetes Version: </strong>if you do not want to try out a specific Kubernetes version, you can proceed with the default selection of the stable Kubernetes version.</p><p><strong>Traefik: </strong>Disable the Traefik<strong> </strong>(Rancher Desktop uses K3s under the hood, which in turn uses Traefik as the default ingress controller for the Kubernetes cluster. By the way, the WSO2 APIM helm charts are fine tune with the Ingress-Nginx Controller)</p><p>3. Increase resources that are allocated to the rancher desktop.</p><p>Go to the Virtual Machine Configuration and increase the CPU up to 4 CPUs and memory to 8GB in order to run both the MySQL Pod and APIM smoothly.</p><p>By the way, you can configure a lower resource value for the Rancher Desktop by adjusting the resource value for the APIM Pod. You can follow step 4.1 to configure the APIM Pod resource values</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*gM63rd8Ci88w683lol3Upw.png" /></figure><p>Once you configure the Kubernetes cluster on the rancher desktop, it will restart the rancher desktop and takes a couple of minutes to install the Kubernetes cluster and Kubernetes management tools.</p><h3><strong>Step 2: Install the ingress controller</strong></h3><ol><li>Install the ingress controller by executing the below helm install command. (refer to the <a href="https://kubernetes.github.io/ingress-nginx/deploy/">ingress documentation</a> for more details on this)</li></ol><pre>helm upgrade --install ingress-nginx ingress-nginx \<br>  --repo https://kubernetes.github.io/ingress-nginx \<br>  --namespace ingress-nginx --create-namespace</pre><p>2. You can validate whether the ingress controller is properly configured and running in your cluster by following the steps mentioned in the <a href="https://kubernetes.github.io/ingress-nginx/deploy/#local-testing">documentation</a></p><h3><strong>Step 3: Checkout to the 4.0.x branch in the cloned kubernetes-apim repository.</strong></h3><pre>git checkout 4.0.x</pre><p>In this blog post, we are trying out the APIM single-node deployment. So, we need to use the helm charts in the kubernetes-apim/simple/am-single directory. I will refer the kubernetes-apim/simple/am-single directory as the HELM_HOME</p><h3><strong>Step 4: Modify Helm Charts for Apple </strong>Silicon Chip<strong> Compatibility</strong></h3><h4>Step 4.1: APIM Pod Configuration</h4><p>The official WSO2 Docker images built for the x86_64 architecture might not be compatible with the Mac Silicon Chip (ARM64) architecture and would require an ARM64-compatible version of the Docker image to run on the Mac Silicon Chip.</p><p>Therefore, the WSO2 release Docker images that are compatible with the ARM64 architecture and are labeled as wso2am:{version}-multiarch. However, starting from APIM-4.1.0, the WSO2 Docker images, including the multi-arch images, will no longer be publicly available on Docker Hub. As of now, only the wso2am:4.0.0-multiarch is available in the docker repository.</p><p>The multi-arch Docker images are also not published in the WSO2 private Docker repositories. fear not!😱, still you have the option to build your own Docker images compatible with ARM64 architecture by referring to the Dockerfile and following the guidance provided in the <a href="https://github.com/wso2/docker-apim/tree/master/dockerfiles/ubuntu/apim#how-to-build-a-docker-image-with-multi-architecture-support">WSO2 documentation</a>.</p><p><strong>So, let’s update the default helm chart</strong></p><ol><li>Open the values.yaml the file that resides in the HELM_HOME.</li><li>Update the docker image tag from 4.0.0 to 4.0.0-multiarch in wso2.am.imageTag.</li></ol><pre>    am:<br>      imageName: &quot;wso2am&quot;<br>      imageTag: &quot;4.0.0-multiarch&quot;</pre><p>3. Disable the NFS service provisioner dependency by updating the wso2.deployment.dependencies.nfsServerProvisioner value to false.</p><pre>  deployment:<br>    dependencies:<br>      mysql: true<br>      nfsServerProvisioner: false</pre><p>The nfsServerProvisioner tag is used in the APIM helm chart to enable dynamic provisioning of NFS volumes. It facilitates the retrieval of stable NFS Server Provisioner-related Helm resources from the Helm repository and deploys an NFS service provider pod within the cluster. By default, this NFS service provisioner pod serves and mounts all the persistent volume requirements for both APIM and Mysql Database.</p><p>However, creating a new pod within your local cluster can introduce additional overhead due to limited CPU and memory resources on your local machine. Instead, you have the option to utilize node storage in the Rancher Desktop cluster to fulfill the persistent volume requirements. This approach leverages the available storage resources on the cluster nodes, reducing the strain on your local machine.</p><p>4. Change the Kubernetes storage class by updating wso2.deployment.persistentRuntimeArtifacts.storage-class value from &amp;storage_class “nfs” to storage_class “local-path”</p><pre>    persistentRuntimeArtifacts:<br>      storageClass: &amp;storage_class &quot;local-path&quot;</pre><p>Kubernetes Storage Class is used to dynamically provision the relevant Persistent Volumes, By default, this APIM helm chart uses the nfs Kubernetes StorageClass created using the official, NFS Server Provisioner. Since the NFS server provision was not initialized in our local cluster, The storage class needs to be changed tolocal-path, which is a storage class offered by Rancher Desktop. This local-path storage class allows for the automatic provisioning of Persistent Volumes when pods require them.</p><p>5. Reduce the CPU/Memory resources that are allocated to the APIM pod</p><p>Define request/limit resources for the APIM pod are defined as below. wso2.deployment.am.resources</p><pre>      resources:<br>        requests:<br>          memory: &quot;1Gi&quot;<br>          cpu: &quot;1000m&quot;<br>        limits:<br>          memory: &quot;2Gi&quot;<br>          cpu: &quot;2000m&quot;</pre><p><strong>Resource requests</strong> define the minimum amount of CPU and memory that a pod requires to run.</p><p><strong>Resource limits</strong> define the maximum amount of CPU and memory that a pod can consume.</p><p>If you have already assigned sufficient CPU and memory resources to Rancher Desktop, there is no need to decrease the resources allocated to the APIM pod. You can maintain the default CPU and memory allocation as recommended by WSO2.</p><h4>Step 4.2: Mysql Node</h4><p>The default APIM helm chart is configured to use the MySQL database server. To set up the MySQL database, a <a href="https://artifacthub.io/packages/helm/wso2/mysql">MySQL Helm chart</a> is utilized as a subchart within the APIM Helm charts. If you enable the wso2.deployment.dependencies.mysql=true parameter in the values.yaml file.</p><p>If the MySQL image used in the MySQL Helm chart hasn’t been updated properly, the MySQL pod will fail to initialize and throw the following exception. This occurs because the container runtime is unable to pull the ARM64 Architecture supported docker image from the Mysql Docker repository, which is a known issue for users with Apple Silicon chip.</p><p>Failed to pull image “mysql:5.7.34”: rpc error: code = Unknown desc = no matching manifest for linux/arm64/v8 in the manifest list entries</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w4RSRCnG96SviCak" /></figure><p>By simply specifying the image platform as linux/amd64, you can fetch Docker images that are compatible with the linux/amd64 architecture, which also works with arm64 architecture. This allows for easy retrieval of linux/amd64 supported images that can run on both architectures even though there is no specific MySQL image for the arm64 architecture.</p><p>However, while it is possible to update the image platform in a docker-compose, defining the platform directly in Kubernetes is not as straightforward.</p><p>Do not worry 😉, we have a workaround to sort out this issue, you can simply follow the below steps:</p><ol><li>Pull the linux/amd64 MySQL docker image</li></ol><pre>docker pull mysql:5.7.34 — platform linux/amd64</pre><p>2. Re-tag the pulled docker image mysql:5.7.34 with your own tag name</p><pre>docker tag mysql:5.7.34 m1mysql:5.7.34</pre><p>This command creates a new tag m1mysql:5.7.34 for the existing mysql:5.7.34 image. Now you can refer to the image using either mysql:5.7.34 or m1mysql:5.7.34 as the image name.</p><p>In the MySQL helm chart, we can refer to this newly created tag and it will fetch from your local docker repository without filtering any architecture type.</p><p>3. Update the helm chart.</p><p>3.1 Open the values.yaml file that resides in the kubernetes-apim/simple/am-single/ directory.</p><p>3.2 Define the updated MySQL image name and tag name under the mysql-am.mysql tag</p><pre>mysql-am:<br>  mysql:<br>    image: &quot;m1mysql&quot;<br>    imageTag: &quot;5.7.34&quot;<br>    persistence:<br>      storageClass: *storage_class</pre><p>Here, We are updating the values.yaml defined variables in the MySQL helm chart (sub-chart) from the main APIM helm charts values.yaml.</p><h3>Step 4: Install Helm Chart</h3><p>Execute the below command to install helm charts.</p><pre>helm install &lt;RELEASE_NAME&gt; &lt;HELM_HOME&gt;/am-single — version 4.2.0–1 — namespace &lt;NAMESPACE&gt; — dependency-update — create-namespace</pre><p>Ex:</p><pre>helm install wso2am ./simple/am-single/ — version 4.0.0–1 — namespace apim — dependency-update — create-namespace</pre><h3>Step 5: DNS Mapping</h3><ol><li>Obtain the external IP (`EXTERNAL-IP`) of the API Manager Ingress resources, by listing down the Kubernetes Ingresses.</li></ol><pre>kubectl get ing -n &lt;nameSpace&gt;</pre><p>so, you will get an output similar to below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*X3eIqqNd2U6yqmMSVbVt6Q.png" /></figure><p>2. open /etc/hosts file using a text editor and Add a DNS record mapping the hostnames (in step 1) and the external IP.</p><pre>192.168.1.89 am.wso2.com gateway.am.wso2.com</pre><p>3. Navigate to the consoles in your browser of choice.</p><p>API Manager Publisher: <a href="https:// am.wso2.com/publisher">https:// am.wso2.com/publisher</a><br>API Manager DevPortal: <a href="https://am.wso2.com/devportal">https://am.wso2.com/devportal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=809d5df20c46" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>