Closed BreakTheBeta closed 1 year ago
Only the List call communicates with the server. At that point, you have a static snapshot of Pod objects that does not update if more changes are made to the objects on the server.
To see new data, you would need to relist and get a new copy from the server, or better, watch for changes (see https://github.com/kubernetes/client-go/blob/master/examples/workqueue/main.go for an example of watching and handling add/update/delete events using an informer)
Package name: k8s.io/client-go v0.22.5
Issue: When getting a list of pods
k8s.CoreV1().Pods(namespace).List(ctx, listOptions)
If you monitor the list of returned pods and get their Phase "Running" will be returned even if the pod has been terminated by kubernetes for a new rendition of that pod: