I have a very simple setup. My .yaml-Configuration file for Kubernetes:
apiVersion: batch/v1
kind: Job
metadata:
name: stdout-test
spec:
template:
spec:
priorityClassName: research-high
containers:
- name: container-stdout-test
image: <here comes my secret image repo>
imagePullPolicy: "IfNotPresent"
resources:
limits:
nvidia.com/gpu: "1"
cpu: "1"
memory: "8Gi"
requests:
nvidia.com/gpu: "1"
cpu: "1"
memory: "4Gi"
command: ["python3", "/workspace/main.py"]
volumeMounts:
- mountPath: /workspace
name: localdir
imagePullSecrets:
- name: lsx-registry
restartPolicy: "Never"
volumes:
- name: localdir
cephfs:
monitors:
- <here come my secret monitors>
user: <namespace>
path: "/home/stud/nothelfer/stdout-test"
secretRef:
name: <my secret>
And my simple python program (main.py
):
import time
for i in range(0, 1000):
print(i)
time.sleep(1.0)
Starting and running the job in kubernetes works fine. I get this output from kubectl get pods
:
NAME READY STATUS RESTARTS AGE
stdout-test-hl6qs 1/1 Running 0 5s
But i dont get the expected output 0, 1, 2, ... from stdout by using kubectl logs -f stdout-test-hl6qs
. Instead i just get a blank screen. There is just no output printed to the console. I was expecting to get the output of my simple python program. I have tried all possible command line arguments for kubectl logs
but none of them make me see the output of my Python program in the command line. The image is set up correctly, the Python program runs fine in the container, I have already checked all that. Can anyone help me here?
My Dockerfile:
FROM pytorch/pytorch
RUN conda install matplotlib pandas numpy
RUN conda update --all
ENV PYTHONUNBUFFERED 1
RUN python -c "import torch, pandas, matplotlib"