diff --git a/core/src/plugins/kubernetes/util.ts b/core/src/plugins/kubernetes/util.ts index 0352a94a17..aee077c726 100644 --- a/core/src/plugins/kubernetes/util.ts +++ b/core/src/plugins/kubernetes/util.ts @@ -262,7 +262,14 @@ export async function execInWorkload({ const api = await KubeApi.factory(log, ctx, provider) const pods = await getCurrentWorkloadPods(api, namespace, workload) - const pod = pods[0] + const runningPods = pods.filter((p) => checkPodStatus(p) === "ready") + if (runningPods.length === 0) { + throw new DeploymentError({ + message: `No running pods found for ${getResourceKey(workload)}`, + }) + } + + const pod = sample(runningPods) if (!pod) { // This should not happen because of the prior status check, but checking to be sure