istio: Index | Files

package adsc

import ""


Package Files

adsc.go util.go

func ConfigInitialRequests Uses

func ConfigInitialRequests() []*discovery.DiscoveryRequest

func XdsInitialRequests Uses

func XdsInitialRequests() []*discovery.DiscoveryRequest

type ADSC Uses

type ADSC struct {

    // InitialLoad tracks the time to receive the initial configuration.
    InitialLoad time.Duration

    // Metadata has the node metadata to send to pilot.
    // If nil, the defaults will be used.
    Metadata *pstruct.Struct

    // Updates includes the type of the last update received from the server.
    Updates     chan string
    XDSUpdates  chan *discovery.DiscoveryResponse
    VersionInfo map[string]string

    // Last received message, by type
    Received map[string]*discovery.DiscoveryResponse

    Mesh *v1alpha1.MeshConfig

    // Retrieved configurations can be stored using the common istio model interface.
    Store model.IstioConfigStore

    // Retrieved endpoints can be stored in the memory registry. This is used for CDS and EDS responses.
    Registry *memory.ServiceDiscovery

    // LocalCacheDir is set to a base name used to save fetched resources.
    // If set, each update will be saved.
    // TODO: also load at startup - so we can support warm up in init-container, and survive
    // restarts.
    LocalCacheDir string

    // RecvWg is for letting goroutines know when the goroutine handling the ADS stream finishes.
    RecvWg sync.WaitGroup

    Locality *core.Locality
    // contains filtered or unexported fields

ADSC implements a basic client for ADS, for use in stress tests and tools or libraries that need to connect to Istio pilot or other ADS servers.

func New Uses

func New(discoveryAddr string, opts *Config) (*ADSC, error)

New creates a new ADSC, maintaining a connection to an XDS server. Will: - get certificate using the Secret provider, if CertRequired - connect to the XDS server specified in ProxyConfig - send initial request for watched resources - wait for response from XDS server - on success, start a background thread to maintain the connection, with exp. backoff.

func (*ADSC) Close Uses

func (a *ADSC) Close()

Close the stream.

func (*ADSC) Dial Uses

func (a *ADSC) Dial() error

Dial connects to a ADS server, with optional MTLS authentication if a cert dir is specified.

func (*ADSC) EndpointsJSON Uses

func (a *ADSC) EndpointsJSON() string

EndpointsJSON returns the endpoints, formatted as JSON, for debugging.

func (*ADSC) GetClusters Uses

func (a *ADSC) GetClusters() map[string]*cluster.Cluster

GetClusters returns all the non-eds type clusters.

func (*ADSC) GetEdsClusters Uses

func (a *ADSC) GetEdsClusters() map[string]*cluster.Cluster

GetEdsClusters returns all the eds type clusters.

func (*ADSC) GetEndpoints Uses

func (a *ADSC) GetEndpoints() map[string]*endpoint.ClusterLoadAssignment

GetEndpoints returns all the routes.

func (*ADSC) GetHTTPListeners Uses

func (a *ADSC) GetHTTPListeners() map[string]*listener.Listener

GetHTTPListeners returns all the http listeners.

func (*ADSC) GetRoutes Uses

func (a *ADSC) GetRoutes() map[string]*route.RouteConfiguration

GetRoutes returns all the routes.

func (*ADSC) GetTCPListeners Uses

func (a *ADSC) GetTCPListeners() map[string]*listener.Listener

GetTCPListeners returns all the tcp listeners.

func (*ADSC) Run Uses

func (a *ADSC) Run() error

Run will create a new stream using the existing grpc client connection and send the initial xds requests. And then it will run a go routine receiving and handling xds response. Note: it is non blocking

func (*ADSC) Save Uses

func (a *ADSC) Save(base string) error

Save will save the json configs to files, using the base directory

func (*ADSC) Send Uses

func (a *ADSC) Send(req *discovery.DiscoveryRequest) error

Raw send of a request.

func (*ADSC) Wait Uses

func (a *ADSC) Wait(to time.Duration, updates ...string) ([]string, error)

Wait for an updates for all the specified types If updates is empty, this will wait for any update

func (*ADSC) WaitClear Uses

func (a *ADSC) WaitClear()

WaitClear will clear the waiting events, so next call to Wait will get the next push type.

func (*ADSC) WaitConfigSync Uses

func (a *ADSC) WaitConfigSync(max time.Duration) bool

WaitConfigSync will wait for the memory controller to sync.

func (*ADSC) WaitSingle Uses

func (a *ADSC) WaitSingle(to time.Duration, want string, reject string) error

WaitSingle waits for a single resource, and fails if the rejected type is returned. We avoid rejecting all other types to avoid race conditions. For example, a test asserting an incremental update of EDS may fail if a previous push's RDS response comes in later. Instead, we can reject events coming before (ie CDS). The only real alternative is to wait which introduces its own issues.

func (*ADSC) WaitVersion Uses

func (a *ADSC) WaitVersion(to time.Duration, typeURL, lastVersion string) (*discovery.DiscoveryResponse, error)

WaitVersion waits for a new or updated for a typeURL.

func (*ADSC) Watch Uses

func (a *ADSC) Watch()

Watch will start watching resources, starting with CDS. Based on the CDS response it will start watching RDS and LDS.

func (*ADSC) WatchConfig Uses

func (a *ADSC) WatchConfig()

WatchConfig will use the new experimental API watching, similar with MCP.

type Config Uses

type Config struct {
    // Namespace defaults to 'default'
    Namespace string

    // Workload defaults to 'test'
    Workload string

    // Meta includes additional metadata for the node
    Meta *pstruct.Struct

    Locality *core.Locality

    // NodeType defaults to sidecar. "ingress" and "router" are also supported.
    NodeType string

    // IP is currently the primary key used to locate inbound configs. It is sent by client,
    // must match a known endpoint IP. Tests can use a ServiceEntry to register fake IPs.
    IP  string

    // CertDir is the directory where mTLS certs are configured.
    // If CertDir and Secret are empty, an insecure connection will be used.
    // TODO: implement SecretManager for cert dir
    CertDir string

    // Secrets is the interface used for getting keys and rootCA.
    SecretManager security.SecretManager

    // For getting the certificate, using same code as SDS server.
    // Either the JWTPath or the certs must be present.
    JWTPath string

    // XDSSAN is the expected SAN of the XDS server. If not set, the ProxyConfig.DiscoveryAddress is used.
    XDSSAN string

    // XDSRootCAFile explicitly set the root CA to be used for the XDS connection.
    // Mirrors Envoy file.
    XDSRootCAFile string

    // RootCert contains the XDS root certificate. Used mainly for tests, apps will normally use
    // XDSRootCAFile
    RootCert []byte

    // InsecureSkipVerify skips client verification the server's certificate chain and host name.
    InsecureSkipVerify bool

    // InitialDiscoveryRequests is a list of resources to watch at first, represented as URLs (for new XDS resource naming)
    // or type URLs.
    InitialDiscoveryRequests []*discovery.DiscoveryRequest

    // BackoffPolicy determines the reconnect policy. Based on MCP client.
    BackoffPolicy backoff.BackOff

    // ResponseHandler will be called on each DiscoveryResponse.
    // TODO: mirror Generator, allow adding handler per type
    ResponseHandler ResponseHandler

    GrpcOpts []grpc.DialOption

Config for the ADS connection.

type ResponseHandler Uses

type ResponseHandler interface {
    HandleResponse(con *ADSC, response *discovery.DiscoveryResponse)

Package adsc imports 37 packages (graph) and is imported by 7 packages. Updated 2021-01-16. Refresh now. Tools for package owners.