This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Deploying the API Microgateway in Docker
Please note that this page is WIP.
Before you begin, make sure you have downloaded the following:
WSO2 Microgateway ToolKit - Version 2.6.0 (WSO2 Microgateway Toolkit is packed with the WSO2 Microgateway Version 2.6.0)
Start the API Manager and log in to the API Publisher (
https://<hostname>:9443/publisher) usingadminas the username and password.Create and publish an API (e.g.
Petstore).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.Create a
deployment.tomlfile containing the relevant deployment configurations such as docker image name, registry, tag, etc. as shown below.[docker] [docker.dockerConfig] enable = true name = "petstore" registry = 'docker.wso2.com' tag = 'v1' #buildImage = '' #dockerHost = '' #dockerCertPath = '' #baseImage = '' #enableDebug = '' #debugPort = '' #push = '' #username = '' #password = '' [docker.dockerCopyFiles] enable = true [[docker.dockerCopyFiles.files]] source = '<MICROGW_TOOLKIT_HOME>/resources/conf/micro-gw.conf' target = '/home/ballerina/conf/micro-gw.conf' isBallerinaConf = trueCopy 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 calledpetstore_projectand provide thedeployment.tomlfile as an input.Navigate to the
<MICROGW_TOOLKIT_HOME>/bindirectory and run the following command,./micro-gw setup <project_name> -a <API_name> -v <version> --deployment-config deployment.tomlFor example,
./micro-gw setup petstore-project -a petstore -v 1.0.0 --deployment-config deployment.tomlThis commands creates the following folders under the
petstore_projectfolder.├── petstore_project│ ├── 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└── test.tomlBuild the project using the following command,
./micro-gw build <project_name>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,
docker run -d docker.wso2.com/<API_name>:<version>Retrieve the docker container IP address as follows,
docker ps - This provides the container id docker inspect <Container_ID> | grep "IPAddress"Using a REST client or a cURL command, access the API using the following details:
URL -
https://<Container_IP>:9095/<API_name>/<version>/<resource>Headers -
Authorization : Bearer <JWT_TOKEN>Method -
GET
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.
[keyManager]
serverUrl="https://localhost:9443"
username="admin"
password="admin"
tokenContext="oauth2"
timestampSkew=5000