I am trying to get STDOUT and STDERR of a pod written to the file at PVC mount location.
Following is the template content of my deployment:
    "template": {
      "metadata": {
        "name": "python-stdout-app",
        "creationTimestamp": null,
        "labels": {
          "k8s-app": "python-stdout-app"
        }
      },
      "spec": {
        "volumes": [
          {
            "name": "task-pv-volume",
            "persistentVolumeClaim": {
              "claimName": "task-pv-claim"
            }
          }
        ],
        "containers": [
          {
            "name": "python-stdout-app",
            "image": "trideep/demo-stdout-app",
            "resources": {},
            "volumeMounts": [
              {
                "name": "task-pv-volume",
                "mountPath": "/usr/share"
              }
            ],
            "terminationMessagePath": "/usr/share/1fed8c03-bc30-4889-952e-46f4c19b6ac1.log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "Always",
            "securityContext": {
              "privileged": false
            }
          }
        ],
        "restartPolicy": "Always",
        "terminationGracePeriodSeconds": 30,
        "dnsPolicy": "ClusterFirst",
        "securityContext": {},
        "schedulerName": "default-scheduler"
      }
    }
I can see the file being written while inside the pod. But not seeing the output on mounted host location.
Following is the execution command
python demo_stdout.py >> /usr/share/1fed8c03-bc30-4889-952e-46f4c19b6ac1.log 2>&1
One thing which I did is the output file and the "terminationMessagePath" is the same as i want the pod termination footprint and the stdout/stderr in the same file.
Dockerfile is as below:
FROM python:2.7.15-alpine3.9
WORKDIR /usr/src/app
COPY . .
CMD ["sh", "-c", "tail -f /dev/null"]
Tried the following:
python demo_stdout.py >> /usr/share/test.log 2>&1
The above produces the log in PVC. But need to get the pod termination log in the same file.
Can someone help me with this?