The function as "kubectl delete pod podName --grace-period=0 --force" ?
Hey @lxl910915
Can you please try this if it resolves your problem.
client.pods().inNamespace(namespace).withName(podName).withGracePeriod(0).delete();
not right now, --force ,how to make
Hey @lxl910915
Can you please try this if it resolves your problem.
client.pods().inNamespace(namespace).withName(podName).withGracePeriod(0).delete();
can't resolve this problem, the command --force , how to use the client-api implement?
@liuchaoheliang : Hi, Have you checked if there is such implementation of force deletion in kubernetes rest api? I think it can be implemented
@rohanKanojia it seems that force is just a flag to make sure user knows what he is doing and provide backwards compatibility:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/delete/delete.go#L160
So graceperiod=0 should do the job as --force enforces grace period to 0 otherwise if that flag is not there period will be 1 as with the --now flag.
Hey @lxl910915
Can you please try this if it resolves your problem.
client.pods().inNamespace(namespace).withName(podName).withGracePeriod(0).delete();
Can we delete one more pods?
@yuwzho : Could you please elaborate what you're saying?
@rohanKanojia I have some pods to force delete (no specific label set, just names), can I make it in one(as less as possible) api call to save network overhead.
umm, just names. I don't think so. But if you have full objects then you can do something like:
client.resourceList(new PodListBuilder().withItems(pod1, pod2, pod3).build()).withGracePeriod(0).delete()
Thank you very much! It solves my problem!
Most helpful comment
@rohanKanojia it seems that force is just a flag to make sure user knows what he is doing and provide backwards compatibility:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/delete/delete.go#L160
So graceperiod=0 should do the job as
--forceenforces grace period to 0 otherwise if that flag is not there period will be 1 as with the--nowflag.