core

package
v0.0.0-...-7929486 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 115 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// EnvoyServerName for istio's envoy
	EnvoyServerName = "istio-envoy"

	// EnvoyAccessLogCluster is the cluster name that has details for server implementing Envoy ALS.
	// This cluster is created in bootstrap.
	EnvoyAccessLogCluster = "envoy_accesslog_service"
)
View Source
const (
	NoConflict = iota
	// HTTPOverTCP represents incoming HTTP existing TCP
	HTTPOverTCP
	// TCPOverHTTP represents incoming TCP existing HTTP
	TCPOverHTTP
	// TCPOverTCP represents incoming TCP existing TCP
	TCPOverTCP
	// TCPOverAuto represents incoming TCP existing AUTO
	TCPOverAuto
	// AutoOverHTTP represents incoming AUTO existing HTTP
	AutoOverHTTP
	// AutoOverTCP represents incoming AUTO existing TCP
	AutoOverTCP
)
View Source
const (
	// WildcardAddress binds to all IP addresses
	WildcardAddress = "0.0.0.0"

	// WildcardIPv6Address binds to all IPv6 addresses
	WildcardIPv6Address = "::"

	// LocalhostAddress for local binding
	LocalhostAddress = "127.0.0.1"

	// LocalhostIPv6Address for local binding
	LocalhostIPv6Address = "::1"

	// 6 is the magical number for inbound: 15006, 127.0.0.6, ::6
	InboundPassthroughBindIpv4 = "127.0.0.6"
	InboundPassthroughBindIpv6 = "::6"
)
View Source
const (
	// ConnectTerminate is the name for the resources associated with the termination of HTTP CONNECT.
	ConnectTerminate = "connect_terminate"

	// MainInternalName is the name for the resources associated with the main (non-tunnel) internal listener.
	MainInternalName = "main_internal"

	// ConnectOriginate is the name for the resources associated with the origination of HTTP CONNECT.
	ConnectOriginate = "connect_originate"

	// EncapClusterName is the name of the cluster used for traffic to the connect_originate listener.
	EncapClusterName = "encap"

	// ConnectUpgradeType is the type of upgrade for HTTP CONNECT.
	ConnectUpgradeType = "CONNECT"
)

Variables

View Source
var (
	Separator = []byte{'~'}
	Slash     = []byte{'/'}
)
View Source
var (
	GetMainInternalCluster = func() *cluster.Cluster {
		return buildInternalUpstreamCluster(MainInternalName, MainInternalName)
	}

	GetEncapCluster = func() *cluster.Cluster {
		return buildInternalUpstreamCluster(EncapClusterName, ConnectOriginate)
	}
)

Functions

func ApplyRingHashLoadBalancer

func ApplyRingHashLoadBalancer(c *cluster.Cluster, lb *networking.LoadBalancerSettings)

ApplyRingHashLoadBalancer will set the LbPolicy and create an LbConfig for RING_HASH if used in LoadBalancerSettings

func BuildListenerTLSContext

func BuildListenerTLSContext(serverTLSSettings *networking.ServerTLSSettings,
	proxy *model.Proxy, mesh *meshconfig.MeshConfig, transportProtocol istionetworking.TransportProtocol, gatewayTCPServerWithTerminatingTLS bool,
) *auth.DownstreamTlsContext

func BuildSidecarOutboundVirtualHosts

func BuildSidecarOutboundVirtualHosts(node *model.Proxy, push *model.PushContext,
	routeName string,
	listenerPort int,
	efKeys []string,
	xdsCache model.XdsCache,
) ([]*route.VirtualHost, *discovery.Resource, *istio_route.Cache)

func CastDestinationRule

func CastDestinationRule(config *config.Config) *networking.DestinationRule

CastDestinationRule returns the destination rule enclosed by the config, if not null. Otherwise, return nil.

func ExtractRoutesFromListeners

func ExtractRoutesFromListeners(ll []*listener.Listener) []string

copied from xdstest to avoid import issues

func GenerateAltVirtualHosts

func GenerateAltVirtualHosts(hostname string, port int, proxyDomain string) []string

GenerateAltVirtualHosts given a service and a port, generates all possible HTTP Host headers. For example, a service of the form foo.local.campus.net on port 80, with local domain "local.campus.net" could be accessed as http://foo:80 within the .local network, as http://foo.local:80 (by other clients in the campus.net domain), as http://foo.local.campus:80, etc. NOTE: When a sidecar in remote.campus.net domain is talking to foo.local.campus.net, we should only generate foo.local, foo.local.campus, etc (and never just "foo").

- Given foo.local.campus.net on proxy domain local.campus.net, this function generates foo:80, foo.local:80, foo.local.campus:80, with and without ports. It will not generate foo.local.campus.net (full hostname) since its already added elsewhere.

- Given foo.local.campus.net on proxy domain remote.campus.net, this function generates foo.local:80, foo.local.campus:80

- Given foo.local.campus.net on proxy domain "" or proxy domain example.com, this function returns nil

func SidecarIgnorePort

func SidecarIgnorePort(node *model.Proxy) bool

Types

type AccessLogBuilder

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

type ClusterBuilder

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

ClusterBuilder interface provides an abstraction for building Envoy Clusters.

func NewClusterBuilder

func NewClusterBuilder(proxy *model.Proxy, req *model.PushRequest, cache model.XdsCache) *ClusterBuilder

NewClusterBuilder builds an instance of ClusterBuilder.

type ClusterMode

type ClusterMode string

ClusterMode defines whether the cluster is being built for SNI-DNATing (sni passthrough) or not

const (
	// SniDnatClusterMode indicates cluster is being built for SNI dnat mode
	SniDnatClusterMode ClusterMode = "sni-dnat"
	// DefaultClusterMode indicates usual cluster with mTLS et al
	DefaultClusterMode ClusterMode = "outbound"
)

type ConfigGenTest

type ConfigGenTest struct {
	ConfigGen            *ConfigGeneratorImpl
	MemRegistry          *memregistry.ServiceDiscovery
	ServiceEntryRegistry *serviceentry.Controller
	Registry             model.Controller

	MemServiceRegistry serviceregistry.Simple
	// contains filtered or unexported fields
}

func NewConfigGenTest

func NewConfigGenTest(t test.Failer, opts TestOptions) *ConfigGenTest

func (*ConfigGenTest) Clusters

func (f *ConfigGenTest) Clusters(p *model.Proxy) []*cluster.Cluster

func (*ConfigGenTest) DeltaClusters

func (f *ConfigGenTest) DeltaClusters(
	p *model.Proxy,
	configUpdated sets.Set[model.ConfigKey],
	watched *model.WatchedResource,
) ([]*cluster.Cluster, []string, bool)

func (*ConfigGenTest) Env

func (f *ConfigGenTest) Env() *model.Environment

func (*ConfigGenTest) Listeners

func (f *ConfigGenTest) Listeners(p *model.Proxy) []*listener.Listener

func (*ConfigGenTest) PushContext

func (f *ConfigGenTest) PushContext() *model.PushContext

func (*ConfigGenTest) Routes

func (*ConfigGenTest) RoutesFromListeners

func (f *ConfigGenTest) RoutesFromListeners(p *model.Proxy, l []*listener.Listener) []*route.RouteConfiguration

func (*ConfigGenTest) Run

func (f *ConfigGenTest) Run()

func (*ConfigGenTest) SetupProxy

func (f *ConfigGenTest) SetupProxy(p *model.Proxy) *model.Proxy

SetupProxy initializes a proxy for the current environment. This should generally be used when creating any proxy. For example, `p := SetupProxy(&model.Proxy{...})`.

func (*ConfigGenTest) Store

type ConfigGenerator

type ConfigGenerator interface {
	// BuildListeners returns the list of inbound/outbound listeners for the given proxy. This is the LDS output
	// Internally, the computation will be optimized to ensure that listeners are computed only
	// once and shared across multiple invocations of this function.
	BuildListeners(node *model.Proxy, push *model.PushContext) []*listener.Listener

	// BuildClusters returns the list of clusters for the given proxy. This is the CDS output
	BuildClusters(node *model.Proxy, req *model.PushRequest) ([]*discovery.Resource, model.XdsLogDetails)

	// BuildDeltaClusters returns both a list of resources that need to be pushed for a given proxy and a list of resources
	// that have been deleted and should be removed from a given proxy. This is Delta CDS output.
	BuildDeltaClusters(proxy *model.Proxy, updates *model.PushRequest,
		watched *model.WatchedResource) ([]*discovery.Resource, []string, model.XdsLogDetails, bool)

	// BuildHTTPRoutes returns the list of HTTP routes for the given proxy. This is the RDS output
	BuildHTTPRoutes(node *model.Proxy, req *model.PushRequest, routeNames []string) ([]*discovery.Resource, model.XdsLogDetails)

	// BuildNameTable returns list of hostnames and the associated IPs
	BuildNameTable(node *model.Proxy, push *model.PushContext) *dnsProto.NameTable

	// BuildExtensionConfiguration returns the list of extension configuration for the given proxy and list of names. This is the ECDS output.
	BuildExtensionConfiguration(node *model.Proxy, push *model.PushContext, extensionConfigNames []string,
		pullSecrets map[string][]byte) []*core.TypedExtensionConfig

	// MeshConfigChanged is invoked when mesh config is changed, giving a chance to rebuild any cached config.
	MeshConfigChanged(mesh *meshconfig.MeshConfig)
}

ConfigGenerator represents the interfaces to be implemented by code that generates xDS responses

type ConfigGeneratorImpl

type ConfigGeneratorImpl struct {
	Cache model.XdsCache
}

func NewConfigGenerator

func NewConfigGenerator(cache model.XdsCache) *ConfigGeneratorImpl

func (*ConfigGeneratorImpl) BuildClusters

func (configgen *ConfigGeneratorImpl) BuildClusters(proxy *model.Proxy, req *model.PushRequest) ([]*discovery.Resource, model.XdsLogDetails)

BuildClusters returns the list of clusters for the given proxy. This is the CDS output For outbound: Cluster for each service/subset hostname or cidr with SNI set to service hostname Cluster type based on resolution For inbound (sidecar only): Cluster for each inbound endpoint port and for each service port

func (*ConfigGeneratorImpl) BuildDeltaClusters

func (configgen *ConfigGeneratorImpl) BuildDeltaClusters(proxy *model.Proxy, updates *model.PushRequest,
	watched *model.WatchedResource,
) ([]*discovery.Resource, []string, model.XdsLogDetails, bool)

BuildDeltaClusters generates the deltas (add and delete) for a given proxy. Currently, only service changes are reflected with deltas. Otherwise, we fall back onto generating everything.

func (*ConfigGeneratorImpl) BuildExtensionConfiguration

func (configgen *ConfigGeneratorImpl) BuildExtensionConfiguration(
	proxy *model.Proxy, push *model.PushContext, extensionConfigNames []string, pullSecrets map[string][]byte,
) []*core.TypedExtensionConfig

BuildExtensionConfiguration returns the list of extension configuration for the given proxy and list of names. This is the ECDS output.

func (*ConfigGeneratorImpl) BuildHTTPRoutes

func (configgen *ConfigGeneratorImpl) BuildHTTPRoutes(
	node *model.Proxy,
	req *model.PushRequest,
	routeNames []string,
) ([]*discovery.Resource, model.XdsLogDetails)

BuildHTTPRoutes produces a list of routes for the proxy

func (*ConfigGeneratorImpl) BuildListeners

func (configgen *ConfigGeneratorImpl) BuildListeners(node *model.Proxy,
	push *model.PushContext,
) []*listener.Listener

BuildListeners produces a list of listeners and referenced clusters for all proxies

func (*ConfigGeneratorImpl) BuildNameTable

func (configgen *ConfigGeneratorImpl) BuildNameTable(node *model.Proxy, push *model.PushContext) *dnsProto.NameTable

BuildNameTable produces a table of hostnames and their associated IPs that can then be used by the agent to resolve DNS. This logic is always active. However, local DNS resolution will only be effective if DNS capture is enabled in the proxy

func (*ConfigGeneratorImpl) MeshConfigChanged

func (configgen *ConfigGeneratorImpl) MeshConfigChanged(_ *meshconfig.MeshConfig)

MeshConfigChanged is called when mesh config is changed.

type FilterChainMatchOptions

type FilterChainMatchOptions struct {
	// Application protocols of the filter chain match
	ApplicationProtocols []string
	// Transport protocol of the filter chain match. "tls" or empty
	TransportProtocol string
	// Filter chain protocol. HTTP for HTTP proxy and TCP for TCP proxy
	Protocol networking.ListenerProtocol
	// Whether this chain should terminate TLS or not
	TLS bool
}

FilterChainMatchOptions describes options used for filter chain matches.

func (FilterChainMatchOptions) ToTransportSocket

func (opt FilterChainMatchOptions) ToTransportSocket(mtls authn.MTLSSettings) *tls.DownstreamTlsContext

type ListenerBuilder

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

A stateful listener builder Support the below intentions 1. Use separate inbound capture listener(:15006) and outbound capture listener(:15001) 2. The above listeners use bind_to_port sub listeners or filter chains.

func NewListenerBuilder

func NewListenerBuilder(node *model.Proxy, push *model.PushContext) *ListenerBuilder

type MutableGatewayListener

type MutableGatewayListener struct {
	// Listener is the listener being built.
	Listener *listener.Listener
}

MutableGatewayListener represents a listener that is being built. Historically, this was used for all listener building. At this point, outbound and inbound have specialized code. This only applies to gateways now.

type ProxyHeaders

type ProxyHeaders struct {
	ServerName                 string
	ServerHeaderTransformation hcm.HttpConnectionManager_ServerHeaderTransformation
	ForwardedClientCert        hcm.HttpConnectionManager_ForwardClientCertDetails
	SetCurrentCertDetails      *meshconfig.ProxyConfig_ProxyHeaders_SetCurrentClientCertDetails
	IncludeRequestAttemptCount bool
	GenerateRequestID          *wrappers.BoolValue
	SuppressDebugHeaders       bool
	SkipIstioMXHeaders         bool
}

func GetProxyHeaders

func GetProxyHeaders(node *model.Proxy, push *model.PushContext, class istionetworking.ListenerClass) ProxyHeaders

type TestOptions

type TestOptions struct {
	// If provided, these configs will be used directly
	Configs        []config.Config
	ConfigPointers []*config.Config

	// If provided, the yaml string will be parsed and used as configs
	ConfigString string
	// If provided, the ConfigString will be treated as a go template, with this as input params
	ConfigTemplateInput any

	// Services to pre-populate as part of the service discovery
	Services  []*model.Service
	Instances []*model.ServiceInstance
	Gateways  []model.NetworkGateway

	// If provided, this mesh config will be used
	MeshConfig      *meshconfig.MeshConfig
	NetworksWatcher mesh.NetworksWatcher

	// Additional service registries to use. A ServiceEntry and memory registry will always be created.
	ServiceRegistries []serviceregistry.Instance

	// Base ConfigController to use. If not set, a in-memory store will be used
	ConfigController model.ConfigStoreController

	// Additional ConfigStoreController to use
	ConfigStoreCaches []model.ConfigStoreController

	// CreateConfigStore defines a function that, given a ConfigStoreController, returns another ConfigStoreController to use
	CreateConfigStore func(c model.ConfigStoreController) model.ConfigStoreController

	// If set, we will not run immediately, allowing adding event handlers, etc prior to start.
	SkipRun bool

	// Used to set the serviceentry registry's cluster id
	ClusterID cluster2.ID

	// XDSUpdater to use. Otherwise, our own will be used
	XDSUpdater model.XDSUpdater
}

func (TestOptions) FuzzValidate

func (to TestOptions) FuzzValidate() bool

Directories

Path Synopsis
packages used for load balancer setting
packages used for load balancer setting

Jump to

Keyboard shortcuts

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