xds

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

Contains functions to translate Kubernetes EndpointSlice resources into xDS server config.

Contains functions to translate Kubernetes Service resources into xDS server config

Index

Constants

View Source
const (

	// We use EmptyNodeID to create snapshots of kubernetes resources when there
	// are no nodes registered with the server. This will allow us to have a ready
	// to serve snapshot on new node requests and initialise new snapshots just by
	// copying the EmptyNodeID. Also, we can use it when exporting metrics to
	// reduce the amount of series and still expose metrics regarding the server's
	// snapshot resources.
	EmptyNodeID = ""
)

Variables

This section is empty.

Functions

func ExtractManagerFromListener

func ExtractManagerFromListener(listener *listenerv3.Listener) (*managerv3.HttpConnectionManager, error)

ExtractManagerFromListener unmarshals manager configuration from listener

func InitSnapMetricsCollector added in v0.4.0

func InitSnapMetricsCollector(snapshotter *Snapshotter)

func NewXdsEnpointStore added in v0.2.0

func NewXdsEnpointStore() *xdsEndpointStoreWrapper

NewServiceEnpointStore return a new ServiceEndpointStore

func NewXdsServiceStore added in v0.2.0

func NewXdsServiceStore() *xdsServiceStoreWrapper

NewXdsServiceStore return a new ServiceEndpointStore

func ParseClusterDiscoveryType

func ParseClusterDiscoveryType(discoveryType clusterv3.Cluster_DiscoveryType) string

ParseClusterDiscoveryType returns the Cluster Discovery type based on: https://pkg.go.dev/github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3#Cluster_DiscoveryType

func ParseClusterLbPolicy

func ParseClusterLbPolicy(policy clusterv3.Cluster_LbPolicy) string

ParseClusterLbPolicy returns the Cluster load balancing policy based on: https://pkg.go.dev/github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3#Cluster_LbPolicy

func ParseLbEndpointHealthStatus

func ParseLbEndpointHealthStatus(status corev3.HealthStatus) string

ParseLbEndpointHealthStatus returns the Lb Endpoint Health Status based on: https://pkg.go.dev/github.com/envoyproxy/go-control-plane@v0.10.3/envoy/config/core/v3#HealthStatus

func ParseNumRetries added in v0.3.0

func ParseNumRetries(num *uint32) *wrappers.UInt32Value

ParseNumRetries parses the number of retries.

func ParsePriorityStrategy added in v0.3.0

func ParsePriorityStrategy(strategy xdsTypes.PolicyStrategy) xdsTypes.PolicyStrategy

ParsePriorityStrategy parses priorityStrategy attribute

func ParseRetryBackOff added in v0.3.0

func ParseRetryBackOff(base, max string) *routev3.RetryPolicy_RetryBackOff

ParseRetryBackOff parses the retry backoff values. Default base is 25ms and the default max is 10x the base.

func ParseRetryOn added in v0.3.0

func ParseRetryOn(on []string) string

ParseRetryOn validates the retry_on value and returns it if valid.

func ParseToClusterLbPolicy added in v0.2.0

func ParseToClusterLbPolicy(policy string) clusterv3.Cluster_LbPolicy

parseToClusterLbPolicy is the reverse of the above. Accepts a string and returns a clusterv3.Cluster_LbPolicy.

func PrioritizeLocal added in v0.3.0

func PrioritizeLocal(strategy xdsTypes.PolicyStrategy) bool

PrioritizeLocal returns true if the strategy is set to local-first

func UnmarshalResourceToCluster

func UnmarshalResourceToCluster(res types.Resource) (*clusterv3.Cluster, error)

UnmarshalResourceToCluster parses configuration into a CLuster struct

func UnmarshalResourceToEndpoint

func UnmarshalResourceToEndpoint(res types.Resource) (*endpointv3.ClusterLoadAssignment, error)

UnmarshalResourceToEndpoint parses configuration into a ClusterLoadAssignment

func UnmarshalResourceToListener

func UnmarshalResourceToListener(res types.Resource) (*listenerv3.Listener, error)

UnmarshalResourceToListener parses a resource into a Listener

func UnmarshalResourceToRouteConfiguration

func UnmarshalResourceToRouteConfiguration(res types.Resource) (*routev3.RouteConfiguration, error)

UnmarshalResourceToRouteConfiguration parses a resource into RouteConfiguration

Types

type EdsCluster

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

EDSCluster holds the data to create an EDS cluster load assignment

type EdsClusterEndpoints

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

EdsClusterEndpoints will store EndpointSlice data needed in cluster creation

type EdsClusters

type EdsClusters map[string]EdsCluster

EdsClusters hold a map of EDS clusters

type Node added in v0.4.0

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

Node keeps the info for a node

type NodeSnapshotResources added in v0.4.0

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

NodeSnapshot keeps resources and versions to help snapshotting per node

type Service added in v0.3.0

type Service struct {
	EnableRemoteEndpoints    bool
	Policy                   clusterv3.Cluster_LbPolicy
	RingHash                 *clusterv3.Cluster_RingHashLbConfig
	RingHashPolicies         []*routev3.RouteAction_HashPolicy
	PrioritizeLocalEndpoints bool
	Service                  *v1.Service
	Retry                    *routev3.RetryPolicy
}

Service holds the data we need to represent a Kubernetes Service in xds configuration

type Snapshotter

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

func NewSnapshotter

func NewSnapshotter(port uint, requestLimit, streamRequestLimit float64) *Snapshotter

NewSnapshotter needs a grpc server port and the allowed requests limits per server and stream per second

func (*Snapshotter) EndpointsSnapshot

func (s *Snapshotter) EndpointsSnapshot(nodeID string) (cache.ResourceSnapshot, error)

func (*Snapshotter) ListenAndServe

func (s *Snapshotter) ListenAndServe()

ListenAndServeFromCache will start an xDS server at the given port and serve snapshots from the given cache

func (*Snapshotter) NodesMap added in v0.4.0

func (s *Snapshotter) NodesMap() map[string]string

NodesMap returns a map of node ids to addresses

func (*Snapshotter) OnDeltaStreamClosed

func (s *Snapshotter) OnDeltaStreamClosed(id int64, node *core.Node)

func (*Snapshotter) OnDeltaStreamOpen

func (s *Snapshotter) OnDeltaStreamOpen(ctx context.Context, id int64, typ string) error

func (*Snapshotter) OnFetchRequest

func (s *Snapshotter) OnFetchRequest(ctx context.Context, req *discovery.DiscoveryRequest) error

func (*Snapshotter) OnFetchResponse

func (s *Snapshotter) OnFetchResponse(req *discovery.DiscoveryRequest, resp *discovery.DiscoveryResponse)

func (*Snapshotter) OnStreamClosed

func (s *Snapshotter) OnStreamClosed(id int64, node *core.Node)

func (*Snapshotter) OnStreamDeltaRequest

func (s *Snapshotter) OnStreamDeltaRequest(i int64, request *discovery.DeltaDiscoveryRequest) error

func (*Snapshotter) OnStreamDeltaResponse

func (s *Snapshotter) OnStreamDeltaResponse(i int64, request *discovery.DeltaDiscoveryRequest, response *discovery.DeltaDiscoveryResponse)

func (*Snapshotter) OnStreamOpen

func (s *Snapshotter) OnStreamOpen(ctx context.Context, id int64, typ string) error

func (*Snapshotter) OnStreamRequest

func (s *Snapshotter) OnStreamRequest(id int64, r *discovery.DiscoveryRequest) error

func (*Snapshotter) OnStreamResponse

func (s *Snapshotter) OnStreamResponse(ctx context.Context, id int64, req *discovery.DiscoveryRequest, resp *discovery.DiscoveryResponse)

func (*Snapshotter) ServicesSnapshot

func (s *Snapshotter) ServicesSnapshot(nodeID string) (cache.ResourceSnapshot, error)

func (*Snapshotter) SnapEndpoints

func (s *Snapshotter) SnapEndpoints(endpointStore XdsEndpointStore) error

SnapEndpoints dumps the list of watched Kubernetes EndpointSlices into endoints snapshot

func (*Snapshotter) SnapServices

func (s *Snapshotter) SnapServices(serviceStore XdsServiceStore) error

SnapServices dumps the list of watched Kubernetes Services into services snapshot

type Stream added in v0.4.0

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

Stream will keep the peer address handy for logging and a rate limiter per stream

type XdsEndpointStore added in v0.2.0

type XdsEndpointStore interface {
	All() map[string]xdsEndpoint
	Add(service, namespace string, eps *discoveryv1.EndpointSlice, priority uint32)
	Get(service, namespace string) xdsEndpoint
	// contains filtered or unexported methods
}

XdsEndpointStore is a store of xdsEndpoint objects. It shall be used to populate a map of serviceEndpoint objects and passed to the snapshotter so only add and get functions should be implemented. For new snapshots we should create new stores

type XdsServiceStore added in v0.2.0

type XdsServiceStore interface {
	All() map[string]Service
	AddOrUpdate(service *v1.Service, xdsService Service)
	Get(service, namespace string) (Service, error)
	// contains filtered or unexported methods
}

XdsServiceStore is a store of xdsService objects. It's meant It to be used to populate a map of xdsService objects and passed to the snapshotter so only add and get functions should be implemented. For new snapshots we should create new stores

Jump to

Keyboard shortcuts

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