Cyberithub

How to Install Kong Gateway on Ubuntu Linux

Advertisements

In this article, we will see how to install Kong Gateway on Ubuntu Linux. If you are looking for an API driven gateway to manage API and microservices traffic then Kong Gateway is probably the most suitable one to use. It is a free and open source reverse proxy which works at the microservices management layer. It also comes with pricing policy in case you would like to use additional features. It is mainly designed to handle traffic between client applications and API or microservices. Additionally, it also perform tasks like authentication, analysis, rate limiting, request/response transformations and logging.

As kong gateway is a lua application built on top of lightweight NGINX server, it can handle high volume of multiple concurrent API calls efficiently. It is also easy to deploy in almost all kinds of environments including hybrid cloud and multi-cloud environments. It can also be scaled horizontally as demand increases. Thus providing the flexibility to keep up with the demand. Kong not only provides plugins for gateway deployment but it also allows us to create custom plugins. More on official website.

 

How to Install Kong Gateway on Ubuntu Linux

How to Install Kong Gateway on Ubuntu Linux

Also Read: How to Install lighttpd web server on Ubuntu 22.04

Step 1: Prerequisites

  • You would require a fully functional Ubuntu Linux system.
  • You would also require root or equivalent access to run privileged commands.
  • curl utility would be needed to be used in bash script and for installation verification.

 

Step 2: Update Your Server

To check latest available packages and upgrade all packages installed in the system, run sudo apt update && sudo apt upgrade command as shown below. It will install all the security updates, bug fixes and improvement features.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade

 

Step 3: Install Kong Gateway

There are multiple ways to install Kong Gateway but the quickest you is through bash script. To install Kong Gateway, run bash <(curl -sS https://get.konghq.com/install) -v script in your system as shown below.

NOTE:

Please note that if you are running a firewall in your system then make sure to allow Port 8000, 8001 and 8002 from it for kong gateway to run properly.
cyberithub@ubuntu:~$ bash <(curl -sS https://get.konghq.com/install) -v
/dev/fd/63: option requires an argument -- v
This script will install Kong Gateway in traditional mode, where it acts as both the Control Plane and Data Plane. Running in this mode may have a small performance impact.

Would you prefer to have Kong host your Control Plane, allowing your data plane to run at maximum performance and decreasing your deployment complexity?

Switch to using Konnect? (y/n) n

########################################################
Installing kong-enterprise-edition on Ubuntu
########################################################

Checking installed packages
Adding Kong repo
Installing kong-enterprise-edition
Installing postgresql
Running Kong migrations
Starting Kong

===================================================
Kong Gateway is now running on your system
Ensure that port 8000 is open to the public

Kong Manager is available on port 8002
See https://docs.konghq.com/gateway/latest/kong-manager/enable/ to enable the UI
You can log in with the username 'kong_admin' and password '135910d471de9dbc0321'
===================================================

 

Step 4: Verify Installation

To verify installation, run curl -i http://localhost:8001  command as shown below.

cyberithub@ubuntu:~$ curl -i http://localhost:8001
HTTP/1.1 200 OK
Date: Sat, 13 Apr 2024 06:40:50 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 5ad3680a2dfdef454e2b887904445f31
Content-Length: 21033
X-Kong-Admin-Latency: 778
Server: kong/3.6.1.2-enterprise-edition
.............................................

 

Step 5: Check Version

You can also verify the current installed version by using kong version command.

cyberithub@ubuntu:~$ kong version
Kong Enterprise 3.6.1.2

 

Step 6: Check Health Status

To check the health status, run sudo kong health command as shown below. If you see output like below then it confirms that kong is healthy and running fine.

cyberithub@ubuntu:~$ sudo kong health
[sudo] password for cyberithub:
nginx.......running

Kong is healthy at /usr/local/kong

 

Step 7: Configure Kong Gateway

By default, kong gateway configuration would be available under /etc/kong/kong.conf path. You can configure admin_gui_path and admin_gui_url as below.

admin_gui_path = /manager
admin_gui_url = http://localhost:8002/manager

After setting up the configuration, you can verify its validity by running kong check command as shown below.

cyberithub@ubuntu:~$ kong check
configuration at /etc/kong/kong.conf is valid

Then restart kong by running sudo kong restart command as shown below.

cyberithub@ubuntu:~$ sudo kong restart
Kong stopped
Kong started

 

Step 8: Access Kong Manager

To access kong manager dashboard, go to your favorite browser and enter url http://localhost:8002/manager. It should open like below.

How to Install Kong Gateway on Ubuntu Linux 2

 

Step 9: Configure a New Gateway Service

Now that Kong Gateway is installed, let's configure a new gateway service. For that, go to Workspaces and select default workforce.

How to Install Kong Gateway on Ubuntu Linux 3

Under Gateway services, click on New Gateway Service.

How to Install Kong Gateway on Ubuntu Linux 4

You can provide the name of gateway service as cyberithub_service and url as http://httpbin.org.

How to Install Kong Gateway on Ubuntu Linux 5

Once provided, click on Save to create a new gateway service.

How to Install Kong Gateway on Ubuntu Linux 6

It should be created and enabled like below.

How to Install Kong Gateway on Ubuntu Linux 7

 

Step 10: Add a Route

Now that gateway service is create, let's add a route to it. For that, go to cyberithub_service and click on Add a route from overview screen.

How to Install Kong Gateway on Ubuntu Linux 8

Here provide a valid route name and leave protocols to default HTTP, HTTPS.

How to Install Kong Gateway on Ubuntu Linux 9

Then provide the paths as /test and click on Save to finally add the route.

How to Install Kong Gateway on Ubuntu Linux 10

You should see testing route created as below.

How to Install Kong Gateway on Ubuntu Linux 11

By default, kong gateway handle all proxy requests at Port 8000. To verify if the route forwarding requests to service, navigate to url http://localhost:8000/test/anything and check the output. It should show something like below. This confirms route successfully forwarding requests to cyberithub_service.

How to Install Kong Gateway on Ubuntu Linux 12

 

Step 11: Fun Command

There is also a fun command in Kong Gateway called kong roar which you can use to display an ASCII representation of  a gorilla. It does not have any practical purpose.

cyberithub@ubuntu:~$ kong roar
Kong, Monolith destroyer.

    /\  ____
    <> ( oo )
    <>_| ^^ |_
    <>   @    \
   /~~\ . . _ |
  /~~~~\    | |
 /~~~~~~\/ _| |
 |[][][]/ / [m]
 |[][][[m]
 |[][][]|
 |[][][]|
 |[][][]|
 |[][][]|
 |[][][]|
 |[][][]|
 |[][][]|
 |[][][]|
 |[|--|]|
 |[| |]|
 ========
==========
|[[ ]]|
==========

 

Step 12: Uninstall Kong Gateway

When you are done using kong, you can also think of removing it from your system by first stopping it using kong stop command.

cyberithub@ubuntu:~$ sudo kong stop
Kong stopped

Then remove the package by using sudo apt remove kong-enterprise-edition command as shown below.

cyberithub@ubuntu:~$ sudo apt remove kong-enterprise-edition
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
kong-enterprise-edition
0 upgraded, 0 newly installed, 1 to remove and 24 not upgraded.
After this operation, 267 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 252445 files and directories currently installed.)
Removing kong-enterprise-edition (3.6.1.2) ...
dpkg: warning: while removing kong-enterprise-edition, directory '/usr/local/share/xml' not empty so not removed
dpkg: warning: while removing kong-enterprise-edition, directory '/usr/local/lib' not empty so not removed
dpkg: warning: while removing kong-enterprise-edition, directory '/usr/local/kong' not empty so not removed
dpkg: warning: while removing kong-enterprise-edition, directory '/etc/kong' not empty so not removed

Leave a Comment