Documentation ¶
Index ¶
- Constants
- Variables
- func PushAll()
- type DiscoveryServer
- func (s *DiscoveryServer) ClearCacheFunc() func()
- func (s *DiscoveryServer) FetchEndpoints(ctx context.Context, req *xdsapi.DiscoveryRequest) (*xdsapi.DiscoveryResponse, error)
- func (s *DiscoveryServer) InitDebug(mux *http.ServeMux, sctl *aggregate.Controller)
- func (s *DiscoveryServer) Register(rpcs *grpc.Server)
- func (s *DiscoveryServer) StreamAggregatedResources(stream ads.AggregatedDiscoveryService_StreamAggregatedResourcesServer) error
- func (s *DiscoveryServer) StreamEndpoints(stream xdsapi.EndpointDiscoveryService_StreamEndpointsServer) error
- func (s *DiscoveryServer) StreamLoadStats(xdsapi.EndpointDiscoveryService_StreamEndpointsServer) error
- type DiscoveryStream
- type EdsCluster
- type MemServiceDiscovery
- func (sd *MemServiceDiscovery) AddEndpoint(service model.Hostname, servicePortName string, servicePort int, ...) *model.ServiceInstance
- func (sd *MemServiceDiscovery) AddInstance(service model.Hostname, instance *model.ServiceInstance)
- func (sd *MemServiceDiscovery) AddService(name model.Hostname, svc *model.Service)
- func (sd *MemServiceDiscovery) ClearErrors()
- func (sd *MemServiceDiscovery) GetIstioServiceAccounts(hostname model.Hostname, ports []string) []string
- func (sd *MemServiceDiscovery) GetProxyServiceInstances(node *model.Proxy) ([]*model.ServiceInstance, error)
- func (sd *MemServiceDiscovery) GetService(hostname model.Hostname) (*model.Service, error)
- func (sd *MemServiceDiscovery) Instances(hostname model.Hostname, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (sd *MemServiceDiscovery) InstancesByPort(hostname model.Hostname, port int, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (sd *MemServiceDiscovery) ManagementPorts(addr string) model.PortList
- func (sd *MemServiceDiscovery) Services() ([]*model.Service, error)
- type XdsConnection
- type XdsEvent
Constants ¶
const ( // ClusterType is used for cluster discovery. Typically first request received ClusterType = typePrefix + "Cluster" // EndpointType is used for EDS and ADS endpoint discovery. Typically second request. EndpointType = typePrefix + "ClusterLoadAssignment" // ListenerType is sent after clusters and endpoints. ListenerType = typePrefix + "Listener" // RouteType is sent after listeners. RouteType = typePrefix + "RouteConfiguration" )
Variables ¶
var ( // SendTimeout is the max time to wait for a ADS send to complete. This helps detect // clients in a bad state (not reading). In future it may include checking for ACK SendTimeout = 5 * time.Second // PushTimeout is the time to wait for a push on a client. Pilot iterates over // clients and pushes them serially for now, to avoid large CPU/memory spikes. // We measure and reports cases where pusing a client takes longer. PushTimeout = 5 * time.Second )
Functions ¶
Types ¶
type DiscoveryServer ¶
type DiscoveryServer struct { // MemRegistry is used for debug and load testing, allow adding services. Visible for testing. MemRegistry *MemServiceDiscovery // ConfigGenerator is responsible for generating data plane configuration using Istio networking // APIs and service registry info ConfigGenerator *v1alpha3.ConfigGeneratorImpl // contains filtered or unexported fields }
DiscoveryServer is Pilot's gRPC implementation for Envoy's v2 xds APIs
func NewDiscoveryServer ¶
func NewDiscoveryServer(env model.Environment, generator *v1alpha3.ConfigGeneratorImpl) *DiscoveryServer
NewDiscoveryServer creates DiscoveryServer that sources data from Pilot's internal mesh data structures
func (*DiscoveryServer) ClearCacheFunc ¶
func (s *DiscoveryServer) ClearCacheFunc() func()
ClearCacheFunc returns a function that invalidates v2 caches and triggers a push. This is used for transition, once the new config model is in place we'll have separate functions for each event and push only configs that need to be pushed. This is currently called from v1 and has attenuation/throttling.
func (*DiscoveryServer) FetchEndpoints ¶
func (s *DiscoveryServer) FetchEndpoints(ctx context.Context, req *xdsapi.DiscoveryRequest) (*xdsapi.DiscoveryResponse, error)
FetchEndpoints implements xdsapi.EndpointDiscoveryServiceServer.FetchEndpoints().
func (*DiscoveryServer) InitDebug ¶
func (s *DiscoveryServer) InitDebug(mux *http.ServeMux, sctl *aggregate.Controller)
InitDebug initializes the debug handlers and adds a debug in-memory registry.
func (*DiscoveryServer) Register ¶
func (s *DiscoveryServer) Register(rpcs *grpc.Server)
Register adds the ADS and EDS handles to the grpc server
func (*DiscoveryServer) StreamAggregatedResources ¶
func (s *DiscoveryServer) StreamAggregatedResources(stream ads.AggregatedDiscoveryService_StreamAggregatedResourcesServer) error
StreamAggregatedResources implements the ADS interface.
func (*DiscoveryServer) StreamEndpoints ¶
func (s *DiscoveryServer) StreamEndpoints(stream xdsapi.EndpointDiscoveryService_StreamEndpointsServer) error
StreamEndpoints implements xdsapi.EndpointDiscoveryServiceServer.StreamEndpoints().
func (*DiscoveryServer) StreamLoadStats ¶
func (s *DiscoveryServer) StreamLoadStats(xdsapi.EndpointDiscoveryService_StreamEndpointsServer) error
StreamLoadStats implements xdsapi.EndpointDiscoveryServiceServer.StreamLoadStats().
type DiscoveryStream ¶
type DiscoveryStream interface { Send(*xdsapi.DiscoveryResponse) error Recv() (*xdsapi.DiscoveryRequest, error) grpc.ServerStream }
DiscoveryStream is a common interface for EDS and ADS. It also has a shorter name.
type EdsCluster ¶
type EdsCluster struct { LoadAssignment *xdsapi.ClusterLoadAssignment // FirstUse is the time the cluster was first used, for debugging FirstUse time.Time // EdsClients keeps track of all nodes monitoring the cluster. EdsClients map[string]*XdsConnection `json:"-"` // NonEmptyTime is the time the cluster first had a non-empty set of endpoints NonEmptyTime time.Time // contains filtered or unexported fields }
EdsCluster tracks eds-related info for monitored clusters. In practice it'll include all clusters until we support on-demand cluster loading.
type MemServiceDiscovery ¶
type MemServiceDiscovery struct { WantGetProxyServiceInstances []*model.ServiceInstance ServicesError error GetServiceError error InstancesError error GetProxyServiceInstancesError error // contains filtered or unexported fields }
MemServiceDiscovery is a mock discovery interface
func NewMemServiceDiscovery ¶
func NewMemServiceDiscovery(services map[model.Hostname]*model.Service, versions int) *MemServiceDiscovery
NewMemServiceDiscovery builds an in-memory MemServiceDiscovery
func (*MemServiceDiscovery) AddEndpoint ¶
func (sd *MemServiceDiscovery) AddEndpoint(service model.Hostname, servicePortName string, servicePort int, address string, port int) *model.ServiceInstance
AddEndpoint adds an endpoint to a service.
func (*MemServiceDiscovery) AddInstance ¶
func (sd *MemServiceDiscovery) AddInstance(service model.Hostname, instance *model.ServiceInstance)
AddInstance adds an in-memory instance.
func (*MemServiceDiscovery) AddService ¶
func (sd *MemServiceDiscovery) AddService(name model.Hostname, svc *model.Service)
AddService adds an in-memory service.
func (*MemServiceDiscovery) ClearErrors ¶
func (sd *MemServiceDiscovery) ClearErrors()
ClearErrors clear errors used for mocking failures during model.MemServiceDiscovery interface methods
func (*MemServiceDiscovery) GetIstioServiceAccounts ¶
func (sd *MemServiceDiscovery) GetIstioServiceAccounts(hostname model.Hostname, ports []string) []string
GetIstioServiceAccounts gets the Istio service accounts for a service hostname.
func (*MemServiceDiscovery) GetProxyServiceInstances ¶
func (sd *MemServiceDiscovery) GetProxyServiceInstances(node *model.Proxy) ([]*model.ServiceInstance, error)
GetProxyServiceInstances returns service instances associated with a node, resulting in 'in' services.
func (*MemServiceDiscovery) GetService ¶
GetService implements discovery interface
func (*MemServiceDiscovery) Instances ¶
func (sd *MemServiceDiscovery) Instances(hostname model.Hostname, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
Instances filters the service instances by labels. This assumes single port, as is used by EDS/ADS.
func (*MemServiceDiscovery) InstancesByPort ¶
func (sd *MemServiceDiscovery) InstancesByPort(hostname model.Hostname, port int, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
InstancesByPort filters the service instances by labels. This assumes single port, as is used by EDS/ADS.
func (*MemServiceDiscovery) ManagementPorts ¶
func (sd *MemServiceDiscovery) ManagementPorts(addr string) model.PortList
ManagementPorts implements discovery interface
type XdsConnection ¶
type XdsConnection struct { // PeerAddr is the address of the client envoy, from network layer PeerAddr string // Time of connection, for debugging Connect time.Time // ConID is the connection identifier, used as a key in the connection table. // Currently based on the node name and a counter. ConID string HTTPListeners []*xdsapi.Listener `json:"-"` RouteConfigs map[string]*xdsapi.RouteConfiguration HTTPClusters []*xdsapi.Cluster // current list of clusters monitored by the client Clusters []string // Routes is the list of watched Routes. Routes []string // LDSWatch is set if the remote server is watching Listeners LDSWatch bool // CDSWatch is set if the remote server is watching Clusters CDSWatch bool // Time of last push LastPush time.Time // Time of last push failure. LastPushFailure time.Time // contains filtered or unexported fields }
XdsConnection is a listener connection type.