<?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 Tselentis Panagis on Medium]]></title>
        <description><![CDATA[Stories by Tselentis Panagis on Medium]]></description>
        <link>https://medium.com/@tselentispanagis?source=rss-f6f8a1c74eaa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Vk0UDi8KzYwOJVQZ</url>
            <title>Stories by Tselentis Panagis on Medium</title>
            <link>https://medium.com/@tselentispanagis?source=rss-f6f8a1c74eaa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:58:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tselentispanagis/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[Managing microservices and APIs with Kong and Konga]]></title>
            <link>https://medium.com/@tselentispanagis/managing-microservices-and-apis-with-kong-and-konga-7d14568bb59d?source=rss-f6f8a1c74eaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d14568bb59d</guid>
            <category><![CDATA[kong]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[konga]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Tselentis Panagis]]></dc:creator>
            <pubDate>Fri, 20 Jul 2018 20:31:56 GMT</pubDate>
            <atom:updated>2018-07-27T10:04:37.485Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I65gIbFXhUHzplI4NHpj1w.png" /></figure><h4>TL;DR</h4><p>This article will be focusing on how to manage microservices using <strong>Kong </strong>and <strong>Konga</strong>. We will go through the deployment process of both applications and provide a basic example of accessing an API through the gateway as well as securing it’s resources using Authentication plugins and Access Control Lists.</p><h3>What is Kong?</h3><p><a href="https://konghq.com/">The API Platform Powering the API World</a></p><p>Kong is a widely adopted, open source API Gateway, written in Lua. It runs on top of Nginx, leveraging the OpenResty framework and provides a simple RESTful API that can be used to provision your infrastructure in a dynamic way.</p><h3>What about Konga?</h3><p><a href="https://github.com/pantsel/konga">GitHub - pantsel/konga: More than just another GUI to Kong Admin API</a></p><p>Konga is a fully featured open source, multi-user GUI, that makes the hard task of managing multiple Kong installations a breeze.</p><p>It can be integrated with some of the most popular databases out of the box and provides the visual tools you need to better understand and maintain your architecture.</p><h3>Installing Kong</h3><p>For this tutorial, we’re going to use docker containers. Other ways to install Kong can be found here: <a href="https://konghq.com/install/">https://konghq.com/install</a></p><ol><li>To begin with, we need to create a network so that the containers can discover and communicate with each other.</li></ol><pre>$ docker network create kong-net</pre><p>2. We will be using PostgreSQL as Kong’s database (it can be either that or Cassandra).</p><pre>$ docker run -d --name kong-database \ <br>                --network<strong>=</strong>kong-net \ <br>                -p 5432:5432 \ <br>                -e “POSTGRES_USER=kong” \ <br>                -e “POSTGRES_DB=kong” \ <br>                postgres:9.6</pre><p>3. Let us now prepare our database by starting an ephemeral Kong container which will run the appropriate migrations and die!</p><pre>$ docker run --rm \     <br>             --network<strong>=</strong>kong-net \     <br>             -e &quot;KONG_DATABASE=postgres&quot; \     <br>             -e &quot;KONG_PG_HOST=kong-database&quot; \     <br>             kong:latest kong migrations up</pre><p>4. Everything is now set and ready to start Kong!</p><pre>$ docker run -d --name kong \     <br>             --network<strong>=</strong>kong-net \     <br>             -e &quot;KONG_DATABASE=postgres&quot; \     <br>             -e &quot;KONG_PG_HOST=kong-database&quot; \         <br>             -e &quot;KONG_PROXY_ACCESS_LOG=/dev/stdout&quot; \     <br>             -e &quot;KONG_ADMIN_ACCESS_LOG=/dev/stdout&quot; \     <br>             -e &quot;KONG_PROXY_ERROR_LOG=/dev/stderr&quot; \     <br>             -e &quot;KONG_ADMIN_ERROR_LOG=/dev/stderr&quot; \     <br>             -e &quot;KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl&quot; \     <br>             -p 8000:8000 \     <br>             -p 8443:8443 \     <br>             -p 8001:8001 \     <br>             -p 8444:8444 \     <br>             kong:latest</pre><p>5. Test it out!</p><p><em>Kong’s admin API is exposed on port </em><em>8001 and the gateway on port </em><em>8000</em></p><pre>$ curl -i http://localhost:8001/</pre><pre>$ curl -i http://localhost:8000/</pre><h3>Installing Konga</h3><p>Konga ports with it’s own file system storage and although it’s not recommended for production, it can be safely used as long as <em>kongadata</em> folder persists in a volume.</p><p>If you decide to go down that road, running Konga is as simple as this:</p><pre>$ docker run -d -p 1337:1337 \<br>             --network<strong>=</strong>kong-net \<br>             --name konga \<br>             -v /var/data/kongadata:/app/kongadata \<br>             -e &quot;NODE_ENV=production&quot; \<br>             pantsel/konga</pre><p>For this tutorial, since we already have a running PostgreSQL instance, we might as well make our lifes a bit more complicated and use it.</p><p>Like before, we will need to prepare Konga’s database by starting an ephemeral container.</p><pre>$ docker run --rm \ <br>    --network=kong-net \ <br>    pantsel/konga -c prepare -a postgres -u postgresql://kong@kong-database:5432/konga_db</pre><p>When the migrations run, we can start the app.</p><pre>$ docker run -p 1337:1337 \<br>             --network<strong>=</strong>kong-net \<br>             -e &quot;DB_ADAPTER=postgres&quot; \<br>             -e &quot;DB_HOST=kong-database&quot; \<br>             -e &quot;DB_USER=kong&quot; \<br>             -e &quot;DB_DATABASE=konga_db&quot; \<br>             -e &quot;KONGA_HOOK_TIMEOUT=120000&quot; \<br>             -e &quot;NODE_ENV=production&quot; \<br>             --name konga \<br>             pantsel/konga</pre><blockquote>Here’s a <em>docker-compose </em>example<em> for the lazy: </em><a href="https://gist.github.com/pantsel/73d949774bd8e917bfd3d9745d71febf">https://gist.github.com/pantsel/73d949774bd8e917bfd3d9745d71febf</a></blockquote><p>After a while, Konga will be available at:</p><pre>http://&lt;your-servers-public-ip-or-host&gt;:1337</pre><p>Login with the default credentials:</p><p><strong><em>Login</em></strong><em>: admin | </em><strong><em>Password</em></strong><em>: adminadminadmin</em></p><p>After successful login, you will land here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YwJbTeYPpxufuQGpn-_pkw.png" /></figure><p>At this point, you can manually create a connection to Kong’s admin API but, since we deployed everything using the “default” way, Konga has already created that initial connection for us.</p><p>If you open the connections page, you’ll notice that a connection to the previously created Kong instace is already there but not yet active.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vA90CCht_JBBcVL7ffJ_tA.png" /></figure><p>Hit the activate button. If everything is set up properly, Konga will connect to Kong and the interface will be filled with all kinds of coolness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HWgfU0B7DIoup1876aiJhg.png" /></figure><blockquote><strong>Important note</strong>: Don’t forget to change the default admin and user accounts provided by Konga. This can be easily done in the users page.</blockquote><h3>Quick tour</h3><p>Let’s take a quick tour and explain some of the core concepts in a nutshell.</p><h4>Dashboard</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gi9Ud-5Jcb6zpSCvstvz9A.png" /></figure><p>The dashboard displays basic information about the Kong instance you’re currently connected, the underlying database and the available plugins.</p><p>More detailed information can be found in the INFO page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FV0r_dy7P5_Vw4NN5KpYOg.png" /></figure><h4>Snapshots</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxu4HvhaNtnMNZfQij0ukg.png" /></figure><p>The snapshots feature, allows you to easily backup, restore and move your Kong configuration across nodes. You can also schedule automated snapshots of your Kong instances.</p><h4>Settings</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WscrC30pAMASlPe7u0h7xA.png" /></figure><p>The settings page, provides a simple way to configure Konga and set up a basic ACL for user accounts. Bare in mind, that user permissions are set globally and refer to the user account as an entity. Individual user ACLs are not yet supported.</p><h3>Creating Services and Routes</h3><p>Moving on to the important stuff. Let’s see how we can create services and routes to our APIs.</p><p>For this tutorial, we’re going to use the excelent online fake API for testing and prototyping provided by <a href="https://github.com/typicode">typicode </a>.</p><p><a href="https://jsonplaceholder.typicode.com/">JSONPlaceholder</a></p><p>Navigate to the services page and add a new service. Fill in the form as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*ZsJhnAJwfLL-TFyxg9Mj7Q.png" /></figure><p>Submit it and boom! The service will be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwTE8HqzJJWRQJ2OlqVZcg.png" /></figure><p>The <em>jsonplaceholder </em>API provides the following resources:</p><ul><li><a href="https://jsonplaceholder.typicode.com/posts">posts</a></li><li><a href="https://jsonplaceholder.typicode.com/comments">comments</a></li><li><a href="https://jsonplaceholder.typicode.com/albums">albums</a></li><li><a href="https://jsonplaceholder.typicode.com/photos">photos</a></li><li><a href="https://jsonplaceholder.typicode.com/todos">todos</a></li><li><a href="https://jsonplaceholder.typicode.com/users">users</a></li></ul><p>We need to create routes to those resources.</p><p>There are a number of ways we can do that depending on the use case but, for this tutorial, we will only need two routes.</p><p>The first one will be used for fetching and listing and the second one for creating, updating and deleting.</p><p>Click on the json-placeholder service, select the routes tab and add a new route.</p><p>Fill in the form as follows and hit submit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfeGWFSn3fE9e8-gbKAGxA.png" /></figure><p>This route will respond to GET requests.</p><p>Try it out:</p><pre>$ curl -i http://localhost:8000/fake-api/users</pre><p>Likewise, create a second route that responds to POST , PUT , PATCH and DELETE requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6QB51P_jjhkOl6xheUSRQ.png" /></figure><p>Go on and test it by creating a new user:</p><pre>$ curl -X POST \<br>       -H &quot;Content-Type: application/json&quot; \<br>       -d &#39;{&quot;name&quot;:&quot;JohnDoe&quot;,&quot;username&quot;:&quot;jdoe&quot;}&#39; \    <br>       http://localhost:8000/fake-api/users</pre><p>Neat! So, what’s the story so far?</p><p>We’ve sucessfully deployed Kong &amp; Konga and managed to access the <em>jsonplaceholder</em> API through our gateway.</p><p>Next, we need to secure our resources, and provide manager access to only certain consumers.</p><h3>Securing resources</h3><p>Kong provides a number of ways to do that by using Authentication and security plugins. To keep things simple, we’re going to use the key authentication plugin on our service.</p><p>Navigate to thejson-placeholder service, select the plugins tab, hit the add plugin button and select the key auth plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4MEEXHmO8QEv3BczuVZZpA.png" /></figure><p>Submit the form using the default values. A Key Authentication layer is added to our service and both of our routes are now secure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AudJ3HD-8J0bRBwL1h6cjA.png" /></figure><p>If you try:</p><pre>curl -i <a href="http://178.128.192.104:8000/fake-api/users">http://localhost:8000/fake-api/users</a></pre><p>you’ll get a 401 Unauthorized response from the Gateway.</p><p>Next thing we need to do is create a consumer with the appropriate credentials.</p><p>Go to the consumers page and create a new consumer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OjtRZAVJCdKvryprPOS-9A.png" /></figure><p>From the consumer’s page, under the credentials tab, select api keys-&gt;create api key .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*buwlvu3Dg-TkS2j-iq_Osw.png" /></figure><p>Submit the form, the key will be auto-generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhif3aJPORG4UQg9r8xueg.png" /></figure><p>If we now try to consume the resource using the generated apikey in the headers, everything works as expected:</p><pre>$ curl -i -H &quot;apikey:{{your-api-key}}&quot; http://localhost:8000/fake-api/users</pre><p>Golden! But, there’s one caveat. Apart from fetching and listing, our consumer can also create, update and delete resources. In real world applications, the readers should only be able to read. Managing resources is something only administrators/managers should be allowed to do.</p><p>Our management route, — the one that accepts POST , PUT , PATCH and DELETE requests — , should only be accessible by certain consumer groups.</p><p>In order to achieve that, we can use Access Control Lists.</p><p>Create a new consumer with the username manager. The username can be whatever you like, we’re just using the specific one so it’s easier to indentify their roles.</p><p>Assign an apikey credential to the new consumer like before.</p><p>The only extra step we need to take, is to add this consumer to a group .</p><p>In the respective consumer page, select the groups tab and add a new group called managers.</p><p>Back to the jsoonplaceholder service. Select the routes tab and edit the management route. Go to plugins and add the ACL plugin which can be found under the security group.</p><p>In the plugin form, type the name of the managers group, hit enter and submit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2hWVgBJOh9LKP3c7i3V5Q.png" /></figure><p>After submitting, select the eligible consumers tab. You’ll notice that only the manager is listed. That means only that consumer can access the specific route.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*69A7qTsGH0iYLGVu4eF2lQ.png" /></figure><p>Try creating a resource using the reader’s apikey as oposed to the manager’s:</p><pre>$ curl -X POST \<br>       -H &quot;Content-Type: application/json&quot; \<br>       -H &quot;apikey: {{reader-apikey}}&quot; \<br>       -d &#39;{&quot;name&quot;:&quot;JohnDoe&quot;,&quot;username&quot;:&quot;jdoe&quot;}&#39; \    <br>       <a href="http://localhost:8000/fake-api/users">http://localhost:8000/fake-api/users</a></pre><pre>HTTP/1.1 401 Unauthorized</pre><pre>$ curl -X POST \<br>       -H &quot;Content-Type: application/json&quot; \<br>       -H &quot;apikey: {{manager-apikey}}&quot; \<br>       -d &#39;{&quot;name&quot;:&quot;JohnDoe&quot;,&quot;username&quot;:&quot;jdoe&quot;}&#39; \    <br>       <a href="http://localhost:8000/fake-api/users">http://localhost:8000/fake-api/users</a></pre><pre>HTTP/1.1 201 Created</pre><p>Kong &amp; Konga constitute a set of powerfull open source tools that can spare you lots of time and distress. This basic introductory example barely scratches the surface but nevertheless, it’s a solid starting point.</p><p>On future articles we will focus on more complex scenarios and use cases.</p><p>Until then, go on and take those stuff for a ride.</p><p>Peace.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d14568bb59d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>