envoy

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 323 Imported by: 0

Documentation

Overview

Package envoy implements utility routines related to Envoy proxy, and models an instance of a proxy to be able to generate XDS configurations for it.

Index

Constants

View Source
const (
	// HTTP filters
	HTTPConnectionManagerFilterName = "http_connection_manager"
	HTTPRouterFilterName            = "http_router"
	HTTPLuaFilterName               = "http_lua"

	HTTPExtAuthzFilterName    = "http_external_authz"
	HTTPHealthCheckFilterName = "http_health_check"

	// The HTTP typed filters referenced in the RDS configuration still need to
	// use wellknown names. These filters are configured as a map where the key is
	// the filter name and value is the marshalled filter config.
	// See https://github.com/envoyproxy/envoy/issues/21759#issuecomment-1163570994
	HTTPRBACFilterName           = "envoy.filters.http.rbac"
	HTTPLocalRateLimitFilterName = "envoy.filters.http.local_ratelimit"

	// Network (L4) filters
	TCPProxyFilterName         = "tcp_proxy"
	L4LocalRateLimitFilterName = "l4_local_rate_limit"
	L4RBACFilterName           = "l4_rbac"

	// Listener filters
	OriginalDstFilterName   = "original_dst"
	TLSInspectorFilterName  = "tls_inspector"
	HTTPInspectorFilterName = "http_inspector"
)

Filter names - can be any name (not used by Envoy to determine the filter to use) *Note: HTTP typed filters referenced in RDS require a wellknown name

View Source
const (
	HTTPRouterFilterTypeURL    = "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
	HTTPRBACFilterTypeURL      = "type.googleapis.com/envoy.extensions.filters.http.rbac.v3.RBAC"
	OriginalDstFilterTypeURL   = "type.googleapis.com/envoy.extensions.filters.listener.original_dst.v3.OriginalDst"
	TLSInspectorFilterTypeURL  = "type.googleapis.com/envoy.extensions.filters.listener.tls_inspector.v3.TlsInspector"
	HTTPInspectorFilterTypeURL = "type.googleapis.com/envoy.extensions.filters.listener.http_inspector.v3.HttpInspector"
)

Filter TypeURLs - used by Envoy to determine the filter to use

View Source
const (
	// EnvoyActiveHealthCheckPath is the HTTP endpoint to be used to receive
	// active health checks.
	EnvoyActiveHealthCheckPath = "/healthz/osm"

	// EnvoyActiveHealthCheckHeaderKey is the HTTP header key used to identify
	// active health check traffic.
	EnvoyActiveHealthCheckHeaderKey = "x-osm-envoy-healthcheck"
)
View Source
const (
	// TransportProtocolTLS is the TLS transport protocol used in Envoy configurations
	TransportProtocolTLS = "tls"

	// OutboundPassthroughCluster is the outbound passthrough cluster name
	OutboundPassthroughCluster = "passthrough-outbound"

	// AccessLoggerName is name used for the envoy access loggers.
	AccessLoggerName = "envoy.access_loggers.stream"
)

Variables

View Source
var ALPNInMesh = []string{"osm"}

ALPNInMesh indicates that the proxy is connecting to an in-mesh destination. It is set as a part of configuring the UpstreamTLSContext.

ValidURI defines valid URIs

View Source
var (
	// XDSResponseOrder is the order in which we send xDS responses: CDS, EDS, LDS, RDS
	// See: https://github.com/envoyproxy/go-control-plane/issues/59
	XDSResponseOrder = []TypeURI{TypeCDS, TypeEDS, TypeLDS, TypeRDS, TypeSDS}
)
View Source
var XDSShortURINames = map[TypeURI]string{
	TypeEmptyURI: "EmptyURI",
	TypeSDS:      "SDS",
	TypeCDS:      "CDS",
	TypeLDS:      "LDS",
	TypeRDS:      "RDS",
	TypeEDS:      "EDS",
}

XDSShortURINames are shortened versions of the URI types

Functions

func GetADSConfigSource

func GetADSConfigSource() *xds_core.ConfigSource

GetADSConfigSource creates an Envoy ConfigSource struct.

func GetAccessLog

func GetAccessLog() []*xds_accesslog_filter.AccessLog

GetAccessLog creates an Envoy AccessLog struct.

func GetAddress

func GetAddress(address string, port uint32) *xds_core.Address

GetAddress creates an Envoy Address struct.

func GetCIDRRangeFromStr added in v0.11.0

func GetCIDRRangeFromStr(cidr string) (*xds_core.CidrRange, error)

GetCIDRRangeFromStr converts the given CIDR as a string to an XDS CidrRange object

func GetDownstreamTLSContext

func GetDownstreamTLSContext(upstreamIdentity identity.ServiceIdentity, mTLS bool, sidecarSpec configv1alpha2.SidecarSpec) *xds_auth.DownstreamTlsContext

GetDownstreamTLSContext creates a downstream Envoy TLS Context to be configured on the upstream for the given upstream's identity Note: ServiceIdentity must be in the format "name.namespace" [https://github.com/openservicemesh/osm/issues/3188]

func GetEnvoyServiceNodeID added in v0.6.0

func GetEnvoyServiceNodeID(nodeID, workloadKind, workloadName string) string

GetEnvoyServiceNodeID creates the string for Envoy's "--service-node" CLI argument for the Kubernetes sidecar container Command/Args

func GetTLSParams

func GetTLSParams(sidecarSpec configv1alpha2.SidecarSpec) *xds_auth.TlsParameters

GetTLSParams creates Envoy TlsParameters struct.

func GetUpstreamTLSContext

func GetUpstreamTLSContext(downstreamIdentity identity.ServiceIdentity, upstreamSvc service.MeshService, sidecarSpec configv1alpha2.SidecarSpec) *xds_auth.UpstreamTlsContext

GetUpstreamTLSContext creates an upstream Envoy TLS Context for the given downstream identity and upstream service pair Note: ServiceIdentity must be in the format "name.namespace" [https://github.com/openservicemesh/osm/issues/3188]

func IsWildcardTypeURI added in v0.9.2

func IsWildcardTypeURI(t TypeURI) bool

IsWildcardTypeURI returns if a given TypeURI is an expected wildcard TypeURI or not. XDS proto defines general client behavior as: "Envoy will always use wildcard subscriptions for Listener and Cluster resources" https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#client-behavior

func NewXDSCertCNPrefix added in v1.2.0

func NewXDSCertCNPrefix(proxyUUID uuid.UUID, kind ProxyKind, si identity.ServiceIdentity) string

NewXDSCertCNPrefix returns a newly generated CommonName for a certificate of the form: <ProxyUUID>.<kind>.<identity> where identity itself is of the form <name>.<namespace>

Types

type PodMetadata added in v0.6.0

type PodMetadata struct {
	UID            string
	Name           string
	Namespace      string
	IP             string
	ServiceAccount identity.K8sServiceAccount
	Cluster        string
	EnvoyNodeID    string
	WorkloadKind   string
	WorkloadName   string
}

PodMetadata is a struct holding information on the Pod on which a given Envoy proxy is installed This struct is initialized *eventually*, when the metadata arrives via xDS.

func ParseEnvoyServiceNodeID added in v0.6.0

func ParseEnvoyServiceNodeID(serviceNodeID string) (*PodMetadata, error)

ParseEnvoyServiceNodeID parses the given Envoy service node ID and returns the encoded metadata

type Proxy

type Proxy struct {
	// UUID of the proxy
	uuid.UUID

	Identity identity.ServiceIdentity

	net.Addr

	// Records metadata around the Kubernetes Pod on which this Envoy Proxy is installed.
	// This could be nil if the Envoy is not operating in a Kubernetes cluster (VM for example)
	// NOTE: This field may be not be set at the time Proxy struct is initialized. This would
	// eventually be set when the metadata arrives via the xDS protocol.
	PodMetadata *PodMetadata
	// contains filtered or unexported fields
}

Proxy is a representation of an Envoy proxy connected to the xDS server. This should at some point have a 1:1 match to an Endpoint (which is a member of a meshed service).

func NewProxy

func NewProxy(kind ProxyKind, uuid uuid.UUID, svcIdentity identity.ServiceIdentity, ip net.Addr) *Proxy

NewProxy creates a new instance of an Envoy proxy connected to the xDS servers.

func (*Proxy) GetConnectedAt

func (p *Proxy) GetConnectedAt() time.Time

GetConnectedAt returns the timestamp of when the given proxy connected to the control plane.

func (*Proxy) GetIP

func (p *Proxy) GetIP() net.Addr

GetIP returns the IP address of the Envoy proxy connected to xDS.

func (*Proxy) GetLastAppliedVersion

func (p *Proxy) GetLastAppliedVersion(typeURI TypeURI) uint64

GetLastAppliedVersion returns the last version successfully applied to the given Envoy proxy.

func (*Proxy) GetLastResourcesSent added in v0.9.0

func (p *Proxy) GetLastResourcesSent(typeURI TypeURI) mapset.Set

GetLastResourcesSent returns a set of resources last sent for a proxy givne a TypeURL If none were sent, empty set is returned

func (*Proxy) GetLastSentNonce

func (p *Proxy) GetLastSentNonce(typeURI TypeURI) string

GetLastSentNonce returns last sent nonce.

func (*Proxy) GetLastSentVersion

func (p *Proxy) GetLastSentVersion(typeURI TypeURI) uint64

GetLastSentVersion returns the last sent version.

func (*Proxy) GetName added in v1.2.0

func (p *Proxy) GetName() string

GetName returns a unique name for this proxy based on the identity and uuid.

func (*Proxy) GetSubscribedResources added in v0.9.2

func (p *Proxy) GetSubscribedResources(typeURI TypeURI) mapset.Set

GetSubscribedResources returns a set of resources subscribed for a proxy given a TypeURL If none were subscribed, empty set is returned

func (*Proxy) HasPodMetadata added in v0.6.0

func (p *Proxy) HasPodMetadata() bool

HasPodMetadata answers the question - has the Pod metadata been recorded for the given Envoy proxy

func (*Proxy) IncrementLastSentVersion

func (p *Proxy) IncrementLastSentVersion(typeURI TypeURI) uint64

IncrementLastSentVersion increments last sent version.

func (*Proxy) Kind added in v0.10.0

func (p *Proxy) Kind() ProxyKind

Kind return the proxy's kind

func (*Proxy) PodMetadataString added in v0.10.0

func (p *Proxy) PodMetadataString() string

PodMetadataString returns relevant pod metadata as a string

func (*Proxy) SetLastAppliedVersion

func (p *Proxy) SetLastAppliedVersion(typeURI TypeURI, version uint64)

SetLastAppliedVersion records the version of the given Envoy proxy that was last acknowledged.

func (*Proxy) SetLastResourcesSent added in v0.9.0

func (p *Proxy) SetLastResourcesSent(typeURI TypeURI, resourcesSet mapset.Set)

SetLastResourcesSent sets the last sent resources given a proxy for a TypeURL

func (*Proxy) SetLastSentVersion

func (p *Proxy) SetLastSentVersion(typeURI TypeURI, ver uint64)

SetLastSentVersion records the version of the given config last sent to the proxy.

func (*Proxy) SetNewNonce

func (p *Proxy) SetNewNonce(typeURI TypeURI) string

SetNewNonce sets and returns a new nonce.

func (*Proxy) SetSubscribedResources added in v0.9.2

func (p *Proxy) SetSubscribedResources(typeURI TypeURI, resourcesSet mapset.Set)

SetSubscribedResources sets the input resources as subscribed resources given a proxy for a TypeURL

func (*Proxy) StatsHeaders added in v0.8.0

func (p *Proxy) StatsHeaders() map[string]string

StatsHeaders returns the headers required for SMI metrics

func (*Proxy) String

func (p *Proxy) String() string

type ProxyKind added in v0.10.0

type ProxyKind string

ProxyKind is the type used to define the proxy's kind

const (
	// KindSidecar implies the proxy is a sidecar
	KindSidecar ProxyKind = "sidecar"
)

type TypeURI

type TypeURI string

TypeURI is a string describing the Envoy xDS payload.

const (
	// TypeEmptyURI is an Empty URI type representation
	TypeEmptyURI TypeURI = ""

	// TypeSDS is the SDS type URI.
	TypeSDS TypeURI = "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret"

	// TypeCDS is the CDS type URI.
	TypeCDS TypeURI = "type.googleapis.com/envoy.config.cluster.v3.Cluster"

	// TypeLDS is the LDS type URI.
	TypeLDS TypeURI = "type.googleapis.com/envoy.config.listener.v3.Listener"

	// TypeRDS is the RDS type URI.
	TypeRDS TypeURI = "type.googleapis.com/envoy.config.route.v3.RouteConfiguration"

	// TypeEDS is the EDS type URI.
	TypeEDS TypeURI = "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"

	// TypeUpstreamTLSContext is an Envoy type URI.
	TypeUpstreamTLSContext TypeURI = "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext"

	// TypeZipkinConfig is an Envoy type URI.
	TypeZipkinConfig TypeURI = "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig"

	// TypeADS is not actually used by Envoy - but useful within OSM for logging
	TypeADS TypeURI = "ADS"
)

Envoy TypeURIs

func (TypeURI) Short added in v0.9.0

func (t TypeURI) Short() string

Short returns an abbreviated version of the TypeURI, which is easier to spot in logs and metrics.

func (TypeURI) String

func (t TypeURI) String() string

Directories

Path Synopsis
Package ads implements Envoy's Aggregated Discovery Service (ADS).
Package ads implements Envoy's Aggregated Discovery Service (ADS).
Package bootstrap implements functionality related to Envoy's bootstrap config.
Package bootstrap implements functionality related to Envoy's bootstrap config.
test
Package test implements utility routes to test the functionality provided by the injector package.
Package test implements utility routes to test the functionality provided by the injector package.
Package cds implements Envoy's Cluster Discovery Service (CDS).
Package cds implements Envoy's Cluster Discovery Service (CDS).
Package eds implements Envoy's Endpoint Discovery Service (EDS).
Package eds implements Envoy's Endpoint Discovery Service (EDS).
Package lds implements Envoy's Listener Discovery Service (LDS).
Package lds implements Envoy's Listener Discovery Service (LDS).
rds
Package rds implements Envoy's Route Discovery Service (RDS).
Package rds implements Envoy's Route Discovery Service (RDS).
route
Package route implements utility routines to build HTTP route configurations for Envoy proxies.
Package route implements utility routines to build HTTP route configurations for Envoy proxies.
Package sds implements Envoy's Secret Discovery Service (SDS).
Package sds implements Envoy's Secret Discovery Service (SDS).

Jump to

Keyboard shortcuts

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