0

I have do a logging example

apiVersion: v1
kind: Pod
metadata:
  name: counter
spec:
  containers:
  - name: count
    image: busybox:1.28
    args: [/bin/sh, -c,
            'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done']

to create this counter

kubectl apply -f counter.yaml

to get logs

kubectl logs counter

taken from : Kubernetes logging example how ever when i tried the same with python print or stdout.write its not working

1 Answers1

1

Python by default buffers its output to stdout and stderr. Add an env variable named PYTHONUNBUFFERED and set it to something (anything as long as its not empty). You can set it in the env block in the pod yaml or set it in the Docker image as in this answer

Blender Fox
  • 4,442
  • 2
  • 17
  • 30