本文整理汇总了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
}
示例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
}