Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonathanbernal25/6c159a9eee79870a8ac181a707b2715e to your computer and use it in GitHub Desktop.
Save jonathanbernal25/6c159a9eee79870a8ac181a707b2715e to your computer and use it in GitHub Desktop.

Installing Tyk on RHEL7 / RHEL8

This guide is meant to be a distilled version of the information on Tyk's documentation. Refer to the official Tyk documentation for any updates, revisions, or additional details regarding this installation process.

NOTE: This guide is for installing all Tyk components and databases on a single server. This is NOT recommended for a production environment.

This guide is divided into three parts:

  1. Installing Tyk Dashboard
  2. Installing Tyk Pump
  3. Installing Tyk Gateway

The installation sequence should follow the order above, beginning with installing the Tyk Dashboard, then the Tyk Pump, and lastly the Tyk Gateway.

System Prerequisites

This guide assumes all system packages are up-to-date. If not, run the following command:

sudo yum update -y

Install Extra Packages for Enterprise Linux (EPEL), this is required for Redis:

RHEL7 RHEL8
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y

Install Python:

RHEL7 RHEL8
sudo yum install python34 -y sudo yum install python36 -y

Part 1. Installing Tyk Dashboard

Step #1
Set up YUM repository:

RHEL7 RHEL8
sudo yum install pygpgme yum-utils wget -y sudo yum install yum-utils wget -y

Step #2
Create a file called: tyk_tyk-dashboard.repo

sudo vi /etc/yum.repos.d/tyk_tyk-dashboard.repo

And add the following contents:

[tyk_tyk-dashboard]
name=tyk_tyk-dashboard
baseurl=https://packagecloud.io/tyk/tyk-dashboard/el/7/\$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://keyserver.tyk.io/tyk.io.rpm.signing.key.2020
       https://packagecloud.io/tyk/tyk-dashboard/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

Step #3
Create a file called: mongodb-org-4.0.repo

If using Amazon Linux 2 AMI, follow MongoDB documentation on 1 - Configure the package management system (yum) then return and continue to 'Update local cache' below in this same step.

sudo vi /etc/yum.repos.d/mongodb-org-4.0.repo

And add the following contents:

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

Update local cache:

sudo yum -q makecache -y --disablerepo='*' --enablerepo='tyk_tyk-dashboard'

Step #4
Install databases (MongoDB & Redis) and Tyk Dashboard:

sudo yum install mongodb-org tyk-dashboard redis -y

Step #5
Start databases (MongoDB & Redis):

sudo service mongod start
sudo service redis start

Step #6
Configure Tyk Dashboard:
NOTE: Modify the two lines with "<YOUR_IP_ADDRESS>" before working with the command below:

sudo /opt/tyk-dashboard/install/setup.sh \
--listenport=3000 \
--redishost=localhost \
--redisport=6379 \
--mongo=mongodb://localhost/tyk_analytics \
--tyk_api_hostname=<YOUR_IP_ADDRESS>:8080 \
--tyk_node_hostname=http://localhost \
--tyk_node_port=8080 \
--portal_root=/portal \
--domain="<YOUR_IP_ADDRESS>"

Command options explaination:
--listenport=3000

This tells the Tyk Dashboard to listen on port 3000.

--redishost=localhost

This tells the Tyk Dashboard to use the local Redis instance.

--redisport=6379

This tells the Tyk Dashboard to use port 6379 to communicate with Redis (this is the default port for Redis).

--mongo=mongodb://localhost/tyk_analytics

This tells the Tyk Dashboard to use the local MongoDB instance.

--tyk_api_hostname=<YOUR_IP_ADDRESS>:8080 (MODIFICATION REQUIRED)

The hostname the Tyk Dashboard will use when it needs to connect to a Tyk Gateway. In this instance we are using the public IP of the instance.

--tyk_node_hostname=http://localhost

The Tyk Dashboard needs to see a node (Tyk Gateway) in order to create new tokens. This command tells the Tyk Dashboard where to find a node. In this case, we use the locally installed node.

--tyk_node_port=8080

This tells the Tyk Dashboard to use port 8080 to communicate with the Tyk Gateway as defined by tyk_node_hostname (this is the default port for Tyk Gateway).

--portal_root=/portal

Display portal on /portal of whichever domain set for the portal. Not Found Error Fatal Error

--domain="<YOUR_IP_ADDRESS>" (MODIFICATION REQUIRED)

This command binds the Tyk Dashboard to the hostname or IP address of the server.

Step #7
Start Tyk Dashboard:

sudo service tyk-dashboard start

Now go to http://<YOUR_IP_ADDRESS>:3000/ to begin Tyk Dashboard license registration.

Part 2. Installing Tyk Pump

Step #1
Create a file called: tyk_tyk-pump.repo

sudo vi /etc/yum.repos.d/tyk_tyk-pump.repo

And add the following contents:

[tyk_tyk-pump]
name=tyk_tyk-pump
baseurl=https://packagecloud.io/tyk/tyk-pump/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://keyserver.tyk.io/tyk.io.rpm.signing.key.2020
       https://packagecloud.io/tyk/tyk-pump/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

Update local cache:

sudo yum -q makecache -y --disablerepo='*' --enablerepo='tyk_tyk-pump'

Step #2
Install Tyk Pump:

sudo yum install tyk-pump -y

Step #3
Configure Tyk Pump:

sudo /opt/tyk-pump/install/setup.sh \
--redishost=localhost \
--redisport=6379 \
--mongo=mongodb://localhost/tyk_analytics

Command options explaination:
--redishost=localhost

This tells the Tyk Pump to use the local Redis instance.

--redisport=6379

This tells the Tyk Pump to use port 6379 to communicate with Redis (this is the default port for Redis).

--mongo=mongodb://localhost/tyk_analytics

This tells the Tyk Pump to use the local MongoDB instance.

Step #4
Start Tyk Pump:

sudo service tyk-pump start

Part 3. Installing Tyk Gateway

Step #1
Create a file called: tyk_tyk-gateway.repo

sudo vi /etc/yum.repos.d/tyk_tyk-gateway.repo

And add the following contents:

[tyk_tyk-gateway]
name=tyk_tyk-gateway
baseurl=https://packagecloud.io/tyk/tyk-gateway/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://keyserver.tyk.io/tyk.io.rpm.signing.key.2020
       https://packagecloud.io/tyk/tyk-gateway/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

Update local cache:

sudo yum -q makecache -y --disablerepo='*' --enablerepo='tyk_tyk-gateway' --enablerepo=epel

Step #2
Install Tyk Gateway:

sudo yum install tyk-gateway -y

Step #3
Configure Tyk Gateway:

sudo /opt/tyk-gateway/install/setup.sh \
--dashboard=1 \
--listenport=8080 \
--redishost=localhost \
--redisport=6379

Command options explaination:
--dashboard=1

Flag specifying whether the Tyk Gateway should use the Tyk Dashboard. Any non-empty value would act as true.

--listenport=8080

This tells the Tyk Gateway to listen on port 8080 (this is the default port for Tyk Gateway).

--redishost=localhost

This tells the Tyk Gateway to use the local Redis instance.

--redisport=6379

This tells the Tyk Gateway to use port 6379 to communicate with Redis (this is the default port for Redis).

Step #4
Start Tyk Gateway:

sudo service tyk-gateway start

Part 4. Reboot Machine

Reboot Machine:

sudo reboot

Restart services:

sudo service mongod start
sudo service redis start
sudo service tyk-dashboard start
sudo service tyk-pump start
sudo service tyk-gateway start
@jonathanbernal25
Copy link
Author

jonathanbernal25 commented May 28, 2021

View GW logs
journalctl -u tyk-gateway -f

@jonathanbernal25
Copy link
Author

Pretty print redis output via jq
sudo yum install jq -y
redis-cli get KEY_NAME | jq .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment