Kubernetes-client: Setting a grace period when deleting resource

Created on 8 Jun 2020  路  3Comments  路  Source: fabric8io/kubernetes-client

Hi,
I was deleting a resource using this

operation().inNamespace(namespace).withName(name).cascading(cascading).withGracePeriod(gracePeriod).delete();

Since cascading has been deprecated in 4.10.2 (currently using) I updated the code to

operation().inNamespace(namespace).withName(name).withPropagationPolicy(cascading ? DeletionPropagation.FOREGROUND : DeletionPropagation.ORPHAN).delete();

But I cannot set withGracePeriod(long) anymore.
I can do

operation().inNamespace(namespace).withName(name).withGracePeriod(gracePeriod).delete();

but there the propagation policy is not set.

How can I set both of these properties?

Thanks

bug

Most helpful comment

I think it's available like this:

client.apps().deployments().inNamespace("rokumar").withName("nginx").withPropagationPolicy(DeletionPropagation.FOREGROUND).withGracePeriod(0L).delete();

All 3 comments

It seems this made it into 4.10.3 however I am still not able to do

KubernetesClient kc = new DefaultKubernetesClient();
kc.apps().statefulSets().inNamespace("ns").withName("name").withGracePeriod(42L).withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();

I think it's available like this:

client.apps().deployments().inNamespace("rokumar").withName("nginx").withPropagationPolicy(DeletionPropagation.FOREGROUND).withGracePeriod(0L).delete();

Aha! Thanks

Was this page helpful?
0 / 5 - 0 ratings