{
  "$type": "site.standard.document",
  "canonicalUrl": "https://rickymoorhouse.uk/blog/2021/debugging-jobs-in-k8s",
  "path": "/blog/2021/debugging-jobs-in-k8s",
  "publishedAt": "2021-07-20T00:00:00.000Z",
  "site": "at://did:plc:r53zv4vpzeihop3aliwyejlu/site.standard.publication/3mos5q3a7jf2w",
  "tags": [
    "kubernetes"
  ],
  "textContent": "As jobs are often short running and finish before you can check anything within the pod, often it's helpful to make the pod run for longer to be able to inspect the environment and re-run the job manually. \nOne way to do this is to extract the yaml definition for a previous run of the job and create a pod definition replacing the command with an endless sleep.\n\n    kubectl get pod {previous-job-pod} -o yaml > pod.yaml\n\nThen edit the pod.yaml, removing the status block and the additional metadata referring to the previous job so the metadata only contains name and namespace\n\nThe comand then needs to be updated/specified with something like this:\n\n      command:\n        - /bin/sh\n        - '-c'\n        - while true; do echo hello; sleep 10000; done\n\nThen use kubectl apply -f pod.yaml to deploy the new pod definition to your cluster and you will have a long running pod with the environment and code for the job.",
  "title": "Debugging jobs in kubernetes"
}