Offline Installation TYK Gateway Open Source

Hi Team,

Can you suggest offline installation of TYK Open source API Gateway including the library dependencies if possible.

Hi @saloni512, I am not sure what you mean by offline installation? Do you have some sort of network limitation?

These days, you would naturally need an Internet connection to install a software and it’s dependency packages.

For Tyk, you can download the already built packages or source files depending on your version. If you download the source files then you would also need go files to build them.

Since the gateway is dependent on Redis then it would be necessary to download Redis as well. Alternatively, you can build it from the source.

Yes, we have limitation. We need to set it up on the server where internet connectivity wont be there.

Could you Please suggest what could be the best approach to install, is it copying /opt/tyk-gateway directory (from the server where it has been setup) to the offline server will work?

Is there any other dependencies also needs to be copied?

! more question: Where I can find tyk-gateway.service on the RHEL server?

To do the POC, assuming python3 and redis altready installed on the server I copied /opt/tyk-gateway directory to the server from the server where its setup completely.

I can see tyk process is started but completely:

Netstat gives below output:

netstat -alnp | grep tyk
tcp 0 0 127.0.0.1:38347 0.0.0.0:* LISTEN 4164/tyk
tcp 0 0 127.0.0.1:34718 127.0.0.1:6379 ESTABLISHED 4164/tyk
tcp 0 0 127.0.0.1:34706 127.0.0.1:6379 ESTABLISHED 4164/tyk
tcp 0 0 127.0.0.1:34702 127.0.0.1:6379 ESTABLISHED 4164/tyk
tcp 0 0 127.0.0.1:34704 127.0.0.1:6379 ESTABLISHED 4164/tyk
unix 3 [ ] STREAM CONNECTED 55253 4164/tyk

When I check the status of TYK it gives below output:

tyk-gateway.service - Tyk API Gateway
Loaded: loaded (/etc/systemd/system/tyk-gateway.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-12-08 16:09:18 UTC; 30min ago
Main PID: 4164 (tyk)
Tasks: 8 (limit: 48656)
Memory: 25.3M
CGroup: /system.slice/tyk-gateway.service
└─4164 /opt/tyk-gateway/tyk --conf /opt/tyk-gateway/tyk.conf

Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=warning msg=“Starting HTTP server on:[::]:34407” p>
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“Loading uptime tests…” prefix=host-che>
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“Initialised API Definitions” prefix=main
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“API reload complete” prefix=main
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“reload: complete” prefix=main
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“Initiating coprocess reload” prefix=main
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“Reloading middlewares” prefix=coprocess
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“coprocess reload complete” prefix=main
Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=info msg=“reload: cycle completed in 19.951936ms” >
Dec 08 16:13:28 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:28” level=warning msg="Reconnecting storage: Redis is either>

When I try to curl on 8080 (default port of tyk), its not listening.

When I netstat tyk on the properly installed server I could see tcp6 process is running on 8080 but the other server ( where I copied the folder) its not running.

Am I missing out something here or its not a feasible slution Please suggest.

Redis is running on the default port but tyk is not able to identify it do we need to do sme additional configuration.

[[email protected] tyk-gateway]# netstat -alnp | grep redis
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 4567/redis-server 1
tcp 0 0 127.0.0.1:6379 127.0.0.1:34706 ESTABLISHED 4567/redis-server 1
tcp 0 0 127.0.0.1:6379 127.0.0.1:34718 ESTABLISHED 4567/redis-server 1
tcp 0 0 127.0.0.1:6379 127.0.0.1:34702 ESTABLISHED 4567/redis-server 1
tcp 0 0 127.0.0.1:6379 127.0.0.1:34704 ESTABLISHED 4567/redis-server 1
unix 3 [ ] STREAM CONNECTED 59585 4567/redis-server 1

Hi @saloni512 ,

Copying /opt/tyk-gateway from one machine to another isn’t a great thing to do. It leaves you with a bunch of files in a directory without the surrounding init scripts and package registrations. When it comes to upgrade or uninistall it will have to be done manually and things can get overlooked. An install package isn’t just a collection of files, it’s files and scripts. The scripts run during upgrades/downgrades installs and uninstalls to manage those events so have valuable additional functionality.

Your source machine must have had internet connection to have done the original install. It would be advisable to use that machine to download the appropriate package and then transfer that to your offline machine and install tyk there. Google will be able to provide details on how to download individual packages for your OS, but there is a link on each bundle in our package cloud repo to download via a browser if that helps.

Moving on to the subsequent issues. Your netstat shows that tyk isn’t listening on port 8080. The logs say

Dec 08 16:13:25 ip-192-168-100-21.ap-southeast-1.compute.internal tyk[4164]: time=“Dec 08 16:13:25” level=warning msg=“Starting HTTP server on:[::]:34407” p>

So for some reason it appears to be listening on port 34407, but I don’t see any tcp6 addresses in your netstat output which is confusing.

Could you check your tyk.conf and environment variables to see what the listen port is set to? It might be worth running a curl against localhost:34407 as well to see if that responds

Cheers,
Pete