translation

package
v1.16.0-pre.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package translation building block for translation from model to CiliumEnvoyConfig, Service, etc. Translator is the interface to take the model and generate required CiliumEnvoyConfig, LoadBalancer Service, Endpoint, etc.

Additional, this package also contains a bare minimum constructors for common Envoy resources: - Cluster - Listener - HTTP Connection Manager - RouteConfiguration - VirtualHost

Each type of resource can be extended to support more features and use cases with mutation functions.

Index

Constants

View Source
const (
	AppProtocolH2C = "kubernetes.io/h2c"
	AppProtocolWS  = "kubernetes.io/ws"
	AppProtocolWSS = "kubernetes.io/wss"
)

Variables

This section is empty.

Functions

func NewHTTPCluster

func NewHTTPCluster(clusterName string, clusterServiceName string, mutationFunc ...ClusterMutator) (ciliumv2.XDSResource, error)

NewHTTPCluster creates a new Envoy cluster.

func NewHTTPConnectionManager

func NewHTTPConnectionManager(name, routeName string, mutationFunc ...HttpConnectionManagerMutator) (ciliumv2.XDSResource, error)

NewHTTPConnectionManager returns a new HTTP connection manager filter with the given name and route. Mutation functions can be passed to modify the filter based on the caller's needs.

func NewRouteConfiguration

func NewRouteConfiguration(name string, virtualhosts []*envoy_config_route_v3.VirtualHost, mutators ...RouteConfigurationMutator) (ciliumv2.XDSResource, error)

NewRouteConfiguration returns a new route configuration for a given list of http routes.

func NewTCPCluster

func NewTCPCluster(clusterName string, clusterServiceName string, mutationFunc ...ClusterMutator) (ciliumv2.XDSResource, error)

NewTCPCluster creates a new Envoy cluster.

func NewTCPClusterWithDefaults

func NewTCPClusterWithDefaults(clusterName string, clusterServiceName string, mutationFunc ...ClusterMutator) (ciliumv2.XDSResource, error)

NewTCPClusterWithDefaults same as NewTCPCluster but has default mutation functions applied. currently this is only used for TLSRoutes to create a passthrough proxy

func NewVirtualHost

func NewVirtualHost(httpRoutes []model.HTTPRoute, param VirtualHostParameter, mutators ...VirtualHostMutator) (*envoy_config_route_v3.VirtualHost, error)

NewVirtualHost creates a new VirtualHost with the given host and routes.

func NewVirtualHostWithDefaults

func NewVirtualHostWithDefaults(httpRoutes []model.HTTPRoute, param VirtualHostParameter, mutators ...VirtualHostMutator) (*envoy_config_route_v3.VirtualHost, error)

NewVirtualHostWithDefaults is same as NewVirtualHost but with a few default mutator function. If there are multiple http routes having the same path matching (e.g. exact, prefix or regex), the incoming request will be load-balanced to multiple backends equally.

func ParseNodeLabelSelector added in v1.16.0

func ParseNodeLabelSelector(nodeLabelSelectorString string) *slim_metav1.LabelSelector

ParseNodeLabelSelector parses a given string representation of a label selector into a metav1.LabelSelector. The representation is a comma-separated list of key-value pairs (key1=value1,key2=value2) that is used as MatchLabels. Values not matching these rules are skipped.

Types

type CECTranslator added in v1.16.0

type CECTranslator interface {
	// WithUseAlpn enables ALPN
	WithUseAlpn(useAlpn bool)
	// Translate translates the model to CiliumEnvoyConfig.
	Translate(namespace string, name string, model *model.Model) (*ciliumv2.CiliumEnvoyConfig, error)
}

CECTranslator is the interface to take the model and generate required CiliumEnvoyConfig. It might be used as the base for other Translator implementations.

func NewCECTranslator added in v1.16.0

func NewCECTranslator(secretsNamespace string, useProxyProtocol bool, useAppProtocol bool, hostNameSuffixMatch bool, idleTimeoutSeconds int,
	hostNetworkEnabled bool, hostNetworkNodeLabelSelector *slim_metav1.LabelSelector, ipv4Enabled bool, ipv6Enabled bool,
	xffNumTrustedHops uint32,
) CECTranslator

NewCECTranslator returns a new translator

type ClusterMutator

func WithClusterLbPolicy

func WithClusterLbPolicy(lbPolicy int32) ClusterMutator

WithClusterLbPolicy sets the cluster's load balancing policy. https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers

func WithConnectionTimeout

func WithConnectionTimeout(seconds int) ClusterMutator

WithConnectionTimeout sets the cluster's connection timeout.

func WithIdleTimeout

func WithIdleTimeout(seconds int) ClusterMutator

WithIdleTimeout sets the cluster's connection idle timeout.

func WithOutlierDetection

func WithOutlierDetection(splitExternalLocalOriginErrors bool) ClusterMutator

WithOutlierDetection enables outlier detection on the cluster.

func WithProtocol added in v1.15.0

func WithProtocol(protocolVersion HTTPVersionType) ClusterMutator

type HTTPVersionType added in v1.15.0

type HTTPVersionType int
const (
	HTTPVersionDownstream HTTPVersionType = -1
	HTTPVersionAuto       HTTPVersionType = 0
	HTTPVersion1          HTTPVersionType = 1
	HTTPVersion2          HTTPVersionType = 2
	HTTPVersion3          HTTPVersionType = 3
)

type ListenerMutator

func WithAlpn added in v1.16.0

func WithAlpn() ListenerMutator

func WithHostNetworkPort added in v1.16.0

func WithHostNetworkPort(m *model.Model, ipv4Enabled bool, ipv6Enabled bool) ListenerMutator

func WithProxyProtocol added in v1.15.0

func WithProxyProtocol() ListenerMutator

func WithSocketOption

func WithSocketOption(tcpKeepAlive, tcpKeepIdleInSeconds, tcpKeepAliveProbeIntervalInSeconds, tcpKeepAliveMaxFailures int64) ListenerMutator

func WithXffNumTrustedHops added in v1.15.0

func WithXffNumTrustedHops(xff uint32) ListenerMutator

type SortableRoute

type SortableRoute []*envoy_config_route_v3.Route

SortableRoute is a slice of envoy Route, which can be sorted based on matching order as per Ingress requirement.

The sorting order is as follows, continuing on ties, and also noting that when Exact, Regex, or Prefix matches are unset, their length is zero:

  • Exact Match length
  • Regex Match length
  • Prefix match length
  • Number of header matches
  • Number of query parameter matches

As Envoy route matching logic is done sequentially, we need to enforce such sorting order.

func (SortableRoute) Len

func (s SortableRoute) Len() int

func (SortableRoute) Less

func (s SortableRoute) Less(i, j int) bool

func (SortableRoute) Swap

func (s SortableRoute) Swap(i, j int)

type Translator

type Translator interface {
	Translate(model *model.Model) (*ciliumv2.CiliumEnvoyConfig, *corev1.Service, *corev1.Endpoints, error)
}

Translator is the interface to take the model and generate required CiliumEnvoyConfig, LoadBalancer Service, Endpoint, etc.

Different use cases (e.g. Ingress, Gateway API) can provide its own generation logic.

type VirtualHostParameter

type VirtualHostParameter struct {
	HostNames           []string
	HTTPSRedirect       bool
	HostNameSuffixMatch bool
	ListenerPort        uint32
}

VirtualHostParameter is the parameter for NewVirtualHost

Directories

Path Synopsis
Package ingress contains the translation logic from Ingress to CiliumEnvoyConfig and related resources.
Package ingress contains the translation logic from Ingress to CiliumEnvoyConfig and related resources.

Jump to

Keyboard shortcuts

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