Score:0

AKS Kubectl command doesn't return completed pods

in flag

I am using AKS with Kubernetes v1.25.6 and I have started to see a number of pods with a Completed status. From what I understand these are generated when an exit 0 code is returned on the process the pod is running, which for the pods in question makes no sense. I was also given the impression that the completed state would allow me to use a command such as kubectl logs podname to review why the pod "completed".

However, I am told that the resource cannot be found. So I have decided to set up logging to a storage account from AKS using the diagnostic settings to see if I can find the data from there.

So my next step is to basically clean up all completed pods and I have seen the following command given:

kubectl delete pod --field-selector=status.phase==Succeeded

I updated this command to the following (to see what would be selected before swapping to a delete)

kubectl get pod --field-selector=status.phase==Completed

However I am told that "No resources have been found", despite a kubectl get pod command showing me nearly 20 completed pods.

If I alter the command to:

kubectl get pod --field-selector=status.phase==Running

I am shown all the running pods. Why does this not work for completed pods? Is this an AKS issue or is the command incorrect?

Score:0
in flag

So it turns out that "Completed" is considered failed instead of Successful which seems rather unintuitive, since Completed does not mean an error or failure.

Changing to

kubectl get pod --field-selector=status.phase==Failed

Returns the affected pods (including others that have "failed"). This is enough for me to clean up but does not allow me to specifically select "Completed" alone for other reasons but it is as close as possible to what I need.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.