本文整理匯總了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
}