Document updated on Jul 10, 2020
When KrakenD runs, all the behavior is loaded from the configuration file. Through environment variables you can inject a value in the configuration when the server starts. There are two different ways of injecting environment vars.
For each configuration value that isn’t nested (meaning first-level properties of the configuration), you can override its value with an environment variable.
All configuration environment variables that you want to set using environment variables, pass them with a prefix KRAKEND_
. The variable name after the prefix must match the property in the configuration value using uppercase.
For instance, take the following krakend.json
configuration as an example:
{
"version": 2,
"timeout": "3s",
"name": "Example gateway."
}
To replace values using env vars, run krakend with the following command:
$KRAKEND_NAME="Build ABC0123" KRAKEND_TIMEOUT="500ms" krakend run -c krakend.json
The resulting configuration will be:
{
"version": 2,
"timeout": "500ms",
"name": "Build ABC0123"
}
NOTE: The configuration file is not changed. The values above are a representation of the final mapped values.
If you need to replace content using environment variables at any level, you have to use the flexible configuration. It includes a series of advanced functions including an env
function that can write in the config any value.
{ “version”: 2, “name”: “Configuration for {{ env “MY_POD_NAMESPACE” }}” }
The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.
We use cookies to understand how you use our site and to improve your overall experience. By continuing to use our site, you accept our Privacy Policy. More information