I am trying to execute a simple python script via Azure Cloud Shell (Powershell) that generates a simple log via a Kubernates Job, using the following yaml file:
apiVersion: batch/v1
kind: Job
metadata:
name: your-job-name
spec:
template:
spec:
containers:
- name: your-container-name
image: python:3
command: ["python", "your-script.py"]
restartPolicy: Never
This is the python script:
import sys
import datetime as dt
def print_to_stdout(*a):
# Here a is the array holding the objects
# passed as the argument of the function
print(*a, file=sys.stdout)
# Save the current time to a variable ('t')
t = dt.datetime.now()
while True:
delta = dt.datetime.now()-t
if delta.seconds >= 30:
print_to_stdout("Hello World, half minute has passed")
# Update 't' variable to new time
t = dt.datetime.now()
But I am getting stuck on this error: python: can't open file '//your-script.py': [Errno 2] No such file or directory.
Any hint on how to solve this. It seems like python cannot find the file with the source code.