Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes - Scaling the resource failed with: Job.batch is invalid:

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
like image 940
Bruno Quaresma Avatar asked Oct 26 '25 11:10

Bruno Quaresma


2 Answers

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

like image 195
moose1089 Avatar answered Oct 28 '25 03:10

moose1089


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

like image 22
esnible Avatar answered Oct 28 '25 02:10

esnible