dataplane

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package dataplane translates Graph representation of the cluster state into an intermediate representation of data plane configuration. We can think of it as an intermediate state between the cluster resources and NGINX configuration files.

The package includes: - The types to hold the intermediate representation. - The functions to translate the Graph into the representation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// VerifyTLS holds the backend TLS verification configuration.
	VerifyTLS *VerifyTLS
	// UpstreamName is the name of the upstream for this backend.
	UpstreamName string
	// Weight is the weight of the BackendRef.
	// The possible values of weight are 0-1,000,000.
	// If weight is 0, no traffic should be forwarded for this entry.
	Weight int32
	// Valid indicates whether the Backend is valid.
	Valid bool
}

Backend represents a Backend for a routing rule.

type BackendGroup

type BackendGroup struct {
	// Source is the NamespacedName of the HTTPRoute the group belongs to.
	Source types.NamespacedName
	// Backends is a list of Backends in the Group.
	Backends []Backend
	// RuleIdx is the index of the corresponding rule in the HTTPRoute.
	RuleIdx int
}

BackendGroup represents a group of Backends for a routing rule in an HTTPRoute.

func (*BackendGroup) Name

func (bg *BackendGroup) Name() string

Name returns the name of the backend group. This name must be unique across all HTTPRoutes and all rules within the same HTTPRoute. The RuleIdx is used to make the name unique across all rules within the same HTTPRoute. The RuleIdx may change for a given rule if an update is made to the HTTPRoute, but it will always match the index of the rule in the stored HTTPRoute.

type CertBundle added in v1.2.0

type CertBundle []byte

CertBundle is a Certificate bundle.

type CertBundleID added in v1.2.0

type CertBundleID string

CertBundleID is a unique identifier for a Certificate bundle. The ID is safe to use as a file name.

type Configuration

type Configuration struct {
	// SSLKeyPairs holds all unique SSLKeyPairs.
	SSLKeyPairs map[SSLKeyPairID]SSLKeyPair
	// CertBundles holds all unique Certificate Bundles.
	CertBundles map[CertBundleID]CertBundle
	// HTTPServers holds all HTTPServers.
	HTTPServers []VirtualServer
	// SSLServers holds all SSLServers.
	SSLServers []VirtualServer
	// Upstreams holds all unique Upstreams.
	Upstreams []Upstream
	// BackendGroups holds all unique BackendGroups.
	BackendGroups []BackendGroup
	// Version represents the version of the generated configuration.
	Version int
}

Configuration is an intermediate representation of dataplane configuration.

func BuildConfiguration

func BuildConfiguration(
	ctx context.Context,
	g *graph.Graph,
	resolver resolver.ServiceResolver,
	configVersion int,
) Configuration

BuildConfiguration builds the Configuration from the Graph.

type HTTPFilters

type HTTPFilters struct {
	// InvalidFilter is a special filter that indicates whether the filters are invalid. If this is the case,
	// the data plane must return 500 error, and all other filters are nil.
	InvalidFilter *InvalidHTTPFilter
	// RequestRedirect holds the HTTPRequestRedirectFilter.
	RequestRedirect *HTTPRequestRedirectFilter
	// RequestURLRewrite holds the HTTPURLRewriteFilter.
	RequestURLRewrite *HTTPURLRewriteFilter
	// RequestHeaderModifiers holds the HTTPHeaderFilter.
	RequestHeaderModifiers *HTTPHeaderFilter
}

HTTPFilters hold the filters for a MatchRule.

type HTTPHeader

type HTTPHeader struct {
	// Name is the name of the header.
	Name string
	// Value is the value of the header.
	Value string
}

HTTPHeader represents an HTTP header.

type HTTPHeaderFilter

type HTTPHeaderFilter struct {
	// Set adds or replaces headers.
	Set []HTTPHeader
	// Add adds headers. It appends to any existing values associated with a header name.
	Add []HTTPHeader
	// Remove removes headers.
	Remove []string
}

HTTPHeaderFilter manipulates HTTP headers.

type HTTPHeaderMatch

type HTTPHeaderMatch struct {
	// Name is the name of the header to match.
	Name string
	// Value is the value of the header to match.
	Value string
}

HTTPHeaderMatch matches an HTTP header.

type HTTPPathModifier added in v1.2.0

type HTTPPathModifier struct {
	// Replacement specifies the value with which to replace the full path or prefix match of a request during
	// a rewrite or redirect.
	Replacement string
	// Type indicates the type of path modifier.
	Type PathModifierType
}

HTTPPathModifier defines configuration for path modifiers.

type HTTPQueryParamMatch

type HTTPQueryParamMatch struct {
	// Name is the name of the query parameter to match.
	Name string
	// Value is the value of the query parameter to match.
	Value string
}

HTTPQueryParamMatch matches an HTTP query parameter.

type HTTPRequestRedirectFilter

type HTTPRequestRedirectFilter struct {
	// Scheme is the scheme of the redirect.
	Scheme *string
	// Hostname is the hostname of the redirect.
	Hostname *string
	// Port is the port of the redirect.
	Port *int32
	// StatusCode is the HTTP status code of the redirect.
	StatusCode *int
}

HTTPRequestRedirectFilter redirects HTTP requests.

type HTTPURLRewriteFilter added in v1.2.0

type HTTPURLRewriteFilter struct {
	// Hostname is the hostname of the rewrite.
	Hostname *string
	// Path is the path of the rewrite.
	Path *HTTPPathModifier
}

HTTPURLRewriteFilter rewrites HTTP requests.

type InvalidHTTPFilter

type InvalidHTTPFilter struct{}

InvalidHTTPFilter is a special filter for handling the case when configured filters are invalid.

type Match

type Match struct {
	// Method matches against the HTTP method.
	Method *string
	// Headers matches against the HTTP headers.
	Headers []HTTPHeaderMatch
	// QueryParams matches against the HTTP query parameters.
	QueryParams []HTTPQueryParamMatch
}

Match represents a match for a routing rule which consist of matches against various HTTP request attributes.

type MatchRule

type MatchRule struct {
	// Filters holds the filters for the MatchRule.
	Filters HTTPFilters
	// Source is the ObjectMeta of the resource that includes the rule.
	Source *metav1.ObjectMeta
	// Match holds the match for the rule.
	Match Match
	// BackendGroup is the group of Backends that the rule routes to.
	BackendGroup BackendGroup
}

MatchRule represents a routing rule. It corresponds directly to a Match in the HTTPRoute resource. An HTTPRoute is guaranteed to have at least one rule with one match. If no rule or match is specified by the user, the default rule {{path:{ type: "PathPrefix", value: "/"}}} is set by the schema.

type PathModifierType added in v1.2.0

type PathModifierType string

PathModifierType is the type of the PathModifier in a redirect or rewrite rule.

const (
	// ReplaceFullPath indicates that we replace the full path.
	ReplaceFullPath PathModifierType = "ReplaceFullPath"
	// ReplacePrefixMatch indicates that we replace a prefix match.
	ReplacePrefixMatch PathModifierType = "ReplacePrefixMatch"
)

type PathRule

type PathRule struct {
	// Path is a path. For example, '/hello'.
	Path string
	// PathType is the type of the path.
	PathType PathType
	// MatchRules holds routing rules.
	MatchRules []MatchRule
}

PathRule represents routing rules that share a common path.

type PathType

type PathType string

PathType is the type of the path in a PathRule.

const (
	// PathTypePrefix indicates that the path is a prefix.
	PathTypePrefix PathType = "prefix"
	// PathTypeExact indicates that the path is exact.
	PathTypeExact PathType = "exact"
)

type SSL

type SSL struct {
	// KeyPairID is the ID of the corresponding SSLKeyPair for the server.
	KeyPairID SSLKeyPairID
}

SSL is the SSL configuration for a server.

type SSLKeyPair

type SSLKeyPair struct {
	// Cert is the certificate.
	Cert []byte
	// Key is the private key.
	Key []byte
}

SSLKeyPair is an SSL private/public key pair.

type SSLKeyPairID

type SSLKeyPairID string

SSLKeyPairID is a unique identifier for a SSLKeyPair. The ID is safe to use as a file name.

type Upstream

type Upstream struct {
	// Name is the name of the Upstream. Will be unique for each service/port combination.
	Name string
	// ErrorMsg contains the error message if the Upstream is invalid.
	ErrorMsg string
	// Endpoints are the endpoints of the Upstream.
	Endpoints []resolver.Endpoint
}

Upstream is a pool of endpoints to be load balanced.

type VerifyTLS added in v1.2.0

type VerifyTLS struct {
	CertBundleID CertBundleID
	Hostname     string
	RootCAPath   string
}

VerifyTLS holds the backend TLS verification configuration.

type VirtualServer

type VirtualServer struct {
	// SSL holds the SSL configuration for the server.
	SSL *SSL
	// Hostname is the hostname of the server.
	Hostname string
	// PathRules is a collection of routing rules.
	PathRules []PathRule
	// IsDefault indicates whether the server is the default server.
	IsDefault bool
	// Port is the port of the server.
	Port int32
}

VirtualServer is a virtual server.

Jump to

Keyboard shortcuts

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