Gathering logs for a Kubernetes environment

The generate_postmortem.sh script gathers all logs for troubleshooting and diagnostics.

Before you begin

Review the log rotation recommendations in Deployment requirements.

About this task

When contacting IBM Support, several logs are required to assist in troubleshooting or diagnostics. The generate_postmortem.sh script gathers all the required logs using a single shell script.

Note: This article refers to third-party software and documentation that IBM does not control. As such, the software may change and this information may become outdated.

Procedure

  1. Install the kubectl command line interface for Kubernetes, if it is not already installed.
  2. Configure kubectl to the Kubernetes cluster by entering the following commands:
    rm -fr $HOME/.kube
    mkdir -p $HOME/.kube
    scp root@{kubernetes_master_host}:/etc/kubernetes/admin.conf $HOME/.kube/config
    
  3. Download the generate_postmortem.sh script. It will be downloaded to the apicup project directory. Enter the following command:
    curl -s -o generate_postmortem.sh https://raw.githubusercontent.com/ibm-apiconnect/v10-postmortem/master/generate_postmortem.sh
  4. Add execute permissions to the generate_postmortem.sh script. Enter the following command:
    chmod +x generate_postmortem.sh
  5. Run the postmortem tool using the following command:
    ./generate_postmortem.sh
  6. (Optional) Currently, log generation is supported for Gateway and Portal subsystems. Specify either gateway or portal, or all subsystems. Enter the following arguments:
    All (generates logs for both Portal and Gateway subsystems): ./generate_postmortem.sh --diagnostic-all
    Gateway: ./generate_postmortem.sh --diagnostic-gateway
    Portal: ./generate_postmortem.sh --diagnostic-portal
  7. (Optional) If there are errors when running the generate_postmortem.sh script, enter the following command:
    ./generate_postmortem.sh --debug &>debug.log

    For more documentation on the script, see https://github.com/ibm-apiconnect/v10-postmortem.

    Note:
    • Offboarding the logs to an external server is the recommended best practice for long term storage of log data.
    • If the logs do not cover far enough back in time, or conversely if they are too large, adjust the log retention size. For further information, see:https://docs.docker.com/config/containers/logging/json-file/.