Using Configurations from Configuration Management Services

Use configurations from the configuration management services such as Consul and Spring-Cloud-Config, by defining a token such as #<property name># in the application properties, where <property name> is the name of the configuration parameter.

For example, #BACKEND_URL#.

Follow these steps to use configurations from Consul:
  1. Set the environment variable CONSUL_SERVER_URL. For more information, see Environment Variables.
  2. In your Consul service define the keys using the format <BWCE_APP_NAME>/<PROFILE NAME>/<KEY Name>.

    For example, AccountService/Dev/BACKEND_URL

    AccountService/Prod/BACKEND_URL

    Note: The X_CONSUL_TOKEN environment variable should be used when authenticatication is enabled on the Consul server.

Follow these steps to use configurations from Spring Cloud Config:

  1. Set the environment variable SPRING_CLOUD_CONFIG_SERVER_URL. For more information, see Environment Variables
  2. Create a .properties file and add the application properties and their values as key-value pairs in the file. The filename for application specific properties should be <APPLICATION_NAME>-<PROFILE_NAME>.properties.

    For example, jms.application-Docker.properties

    For common properties, the filename should be application.properties.

  3. Add the .properties files to the Spring Cloud Config Server backend.
Note: Using the ExternalApplicationProperties interface provided in com.tibco.bw.runtime.customProps package, users can write their own integration with custom config management servers.
Integration with custom config management server
  1. Create a new package and inside the new package create a new java class.
  2. Import com.tibco.bw.runtime.customProps package in this java class and implement the custom config management by implementing the interface ExternalApplicationProperties provided in this package.

    The implementation of custom configuration management should register an OSGi service implementing the ExternalApplicationProperties interface.

    The interface has a method getExternalApplicationProperties() of return type Map<String, String> that should return the properties and their corresponding values fetched from the custom configuration management server.

  3. Export the project as a plug-in by right-clicking on the newly created package and select Export > Plug-in Development > Deployable plug-ins and fragments.
  4. In the Export wizard, ensure that the package is selected, and specify a location to export the plug-in. Get the JAR file from the specified location in the plug-ins folder and place the JAR in TIBCO_HOME/bwce/2.5/docker/resources/addons/jars folder of the TIBCO BusinessWorks Container Edition installation.
  5. While deploying the application, make sure to set the value of the property bw.application.config.management.type same as the value of the property external.config in your OSGi service.
    1. While deploying the application in the studio, set the property as a VM argument.
    2. For docker, set the property using the following syntax:

      -e BW_JAVA_OPTS="-Dbw.application.config.management.type=custom"

Using Kubernetes ConfigMap for Configuration Management with TIBCO BusinessWorks™ Container Edition.

Follow the steps to use configuration management with ConfigMaps
  1. Export the application properties file for the profile containing the module properties. For more information, see Tokenizing Application Properties for exporting in the Properties file.
  2. Add a profile name to the exported properties file. For example, BW_PROFILE=Prod.
  3. Create a Kubernetes ConfigMap using the following command:
    kubectl create configmap <Name-of-config-map> --from-env-file=<name-of-exported-file>.properties
    
  4. Add the created ConfigMap to the Kubernetes pod specification as follows:
    apiVersion: v1
    kind: Pod
    metadata:
      name: bookstore-demo
      labels:
        app: bookstore-demo
    spec:
      containers:
      - name: bookstore-demo
        image: bookstore-demo:2.4.4
        imagePullPolicy: Never
        envFrom:
        - configMapRef:
          name: <Name-of-config-map>
  5. When a pod is created using above specification, the application will pick values of the tokenized module properties in the application from ConfigMap.