mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 05:36:12 +00:00
Add a kubelet /runningpods endpoint
/runningpods returns a list of pods currently running on the kubelet. The list is composed by examining the container runtime, and may be different from the desired pods to run known by kubelet. This is useful for tests to verify that pods are indeed deleted on nodes.
This commit is contained in:
@@ -1850,6 +1850,23 @@ func (kl *Kubelet) GetPods() []*api.Pod {
|
||||
return kl.podManager.GetPods()
|
||||
}
|
||||
|
||||
// GetRunningPods returns all pods running on kubelet from looking at the
|
||||
// container runtime cache. This function converts kubecontainer.Pod to
|
||||
// api.Pod, so only the fields that exist in both kubecontainer.Pod and
|
||||
// api.Pod are considered meaningful.
|
||||
func (kl *Kubelet) GetRunningPods() ([]*api.Pod, error) {
|
||||
pods, err := kl.runtimeCache.GetPods()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiPods := make([]*api.Pod, 0, len(pods))
|
||||
for _, pod := range pods {
|
||||
apiPods = append(apiPods, pod.ToAPIPod())
|
||||
}
|
||||
return apiPods, nil
|
||||
}
|
||||
|
||||
func (kl *Kubelet) GetPodByFullName(podFullName string) (*api.Pod, bool) {
|
||||
return kl.podManager.GetPodByFullName(podFullName)
|
||||
}
|
||||
|
Reference in New Issue
Block a user