Reputation: 2083
I wanna use kubectl wait
command to wait until a pvc is bound.
I tried kubectl wait --for=condition=bound pvc/my-pvc-claim --timeout=2s
with a pvc which is already bound, but it doesn't seem to work. This is the output error: timed out waiting for the condition on persistentvolumeclaims/my-pvc-claim
.
I read kubectl wait
documentation, but still can't understand which condition I should use. How can I accomplish that? Is there a more complete documentation explaining how to do that?
Upvotes: 5
Views: 2022
Reputation: 235
Use the jsonpath provided in subudears answer as the for option.
So this way you can utilise kubectl wait
kubectl wait --for=jsonpath='{.status.phase}'=Bound pvc/my-pvc
Upvotes: 4
Reputation: 251
You can use the following command:
while [[ $(kubectl get pvc myclaim -o 'jsonpath={..status.phase}') != "Bound" ]]; do echo "waiting for PVC status" && sleep 1; done
Upvotes: 6
Reputation: 161
You may want to try using explain to see what conditions are possible to make sure you have the right one. Check here for an example of how you might use that.
Upvotes: 2