本文整理汇总了Golang中k8s/io/kubernetes/test/e2e/framework.Framework.WaitForAnEndpoint方法的典型用法代码示例。如果您正苦于以下问题:Golang Framework.WaitForAnEndpoint方法的具体用法?Golang Framework.WaitForAnEndpoint怎么用?Golang Framework.WaitForAnEndpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/test/e2e/framework.Framework
的用法示例。
在下文中一共展示了Framework.WaitForAnEndpoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: launchWebserverService
func launchWebserverService(f *e2e.Framework, serviceName string, nodeName string) (serviceAddr string) {
e2e.LaunchWebserverPod(f, serviceName, nodeName)
// FIXME: make e2e.LaunchWebserverPod() set the label when creating the pod
podClient := f.Client.Pods(f.Namespace.Name)
pod, err := podClient.Get(serviceName)
expectNoError(err)
pod.ObjectMeta.Labels = make(map[string]string)
pod.ObjectMeta.Labels["name"] = "web"
podClient.Update(pod)
servicePort := 8080
service := &api.Service{
ObjectMeta: api.ObjectMeta{
Name: serviceName,
},
Spec: api.ServiceSpec{
Type: api.ServiceTypeClusterIP,
Ports: []api.ServicePort{
{
Protocol: api.ProtocolTCP,
Port: int32(servicePort),
},
},
Selector: map[string]string{
"name": "web",
},
},
}
serviceClient := f.Client.Services(f.Namespace.Name)
_, err = serviceClient.Create(service)
expectNoError(err)
expectNoError(f.WaitForAnEndpoint(serviceName))
createdService, err := serviceClient.Get(serviceName)
expectNoError(err)
serviceAddr = fmt.Sprintf("%s:%d", createdService.Spec.ClusterIP, servicePort)
e2e.Logf("Target service IP:port is %s", serviceAddr)
return
}