Configure Persistent Volumes for Logging

Add persistent volumes to retain transaction and debug logs when containers are restarted.

About this task

In a cloud native deployment, transaction and debug logs written to locations inside containers are deleted if a container is restarted. Persistent storage outside of the Kubernetes cluster is needed for logs to persist when containers are recreated.
Note: Configuration details for persistent volumes depend on site infrastructure details and can vary in specific deployments.

Procedure

  1. Update kubernetes/example-engine-config-sideloader/config/resource_create_config.info to add the following questions and answers.
    Note: Because all mtx-engine pods share the same template, it is important to specify the log directory name with local_%e_%c_%b.
    Do you want to use the default transaction log directory (y/n)?n
    What directory do you want to use for the transaction log files?/myssd/local_%e_%c_%b
    Do you want to use the default log directory (y/n)?n
    What directory do you want to use for the log files?/myssd/local_%e_%c_%b
  2. Update kubernetes/example/engine/my_obj_templates/engine_sts.yaml to specify a hostPath volume. The configuration in the template must be different if you use another type of volume.
    Note: A hostPath volume uses a file or directory on the node to emulate network-attached storage. Use an NFS share or similar in a production environment.
    The comments # BEGIN_NEW_BLOCK and # END_NEW_BLOCK are added to clearly mark the boundary of new lines to be added. You do not have to add them in your file.
    apiVersion: apps/v1   
    kind: StatefulSet   
    metadata:   
      name: {name}   
    spec:   
    ...
      template:
      ...
        spec:
          volumes:
          # BEGIN_NEW_BLOCK
          - name: ssd-logs
            hostPath:
              path: /mylogs
              type: DirectoryOrCreate
          # END_NEW_BLOCK
      ...
      containers:
      ...
        volumeMounts:
        # BEGIN_NEW_BLOCK
        - mountPath: /myssd
          name: ssd-logs
        # END_NEW_BLOCK
     ...

What to do next

Apply the configuration changes using the steps in the discussion about applying MATRIXX Engine configuration changes.