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:
Yu-Ju Hong
2015-06-23 16:01:12 -07:00
parent 819b78087c
commit de75a42cb2
4 changed files with 71 additions and 4 deletions

View File

@@ -284,6 +284,24 @@ func (p *Pod) FindContainerByName(containerName string) *Container {
return nil
}
// ToAPIPod converts Pod to api.Pod. Note that if a field in api.Pod has no
// corresponding field in Pod, the field would not be populated.
func (p *Pod) ToAPIPod() *api.Pod {
var pod api.Pod
pod.UID = p.ID
pod.Name = p.Name
pod.Namespace = p.Namespace
pod.Status = p.Status
for _, c := range p.Containers {
var container api.Container
container.Name = c.Name
container.Image = c.Image
pod.Spec.Containers = append(pod.Spec.Containers, container)
}
return &pod
}
// IsEmpty returns true if the pod is empty.
func (p *Pod) IsEmpty() bool {
return reflect.DeepEqual(p, &Pod{})