当前位置: 首页>>代码示例>>Golang>>正文


Golang Interface.ListPods方法代码示例

本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/client.Interface.ListPods方法的典型用法代码示例。如果您正苦于以下问题:Golang Interface.ListPods方法的具体用法?Golang Interface.ListPods怎么用?Golang Interface.ListPods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/GoogleCloudPlatform/kubernetes/pkg/client.Interface的用法示例。


在下文中一共展示了Interface.ListPods方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Update

// Update performs a rolling update of a collection of pods.
// 'name' points to a replication controller.
// 'client' is used for updating pods.
// 'updatePeriod' is the time between pod updates.
func Update(name string, client client.Interface, updatePeriod time.Duration) error {
	controller, err := client.GetReplicationController(name)
	if err != nil {
		return err
	}
	s := labels.Set(controller.DesiredState.ReplicaSelector).AsSelector()

	podList, err := client.ListPods(s)
	if err != nil {
		return err
	}
	expected := len(podList.Items)
	if expected == 0 {
		return nil
	}
	for _, pod := range podList.Items {
		// We delete the pod here, the controller will recreate it.  This will result in pulling
		// a new Docker image.  This isn't a full "update" but it's what we support for now.
		err = client.DeletePod(pod.ID)
		if err != nil {
			return err
		}
		time.Sleep(updatePeriod)
	}
	return wait.Poll(time.Second*5, time.Second*300, func() (bool, error) {
		podList, err := client.ListPods(s)
		if err != nil {
			return false, err
		}
		return len(podList.Items) == expected, nil
	})
}
开发者ID:K-A-Z,项目名称:kubernetes,代码行数:36,代码来源:kubecfg.go


注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/client.Interface.ListPods方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。