本文整理匯總了Golang中k8s/io/kubernetes/pkg/api.Endpoints類的典型用法代碼示例。如果您正苦於以下問題:Golang Endpoints類的具體用法?Golang Endpoints怎麽用?Golang Endpoints使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Endpoints類的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
}
示例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
}
示例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
}
示例4: addEndpointSubsetTo
func (f *fakeServicesDiagnostic) addEndpointSubsetTo(service string) {
endpoints := kapi.Endpoints{}
endpoints.Subsets = []kapi.EndpointSubset{{}}
f.endpoints[service] = endpoints
}