當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Endpoints.Subsets方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/api.Endpoints.Subsets方法的典型用法代碼示例。如果您正苦於以下問題:Golang Endpoints.Subsets方法的具體用法?Golang Endpoints.Subsets怎麽用?Golang Endpoints.Subsets使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/api.Endpoints的用法示例。


在下文中一共展示了Endpoints.Subsets方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: newEndpoints

func newEndpoints(service *kapi.Service, subsets ...kapi.EndpointSubset) *kapi.Endpoints {
	endpoints := kapi.Endpoints{
		ObjectMeta: service.ObjectMeta,
		Subsets:    []kapi.EndpointSubset{},
	}

	endpoints.Subsets = append(endpoints.Subsets, subsets...)
	return &endpoints
}
開發者ID:Xmagicer,項目名稱:origin,代碼行數:9,代碼來源:dns_test.go

示例2: newEndpoints

func newEndpoints(service kapi.Service, subsets ...kapi.EndpointSubset) kapi.Endpoints {
	endpoints := kapi.Endpoints{
		ObjectMeta: service.ObjectMeta,
		Subsets:    []kapi.EndpointSubset{},
	}

	for _, subset := range subsets {
		endpoints.Subsets = append(endpoints.Subsets, subset)
	}
	return endpoints
}
開發者ID:johndmulhausen,項目名稱:kubernetes,代碼行數:11,代碼來源:kube2sky_test.go

示例3: HandleEndpoints

// HandleEndpoints processes watch events on the Endpoints resource and
// creates and deletes pools and pool members in response.
func (p *F5Plugin) HandleEndpoints(eventType watch.EventType,
	endpoints *kapi.Endpoints) error {

	glog.V(4).Infof("Processing %d Endpoints for Name: %v (%v)",
		len(endpoints.Subsets), endpoints.Name, eventType)

	for i, s := range endpoints.Subsets {
		glog.V(4).Infof("  Subset %d : %#v", i, s)
	}

	switch eventType {
	case watch.Added, watch.Modified:
		// Name of the pool in F5.
		poolname := poolName(endpoints.Namespace, endpoints.Name)

		if len(endpoints.Subsets) == 0 {
			// F5 does not permit us to delete a pool if it has a rule associated with
			// it.  However, a pool does not necessarily have a rule associated with
			// it because it may be from a service for which no route was created.
			// Thus we first delete the endpoints from the pool, then we try to delete
			// the pool, in case there is no route associated, but if there *is*
			// a route associated though, the delete will fail and we will have to
			// rely on HandleRoute to delete the pool when it deletes the route.

			glog.V(4).Infof("Deleting endpoints for pool %s", poolname)

			err := p.updatePool(poolname, endpoints)
			if err != nil {
				return err
			}

			glog.V(4).Infof("Deleting pool %s", poolname)

			err = p.deletePool(poolname)
			if err != nil {
				return err
			}
		} else {
			glog.V(4).Infof("Updating endpoints for pool %s", poolname)

			err := p.ensurePoolExists(poolname)
			if err != nil {
				return err
			}

			err = p.updatePool(poolname, endpoints)
			if err != nil {
				return err
			}
		}
	case watch.Deleted:
		poolname := poolName(endpoints.Namespace, endpoints.Name)
		// presumably, the endpoints are a nil subnet now, reset it anyway
		endpoints.Subsets = nil
		err := p.updatePool(poolname, endpoints)
		if err != nil {
			return err
		}

		glog.V(4).Infof("Deleting pool %s", poolname)

		err = p.deletePool(poolname)
		if err != nil {
			return err
		}
	}

	glog.V(4).Infof("Done processing Endpoints for Name: %v.", endpoints.Name)

	return nil
}
開發者ID:dcbw,項目名稱:origin,代碼行數:73,代碼來源:plugin.go

示例4: addEndpointSubsetTo

func (f *fakeServicesDiagnostic) addEndpointSubsetTo(service string) {
	endpoints := kapi.Endpoints{}
	endpoints.Subsets = []kapi.EndpointSubset{{}}
	f.endpoints[service] = endpoints
}
開發者ID:juanluisvaladas,項目名稱:origin,代碼行數:5,代碼來源:services_test.go


注:本文中的k8s/io/kubernetes/pkg/api.Endpoints.Subsets方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。