Programatically get all the containers from EKS cluster

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: 1.25
Cloud being used: AWS (EKS)
Host OS: RHEL 9

I am getting all the pods and containers information for a given cluster using /api/v1/pods k8s api. But this api does not tell me how long pod or containers in that pod have been running. Is there any way to get this information using any of the kubernetes api? This information is necessary for my application.

Any help in this regard is highly appreciated!

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

Each running pod has .status.containerStatuses[*].state.running.startedAt field that I assume is what you are looking for.

1 Like