Please note that this page is WIP.
Before you begin, make sure you have downloaded the following:
- Start the API Manager and log in to the API Publisher (
adminas the username and password.
- Create and publish an API (e.g.
Log in to the API Store and create an application that supports JWT tokens.
Subscribe to the
PetstoreAPI and generate a JWT token to invoke the API.
deployment.tomlfile containing the relevant deployment configurations such as docker image name, registry, tag, etc. as shown below.
Note that the docker image name must be in lower case.Click here to see the description for each parameter...
Parameter Description Default value name Name of the docker image. output balx file name registry Name of the docker registry. None tag The docker image tag. latest buildImage Enable or disable the option to build the docker images. true dockerHost Docker host IP and docker PORT. E.g. minikube IP and docker PORT unix:///var/run/docker.sock dockerCertPath Docker cert path. null baseImage Base image to create the docker image. ballerina/ballerina:latest enableDebug Enable or disable debugging. false debugPort Remote debug port. 5005 push Enable or disable pushing the docker image to the remote registry. false username Username for docker registry. None password Password for docker registry. None
Parameter Description Default value source The source path of the file (in your local machine). None target The target path (inside container). None isBallerinaConf The option to flag if file is a ballerina config file. false
- Copy the
micro-gw.conffile to the docker image as it contains the key manager configurations, JWT configurations, etc. This can be done by enabling the docker copy files configuration as shown above.
Let’s create a project called
petstore_projectand provide the
deployment.tomlfile as an input.
Navigate to the
<MICROGW_TOOLKIT_HOME>/bindirectory and run the following command,
This commands creates the following folders under the
│ ├── conf
│ │ └── deployment-config.toml
│ ├── src
│ │ ├── extension_filter.bal
│ │ ├── petstore.bal
│ │ ├── listeners.bal
│ │ └── policies
│ │ ├── application_10PerMin.bal
│ │ ├── application_20PerMin.bal
│ │ ├── application_50PerMin.bal
│ │ ├── subscription_Bronze.bal
│ │ ├── subscription_Gold.bal
│ │ ├── subscription_Silver.bal
│ │ ├── subscription_Unauthenticated.bal
│ │ └── throttle_policy_initializer.bal
│ ├── target
│ └── temp
│ └── hashes.json
Build the project using the following command,
The docker image is created in your local registry and can be used to spawn an API Microgateway docker container.
Run the docker container using the following command,
If you are working in a Mac environment, start the docker container with the following command to bind the docker container ports to the localhost or the docker host machine:
If you are working in a Linux environment, you can also start the docker container using the host network driver for your container as follows:
If you are working in a Mac environment, skip step 10.
Retrieve the docker container IP address as follows,
Using a REST client or a cURL command, access the API using the following details:
If you are working in a Mac environment, the URL is
Authorization : Bearer <JWT_TOKEN>
As JWT is a self-contained access token, the Microgateway does not need to connect to the Key Manager. However, if you are using an Oauth2 access token, point the Microgateway to the Key Manager using the Key Manager details in the
micro-gw.conf configuration file of the Microgateway. You can provide the Key Manager
serverUrl as shown below. The
serverUrl has to be accessible from the Microgateway.