Configuring custom configmaps and environment variables

You can add environment variables or files to your deployments by using the custom configmap feature. You can create configmaps for either files to be loaded or environment variables that need to be added to the pod.

About this task

Multiple configmaps can be mounted, and can hold environment variables or files, but not a mixture of both.

Mounting path is optional, and if not specified, files are mounted in the overrides directory: /opt/ibm/wlp/usr/servers/defaultServer/configDropins/overrides. The mounting path can be any valid path relative to the container.

All files that are mounted by using this mechanism are not validated and need to be in the correct format.

If a custom configmap is specified in the custom resource, but is not created, the deployment of that component stops.

Procedure

  1. Add a configuration file to any of the FNCM component pods.
    For example, you can add a trace.xml file or a mimetypes.properties file to your deployment.
    1. Create a configmap for the file that you intend to add to the deployment.
      kubectl create configmap your_configmap_name --from-file=file_name_in_pod=your_file_name
      where, your_file_name is the name of the file for which you want to create a configmap. file_name_in_pod is the name of the file in the target FNCM component pod. your_configmap_name is the name of the configmap that you want to create. For example, you can create a configmap for trace.xml from the command:
      kubectl create configmap cpe-trace-cm --from-file=trace.xml=trace.xml
      Note: The key value for the configmap becomes the name of the file to be mounted.
    2. Identify the FNCM component section in the custom resource where you want to add the newly created configmap.
      You can add the configmap to the CPE, CMIS, GraphQL, External Share, Task Manager, Navigator sections of the custom resource.
    3. Edit the custom_configmap parameter in the section to include the configmap that you created.
      For example, if you want to add a file to the Content Platform Engine pod, edit the following section:
      ecm_configuration:
        cpe:
          cpe_production_setting:
            custom_configmap:
              - name: cpe-trace-cm
      To mount the configmap under the non-default location, set the custom_configmap.volume_path parameter to include the location:
      ecm_configuration:
        cpe:
          cpe_production_setting:
            custom_configmap:
              - name: cpe-trace-cm
                volume_path: path_to_file_in_pod
      for example, for mimetypes.properties you can specify the volume path to include the non-default mounting path as /opt/ibm/wlp/usr/servers/defaultServer.
    4. Apply the updated custom resource.
      kubectl replace -f ibm_fncm_cr_production.yaml
    After the operator reconciles, the FNCM component pod restarts and mounts the new file_name_in_pod file under the specified location. If the location is not specified, it mounts the file in the default location.
    Note: You cannot use the custom configmap feature for binary files and they must be copied manually into the pod.
  2. Add two new environment variables to your FNCM component deployment.
    You can add the environment variables to the CPE, CMIS, GraphQL, External Share, Task Manager, Navigator pods.
    ENV_VAR1 = FNCM
    ENV_VAR2 = Operator
    1. Create the configmap containing the environment variables.
      For example, you can create a configmap named env-vars-config for the two environment variables ENV_VAR1 and ENV_VAR2 as:
      kubectl create configmap env-vars-config \
      --from-literal=ENV_VAR1=FNCM \
      --from-literal=ENV_VAR2=Operator
    2. Identify the FNCM component section in the custom resource where you want to add the newly created configmap.
      You can add the configmap to the CPE, CMIS, GraphQL, External Share, Task Manager, Navigator sections of the custom resource.
    3. Edit the custom_configmap parameter in the section to include the configmap that you created.
      For example, if you want to add the configmap to the Content Platform Engine pod, edit the following section:
      ecm_configuration:
        cpe:
          cpe_production_setting:
            custom_configmap:
              - name: env-vars-config
                is_env: true
    After the operator reconciles, the FNCM component pod restarts and adds the new environment variables.