Using ConfigMaps with a Flogo App
Flogo apps running in Kubernetes can leverage 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 leverage the ConfigMap. You can create a ConfigMap using a
.property file that was exported from your Flogo app.
- Procedure
- Export the Flogo app properties to a
.propertiesfile. Refer to the section, Exporting App Properties to a File, for details. - Update the generated
.propertiesfile as desired. - Create a ConfigMap using the
.propertiesfile. 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.propertiesand you want the generated ConfigMap to be calledflogo-rest-configthe command would be similar to the following:kubectl create configmap flogo-rest-config --from-env-file=Timer-env.properties
- 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. - Build the Docker image for the app binary by running the following command:
docker build -t <CONTAINER_REGISTRY_URI>/<app-tag>
- Push the resulting image to the container registry using the following command:
kubectl apply -f <appname>.yaml