Tyk
This example uses Tyk, an API gateway and management platform.
Tyk is used together with Redis to store API tokens and OAuth clients.
To run this example, follow these steps:
-
Install the CLI. Use the unikraft CLI or the legacy kraft CLI. You need a BuildKit builder. The easiest way to get one is via Docker. Alternatively, you can also directly set up and use BuildKit, see the quick start.
The unikraft CLI is the current standard, while kraft is the legacy version. Choose one of the CLIs below and only run the commands associated with it for the rest of this guide.
-
Clone the
examplesrepository andcdinto theexamples/tyk/directory:Code
Make sure to log into Unikraft Cloud and pick a metro close to you.
This guide uses fra (Frankfurt, 🇩🇪):
Redis
The REDIS_PASSWORD environment variable sets the Redis requirepass directive.
If not provided, it defaults to unikraft.
Build and deploy the Redis instance (used internally by Tyk):
Make sure to replace <my-org> with your username / org-name in the unikraft CLI commands above.
The output shows the Redis instance details:
Tyk
Build and deploy the Tyk instance:
Make sure to replace <my-org> with your username / org-name in the unikraft CLI commands above.
The output shows the Tyk instance details:
In this case, the instance names are redis-6vgvc and tyk-s9ixd, and the Tyk address is https://icy-haze-8ph4u8cz.fra.unikraft.app.
They're different for each run.
Use curl to query the Tyk instance on Unikraft Cloud:
Code
Code
You can list information about the instances by running:
When done, you can remove the instances:
Customize your app
To customize the Tyk app, you can update:
Kraftfile: the Unikraft Cloud specificationDockerfile/rootfs/: the Tyk filesystem (in this case the configuration file/etc/tyk.conf)
It's unlikely you will have to update the Kraftfile specification.
Update the contents of the rootfs/etc/tyk.conf file for a different configuration.
You can also update the Dockerfile in order to extend the Tyk filesystem with extra data files or configuration files.
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
Or visit the CLI Reference or the legacy CLI Reference.