uxds

package module
v0.0.0-...-f25926c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EndpointType        = apiTypePrefix + "envoy.config.endpoint.v3.ClusterLoadAssignment"
	ClusterType         = apiTypePrefix + "envoy.config.cluster.v3.Cluster"
	RouteType           = apiTypePrefix + "envoy.config.route.v3.RouteConfiguration"
	ScopedRouteType     = apiTypePrefix + "envoy.config.route.v3.ScopedRouteConfiguration"
	ListenerType        = apiTypePrefix + "envoy.config.listener.v3.Listener"
	SecretType          = apiTypePrefix + "envoy.extensions.transport_sockets.tls.v3.Secret"
	ExtensionConfigType = apiTypePrefix + "envoy.config.core.v3.TypedExtensionConfig"
	RuntimeType         = apiTypePrefix + "envoy.service.runtime.v3.Runtime"

	// AnyType is used only by ADS
	AnyType = ""
)

Resource types in xDS v3.

View Source
const (
	ReasonAck     = "ack"
	ReasonRequest = "request"
	ReasonInit    = "init"
)

Variables

View Source
var Debug = false
View Source
var ErrTimeout = errors.New("timeout")

ErrTimeout is returned by Wait if no update is received in the given time.

Functions

func GetCertificate

func GetCertificate(ctx context.Context, id *auth.MeshAuth, ca *hbone.Cluster) error

getCertificate is using Istio CA gRPC protocol to get a certificate for the id. Google implementation of the protocol is also supported.

func HandleCDS

func HandleCDS(hb *hbone.HBone, eds map[string]*xds.Cluster)

func HandleEDS

func HandleEDS(hb *hbone.HBone, eds map[string]*xds.ClusterLoadAssignment)

func SetupControlPlane

func SetupControlPlane(ctx context.Context, hb *hbone.HBone, c *hbone.Cluster) error

Example Istio: testdata/clusterloadassignment.json

Types

type ADSC

type ADSC struct {

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

	// HTTPListeners contains received listeners with a http_connection_manager filter.
	HTTPListeners map[string]*xds.Listener

	// TCPListeners contains all listeners of type TCP (not-HTTP)
	TCPListeners map[string]*xds.Listener

	// All received Clusters of no-eds type, keyed by name
	Clusters map[string]*xds.Cluster

	// All received Routes, keyed by route name
	Routes map[string]*xds.RouteConfiguration

	// All received endpoints, keyed by cluster name
	Endpoints map[string]*xds.ClusterLoadAssignment

	// Metadata has the node metadata to send to pilot.
	// If nil, the defaults will be used.
	Metadata map[string]interface{}
	Config   *Config

	// Updates includes the type of the last update received from the server, or "close".
	// Short names for eds/cds/lds/rds, as well as init, error-xxxx, long names for other types.
	Updates chan string

	XDSUpdates chan *xds.DiscoveryResponse

	VersionInfo map[string]string

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

	// 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
	// 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 Dial

func Dial(url string, opts *Config) (*ADSC, error)

func DialContext

func DialContext(ctx context.Context, url string, opts *Config) (*ADSC, error)

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

func (*ADSC) Close

func (a *ADSC) Close()

Close the stream.

func (*ADSC) Run

func (a *ADSC) Run() error

Run will run the ADS client.

func (*ADSC) Send

func (a *ADSC) Send(dr *xds.DiscoveryRequest) error

func (*ADSC) Wait

func (a *ADSC) Wait(update string, to time.Duration) (string, error)

Wait for an update of the specified type. If type is empty, wait for next update.

func (*ADSC) WaitClear

func (a *ADSC) WaitClear()

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

type Config

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

	// Workload defaults to 'test'
	Workload string

	// Revision for this control plane instance. We will only read configs that match this revision.
	Revision string

	// Meta includes additional metadata for the node
	Meta map[string]interface{}

	Locality *xds.Locality

	XDSHeaders map[string]string

	// 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

	// Context used for early cancellation
	Context context.Context

	NodeId string

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

	// ResponseHandler will be called on each DiscoveryResponse.
	// TODO: mirror Generator, allow adding handler per type
	ResponseHandler func(con *ADSC, response *xds.DiscoveryResponse)

	HBone   *hbone.HBone
	Cluster *hbone.Cluster
}

Config for the ADS connection.

type Endpoint

type Endpoint struct {
	// Weight extracted from EDS
	Weight int
}

type TCPListener

type TCPListener struct {
	// Address is the address, as expected by go Dial and Listen, including port
	Address string

	// LogFile is the access log address for the listener
	LogFile string

	// Target is the destination cluster.
	Target string
}

TCPListener extracts the core elements from envoy Listener.

type Target

type Target struct {

	// Address is a go address, extracted from the mangled cluster name.
	Address string

	// Endpoints are the resolved endpoints from EDS or cluster static.
	Endpoints map[string]Endpoint
}

type Watch

type Watch struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
google
istio

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL