本文整理汇总了Golang中k8s/io/kubernetes/pkg/api.PodStatus.HostIP方法的典型用法代码示例。如果您正苦于以下问题:Golang PodStatus.HostIP方法的具体用法?Golang PodStatus.HostIP怎么用?Golang PodStatus.HostIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/api.PodStatus
的用法示例。
在下文中一共展示了PodStatus.HostIP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetPodStatus
// GetPodStatus retrieves the status of the pod, including the information of
// all containers in the pod. Clients of this interface assume the containers
// statuses in a pod always have a deterministic ordering (eg: sorted by name).
func (r *runtime) GetPodStatus(pod *api.Pod) (*api.PodStatus, error) {
podInfos, err := r.hyperClient.ListPods()
if err != nil {
glog.Errorf("Hyper: ListPods failed, error: %s", err)
return nil, err
}
var status api.PodStatus
podFullName := r.buildHyperPodFullName(string(pod.UID), string(pod.Name), string(pod.Namespace))
for _, podInfo := range podInfos {
if podInfo.PodName != podFullName {
continue
}
if len(podInfo.PodInfo.Status.PodIP) > 0 {
status.PodIP = podInfo.PodInfo.Status.PodIP[0]
}
status.HostIP = podInfo.PodInfo.Status.HostIP
status.Phase = api.PodPhase(podInfo.PodInfo.Status.Phase)
status.Message = podInfo.PodInfo.Status.Message
status.Reason = podInfo.PodInfo.Status.Reason
for _, containerInfo := range podInfo.PodInfo.Status.Status {
for _, container := range podInfo.PodInfo.Spec.Containers {
if container.ContainerID == containerInfo.ContainerID {
status.ContainerStatuses = append(
status.ContainerStatuses,
r.getContainerStatus(containerInfo, container.Image, container.ImageID))
}
}
}
}
glog.V(5).Infof("Hyper: get pod %s status %s", podFullName, status)
return &status, nil
}