import debugpy
from os import getenv
if getenv("REMOTE_DEBUG", None):
debugpy.listen(5678)
Has to open the port
# In case we want to debug remotely
EXPOSE 5678/tcp
spec:
containers:
- name: my_container
image: some_image:latest
ports:
- containerPort: 5678
kubectl port-forward pod/my-pod-579544f56-hzrng 5678:5678
just attach debugger to localhost:5678