I have a test that launches a Pod to check that certain functionality exists within the cluster.
I want to launch the Pod with kubectl create then kubectl wait to get the container's exit code to determine the test's successfulness, with a fail-fast approach. I'm interested in pure kubectl solutions, as this is the portable unit between the test environments (shell scripts vary).
Other similar posts' answers assume that the Pod will succeed, so either use wait with:
--for jsonpathto check{.status.phase}=Succeeded--for condition=Completedand wrap the Pod in a Job
The problem is that, if the test fails it waits for the full --timeout, which in my case can be a long time - time, resources and energy that are wasted if the Pod fails early.
I've explored using:
- Any
orconditionals, wait accepts multiple--forarguments, but only considers the final one --for jsonpath='{.status.conditions[...].reason}'=PodCompleted, which doesn't work in a variety of formulations tried because can't filter to an individual .reason, or .reason doesn't exist immediately and results in an early error.--for jsonpath='{.status.containerStatuses[0].state.terminated}as there's no field here that has an exact value to check against; there's no way to test for the presence of keys
Thanks