Using ConfigMaps with a Flogo App

Flogo apps running in Kubernetes can use ConfigMaps for the app configuration through environment variables. When you bind the ConfigMap with your pod, all the properties in the ConfigMap get injected into the pod as environment variables. If your pod has multiple containers, you can specify the container into which you want to inject the environment variables in the .yml file of the app. When running the app in Kubernetes, you use the ConfigMap. You can create a ConfigMap using a .property file that was exported from your Flogo app.

To create a ConfigMap when running your app in Kubernetes:
Important: If you update the app properties in Flogo Enterprise, you must recreate the ConfigMap and repush the app for your changes to take effect in Kubernetes.
    Procedure
  1. Export the Flogo app properties to a .properties file. Refer to the section Exporting App Properties to a File for details.
  2. Update the generated .properties file as desired.
  3. Create a ConfigMap using the .properties file. Run the following command:
    kubectl create configmap <name-of-configmap-file-to-be-created> --from-env-file=<exported-app-prop-filename>.properties

    For example, if your exported file name is Timer-env.properties and you want the generated ConfigMap to be called flogo-rest-config the command would be similar to the following:

    kubectl create configmap flogo-rest-config --from-env-file=Timer-env.properties

  4. Update the Kubernetes deployment configuration YAML file for the app to let your app know that you want to use environment variables. Add the following:
    env:
            - name: "FLOGO_APP_PROPS_ENV"
              value: "auto"
            envFrom:
            - configMapRef:
                name: <name-of-the-configmap>
    Note: Refer to the Kubernetes documentation for instructions on how to configure a pod to use ConfigMaps.
  5. Build the docker image for the app binary by running the following command:
    docker build -t  <CONTAINER_REGISTRY_URI>/<app-tag>
  6. Push the resulting image to the container registry using the following command:
    kubectl apply -f <appname>.yaml