本文整理匯總了Golang中vulcan/kubernetes/pkg/client/unversioned.Client.Endpoints方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Endpoints方法的具體用法?Golang Client.Endpoints怎麽用?Golang Client.Endpoints使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vulcan/kubernetes/pkg/client/unversioned.Client
的用法示例。
在下文中一共展示了Client.Endpoints方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: runMasterServiceTest
func runMasterServiceTest(client *client.Client) {
time.Sleep(12 * time.Second)
svcList, err := client.Services(api.NamespaceDefault).List(labels.Everything())
if err != nil {
glog.Fatalf("unexpected error listing services: %v", err)
}
var foundRW bool
found := sets.String{}
for i := range svcList.Items {
found.Insert(svcList.Items[i].Name)
if svcList.Items[i].Name == "kubernetes" {
foundRW = true
}
}
if foundRW {
ep, err := client.Endpoints(api.NamespaceDefault).Get("kubernetes")
if err != nil {
glog.Fatalf("unexpected error listing endpoints for kubernetes service: %v", err)
}
if countEndpoints(ep) == 0 {
glog.Fatalf("no endpoints for kubernetes service: %v", ep)
}
} else {
glog.Errorf("no RW service found: %v", found)
glog.Fatal("Kubernetes service test failed")
}
glog.Infof("Master service test passed.")
}
示例2: endpointsSet
func endpointsSet(c *client.Client, serviceNamespace, serviceID string, endpointCount int) wait.ConditionFunc {
return func() (bool, error) {
endpoints, err := c.Endpoints(serviceNamespace).Get(serviceID)
if err != nil {
glog.Infof("Error getting endpoints: %v", err)
return false, nil
}
count := 0
for _, ss := range endpoints.Subsets {
for _, addr := range ss.Addresses {
for _, port := range ss.Ports {
count++
glog.Infof("%s/%s endpoint: %s:%d %#v", serviceNamespace, serviceID, addr.IP, port.Port, addr.TargetRef)
}
}
}
return count == endpointCount, nil
}
}
示例3: validateEndpointsOrFail
func validateEndpointsOrFail(c *client.Client, namespace, serviceName string, expectedEndpoints PortsByPodName) {
By(fmt.Sprintf("waiting up to %v for service %s in namespace %s to expose endpoints %v", serviceStartTimeout, serviceName, namespace, expectedEndpoints))
i := 1
for start := time.Now(); time.Since(start) < serviceStartTimeout; time.Sleep(1 * time.Second) {
endpoints, err := c.Endpoints(namespace).Get(serviceName)
if err != nil {
Logf("Get endpoints failed (%v elapsed, ignoring for 5s): %v", time.Since(start), err)
continue
}
// Logf("Found endpoints %v", endpoints)
portsByPodUID := getContainerPortsByPodUID(endpoints)
// Logf("Found port by pod UID %v", portsByPodUID)
expectedPortsByPodUID := translatePodNameToUIDOrFail(c, namespace, expectedEndpoints)
if len(portsByPodUID) == len(expectedEndpoints) {
validatePortsOrFail(portsByPodUID, expectedPortsByPodUID)
Logf("successfully validated that service %s in namespace %s exposes endpoints %v (%v elapsed)",
serviceName, namespace, expectedEndpoints, time.Since(start))
return
}
if i%5 == 0 {
Logf("Unexpected endpoints: found %v, expected %v (%v elapsed, will retry)", portsByPodUID, expectedEndpoints, time.Since(start))
}
i++
}
if pods, err := c.Pods(api.NamespaceAll).List(labels.Everything(), fields.Everything()); err == nil {
for _, pod := range pods.Items {
Logf("Pod %s\t%s\t%s\t%s", pod.Namespace, pod.Name, pod.Spec.NodeName, pod.DeletionTimestamp)
}
} else {
Logf("Can't list pod debug info: %v", err)
}
Failf("Timed out waiting for service %s in namespace %s to expose endpoints %v (%v elapsed)", serviceName, namespace, expectedEndpoints, serviceStartTimeout)
}
示例4:
mkpath := func(file string) string {
return filepath.Join(testContext.RepoRoot, "examples/guestbook-go", file)
}
controllerJson := mkpath("redis-master-controller.json")
nsFlag := fmt.Sprintf("--namespace=%v", ns)
redisPort := 6379
By("creating Redis RC")
runKubectlOrDie("create", "-f", controllerJson, nsFlag)
forEachPod(c, ns, "app", "redis", func(pod api.Pod) {
lookForStringInLog(ns, pod.Name, "redis-master", "The server is now ready to accept connections", podStartTimeout)
})
validateService := func(name string, servicePort int, timeout time.Duration) {
err := wait.Poll(poll, timeout, func() (bool, error) {
endpoints, err := c.Endpoints(ns).Get(name)
if err != nil {
if apierrs.IsNotFound(err) {
err = nil
}
Logf("Get endpoints failed (interval %v): %v", poll, err)
return false, err
}
uidToPort := getContainerPortsByPodUID(endpoints)
if len(uidToPort) == 0 {
Logf("No endpoint found, retrying")
return false, nil
}
if len(uidToPort) > 1 {
Fail("Too many endpoints found")
示例5:
{
IP: serverIP,
},
},
Ports: []api.EndpointPort{
{
Name: "gluster",
Port: 24007,
Protocol: api.ProtocolTCP,
},
},
},
},
}
endClient := c.Endpoints(config.namespace)
defer func() {
if clean {
endClient.Delete(config.prefix + "-server")
}
}()
if _, err := endClient.Create(&endpoints); err != nil {
Failf("Failed to create endpoints for Gluster server: %v", err)
}
volume := api.VolumeSource{
Glusterfs: &api.GlusterfsVolumeSource{
EndpointsName: config.prefix + "-server",
// 'test_vol' comes from test/images/volumes-tester/gluster/run_gluster.sh