<p>I have a discord bot that I have deployed on kubernetes.  It is built into a docker image that I then deploy to k8s.</p>

<p><code>Dockerfile</code>:</p>

<pre><code>    FROM python:3.7

    WORKDIR /app
    COPY . /app

    RUN pip install -r requirements.txt

    ENV PYTHONUNBUFFERED=0
    CMD ["python", "-u", "main.py"]
</code></pre>

<p><code>deployment.yml</code>:</p>

<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pythonapp
  labels:
    app: pythonapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pythonapp
  template:
    metadata:
      labels:
        app: pythonapp
    spec:
      containers:
        - name: pythonapp
          image: registry.example.com/pythonapp:latest
          imagePullPolicy: Always
          env:
            - name: PYTHONUNBUFFERED
              value: "0"
</code></pre>

<p>When I deploy it, the program runs fine.  But when I go to check the pod's logs, it says <code>The selected container has not logged any messages yet.</code>.  </p>

<p>How can I get anything that I <code>print()</code> in python to be logged to the kubernetes pod?</p>

cclloyd
<p><code>PYTHONUNBUFFERED</code> must be set to <code>1</code> if you want to show log messages immediately without being buffered first.</p>
