Follow the steps to download and modify the JSON config file for your gateway and then run the list of commands in OpenShift to enable the policy.
- Download the specific version of the apicast config file required from the API manager.
curl -X GET "https://{TENANT_NAME}-admin.{WILDCARD_DOMAIN}/admin/api/services/{service_id}/proxy/configs/{environment}/{version}.json?access_token={access_token}" > apicast.json
- Wrap the JSON file in a JSON object and services array and remove the proxy_config.content parent objects.
- Add the policy_chain to the proxy object within the new JSON.
An example policy_chain JSON would look like this:
{
"policy_chain": [{
"name": "3scale_batcher",
"version": "builtin",
"configuration": {
"auths_ttl": 120,
"batch_report_seconds": 120
}
}, {
"name": "apicast",
"version": "builtin",
"configuration": {}
}]
}
The values used above are just examples. You should end up with a JSON config file as shown here.
This JSON config file needs to be used by APIcast locally so we will use the env var THREESCALE_CONFIG_FILE
which will reference the local path of the config file on the container. The following steps are to create the configmap and update the apicast dc to enable the policy in the new gateway.
oc create configmap apicast-json --from-file=./apicast.json
oc volume dc/{dc_name} --add --name=apicast-configuration -m /tmp/foobar -t configmap --configmap-name=apicast-json
oc env dc/{dc_name} THREESCALE_CONFIG_FILE=/tmp/foobar/apicast.json
oc env dc/{dc_name} THREESCALE_PORTAL_ENDPOINT-
oc edit dc/{dc_name}
You will enter the editor and need to add the subPath to end up with something like the following:
volumeMounts:
- mountPath: /tmp/foobar/apicast.json
name: apicast-configuration
subPath: apicast.json
oc patch dc {dc_name} -p '{"spec": {"template": {"spec": {"containers": [{"name": "{dc_name}", "image": "quay.io/3scale/apicast:master" }]} }}}'
Ensure the deployment config has been redeployed with all the latest changes using oc describe dc/{dc_name}
and verify all the above changes exist.