Skip to main content
Feedback

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

  1. Define configmap and config properties.

  2. Define volumes and volume mounts in trafficmanager subchart values using over-rides file.

  3. Read config/secrets in the adapter code.

  4. Deploy application.

Example for SDK Built Adapter

For example, refer to the samples/trafficmanager/ adapter, and follow the steps listed below.

Procedure

  1. Define config properties and configmap.

    info

    You can define the config file directly in the config-map (for config file, refer to config maps in some of the subcharts)

    or

    Use the Files globber code (for globber examples, refer to this path: samples/trafficmanager/adapter/templates/adapter-configmap.yaml).

    1. Copy the configmap template yaml to deploy/charts/trafficmanager/templates.

      info

      If you are using the Files globber method, copy them to deploy/charts/trafficmanager/ folder.

    2. Use helm lint to validate the syntax of the defined configmap.

    3. 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)

    4. Note the file name and configmap, as these will be needed for the next step.

  2. Define volumes and volume mounts for trafficmanager subchart to mount config to the trafficmanager pods.

    1. Create an overrides file for deployment (refer to this path: samples/trafficmanager/adapter/adapter-overrides.yaml).

    2. Define volume and volume mounts in this file.

      note

      The attribute name in volumes and volume mounts must be the same.

    3. For path, consider using the following recommended path only: /opt/adapter/conf

      info
      • The config file will be mounted in this path with the file name defined in the configmap.

      • 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 kubectl to get secrets.

  3. Read the config file in the adapter.

    For an example, refer to <Mashery Local SDK directory>/MasheryLocalSDK/examples/ReadConfigFileAdapter.java

    1. Use java.nio.Path to locate the file. When mounted in the recommended directory, it will be in /opt/adapter/conf/<file name from configmap>

    2. Use java.nio.Path to 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)

On this Page