4

I'm trying to delete an existent job using

kubectl delete job/job-name -n my-namespace

But this error is displayed

caling the resource failed with: Job.batch "kong-loop" is invalid:
spec.template: Invalid value: api.PodTemplateSpec{...}: field is
immutable; Current resource version 12189833
Bruno Quaresma
  • 9,457
  • 7
  • 32
  • 50

2 Answers2

4

The solution posted by @esnible does work in this scenario, but it is simpler do these steps:

  1. Delete job with cascade false

kubectl delete job/jobname -n namespace --cascade=false

  1. Delete any pod that exists

kubectl delete pod/podname -n namespace

Solution found at in this google groups discussion https://groups.google.com/forum/#!topic/kubernetes-users/YVmUgktoqtI

moose1089
  • 121
  • 5
1

kubectl does an HTTP PUT to the job during the delete process. This PUT fails because the Job has gotten itself into an invalid state. We must DELETE without PUTing.

Try

kubectl proxy curl -X DELETE localhost:8001/apis/batch/v1/namespaces/<namespace>/jobs/<jobname>

Then kill the kubectl proxy process. namespace is typically default

esnible
  • 340
  • 2
  • 10