How to externalize properties and files from SDK-built Adapters (introduced in v6.1.0)
This section provides detailed instructions on how to externalize properties and files from SDK-built adapters.
If the SDK-built adapters require configuration to be available on the filesystem at runtime, then these config files must be available in the trafficmanager pods. The configurations are mounted as secrets or configmaps. We recommend using secrets for sensitive information.
Steps
-
Define
configmapandconfigproperties. -
Define volumes and volume mounts in
trafficmanagersubchart values usingover-ridesfile. -
Read
config/secretsin the adapter code. -
Deploy application.
Example for SDK Built Adapter
For example, refer to the samples/trafficmanager/ adapter, and follow the steps listed below.
Procedure
-
Define
configproperties andconfigmap.infoYou can define the
configfile directly in theconfig-map(forconfigfile, refer toconfig mapsin some of thesubcharts)or
Use the
Files globbercode (forglobberexamples, refer to this path:samples/trafficmanager/adapter/templates/adapter-configmap.yaml).-
Copy the
configmaptemplate yaml todeploy/charts/trafficmanager/templates.infoIf you are using the
Files globbermethod, copy them todeploy/charts/trafficmanager/folder. -
Use
helm lintto validate the syntax of the definedconfigmap. -
Use the helm functions to define APIM Local Edition labels in addition to your labels and annotations (refer to this path:
samples/trafficmanager/adapter/templates/adapter-configmap.yaml) -
Note the file name and
configmap, as these will be needed for the next step.
-
-
Define volumes and volume mounts for
trafficmanagersubchartto mountconfigto thetrafficmanagerpods.-
Create an
overridesfile for deployment (refer to this path:samples/trafficmanager/adapter/adapter-overrides.yaml). -
Define volume and volume mounts in this file.
noteThe attribute name in volumes and volume mounts must be the same.
-
For path, consider using the following recommended path only:
/opt/adapter/confinfo-
The
configfile will be mounted in this path with the file name defined in theconfigmap. -
All secrets will be mounted to
/var/run/secrets/<subdirectory>. Do not mount directly to/var/run/secrets. Use the same path in the Java code. -
Ensure that the secret is already created. Check using
kubectlto get secrets.
-
-
-
Read the
configfile in the adapter.For an example, refer to
<Mashery Local SDK directory>/MasheryLocalSDK/examples/ReadConfigFileAdapter.java-
Use
java.nio.Pathto locate the file. When mounted in the recommended directory, it will be in/opt/adapter/conf/<file name from configmap> -
Use
java.nio.Pathto locate secret. When mounted in the recommended directory, it will be in/var/run/secrets/<subdirectory>/<secret file name> (secret file name from inside the container)
-