I am terminating pods in a stateful state using io.fabric8.kubernetes
client as
client
.inNamespace(namespace)
.pods()
.withLabel("xx", "xxx")
.delete()
What I am trying :
StatefulSet statefulSet = client
.pods()
.inNamespace("namespace-xxx")
.statefulSets()
.inNamespace(namespace)
.withName("statefulset-name")
.get();
StatefulSetStatus status = statefulSet.getStatus();
StatefulSetSpec spec = statefulSet.getSpec();
and then checking the condition
spec.getReplicas.intValue != status.getReadyReplicas.intValue
However this condition seems to be meeting even when the pods are not Ready!
As someone said in the comments, the client API is asynchronous by nature. This means that you should think differently from the procedural way to check the status of an action. As you can see from the documentation https://github.com/fabric8io/kubernetes-client#following-events the client allows you to define a watcher, where you can specify in the anonymous class all the actions to be performed when the desired event/status happens.