Config#

Junction client configuration.

Classes:

Backend

A Backend is a logical target for network traffic.

BackendId

A target and port together uniquely represent a [Backend][crate::backend::Backend].

Fraction

A fraction, expressed as a numerator and a denominator.

HeaderMatchExact

HeaderMatchRegularExpression

HeaderValue

LbPolicyRingHash

LbPolicyRoundRobin

LbPolicyUnspecified

PathMatchExact

PathMatchPrefix

PathMatchRegularExpression

QueryParamMatchExact

QueryParamMatchRegularExpression

Route

A Route is a policy that describes how a request to a specific virtual host should be routed.

RouteMatch

Defines the predicate used to match requests to a given action.

RouteRetry

Configure client retry policy.

RouteRule

A RouteRule contains a set of matches that define which requests it applies to, processing rules, and the final destination(s) for matching traffic.

RouteTimeouts

Defines timeouts that can be configured for a HTTP Route.

SessionAffinity

SessionAffinityHashParam

TargetDns

TargetKubeService

VirtualHost

A virtual hostname.

WeightedBackend

The combination of a backend and a weight.

class junction.config.Backend[source]#

A Backend is a logical target for network traffic.

A backend configures how all traffic for it’s target is handled. Any traffic routed to this backend will use its load balancing policy to evenly spread traffic across all available endpoints.

Attributes:

id

A unique description of what this backend is.

lb

How traffic to this target should be load balanced.

id: BackendId#

A unique description of what this backend is.

lb: LbPolicyRoundRobin | LbPolicyRingHash | LbPolicyUnspecified#

How traffic to this target should be load balanced.

class junction.config.BackendId[source]#

A target and port together uniquely represent a [Backend][crate::backend::Backend].

Attributes:

hostname

A valid RFC1123 DNS domain name.

name

The name of the Kubernetes Service to target.

namespace

The namespace of the Kubernetes service to target.

port

The port backend traffic is sent on.

hostname: str#

A valid RFC1123 DNS domain name.

name: str#

The name of the Kubernetes Service to target.

namespace: str#

The namespace of the Kubernetes service to target. This must be explicitly specified, and won’t be inferred from context.

port: int#

The port backend traffic is sent on.

junction.config.Duration = str | int | float#

A duration expressed as a total number of seconds. Durations should never be negative.

class junction.config.Fraction[source]#

A fraction, expressed as a numerator and a denominator.

class junction.config.HeaderMatchExact[source]#
class junction.config.HeaderMatchRegularExpression[source]#
class junction.config.HeaderValue[source]#

Attributes:

name

The name of the HTTP Header.

value

The value of HTTP Header.

name: str#

The name of the HTTP Header. Note header names are case insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2>).

value: str#

The value of HTTP Header.

class junction.config.LbPolicyRingHash[source]#

Attributes:

hash_params

How to hash an outgoing request into the ring.

min_ring_size

The minimum size of the hash ring

hash_params: List[SessionAffinityHashParam]#

How to hash an outgoing request into the ring.

Hash parameters are applied in order. If the request is missing an input, it has no effect on the final hash. Hashing stops when only when all polices have been applied or a terminal policy matches part of an incoming request.

This allows configuring a fallback-style hash, where the value of HeaderA gets used, falling back to the value of HeaderB.

If no policies match, a random hash is generated for each request.

min_ring_size: int#

The minimum size of the hash ring

class junction.config.LbPolicyRoundRobin[source]#
class junction.config.LbPolicyUnspecified[source]#
class junction.config.PathMatchExact[source]#
class junction.config.PathMatchPrefix[source]#
class junction.config.PathMatchRegularExpression[source]#
class junction.config.QueryParamMatchExact[source]#
class junction.config.QueryParamMatchRegularExpression[source]#
class junction.config.Route[source]#

A Route is a policy that describes how a request to a specific virtual host should be routed.

Attributes:

rules

The rules that determine whether a request matches and where traffic should be routed.

tags

A list of arbitrary tags that can be added to a Route.

vhost

A virtual hostname that uniquely identifies this route.

rules: List[RouteRule]#

The rules that determine whether a request matches and where traffic should be routed.

tags: Dict[str, str]#

A list of arbitrary tags that can be added to a Route.

vhost: VirtualHost#

A virtual hostname that uniquely identifies this route.

class junction.config.RouteMatch[source]#

Defines the predicate used to match requests to a given action. Multiple match types are ANDed together; the match will evaluate to true only if all conditions are satisfied. For example, if a match specifies a path match and two query_params matches, it will match only if the request’s path matches and both of the query_params are matches.

The default RouteMatch functions like a path match on the empty prefix, which matches every request.

Attributes:

headers

Specifies HTTP request header matchers.

method

Specifies HTTP method matcher.

path

Specifies a HTTP request path matcher.

query_params

Specifies HTTP query parameter matchers.

headers: List[HeaderMatchRegularExpression | HeaderMatchExact]#

Specifies HTTP request header matchers. Multiple match values are ANDed together, meaning, a request must match all the specified headers.

method: str#

Specifies HTTP method matcher. When specified, this route will be matched only if the request has the specified method.

path: PathMatchPrefix | PathMatchRegularExpression | PathMatchExact#

Specifies a HTTP request path matcher.

query_params: List[QueryParamMatchRegularExpression | QueryParamMatchExact]#

Specifies HTTP query parameter matchers. Multiple match values are ANDed together, meaning, a request must match all the specified query parameters.

class junction.config.RouteRetry[source]#

Configure client retry policy.

Attributes:

attempts

The total number of attempts to make when retrying this request.

backoff

The amount of time to back off between requests during a series of retries.

codes

The HTTP error codes that retries should be applied to.

attempts: int#

The total number of attempts to make when retrying this request.

backoff: str | int | float#

The amount of time to back off between requests during a series of retries.

codes: List[int]#

The HTTP error codes that retries should be applied to.

class junction.config.RouteRule[source]#

A RouteRule contains a set of matches that define which requests it applies to, processing rules, and the final destination(s) for matching traffic.

See the Junction docs for a high level description of how Routes and RouteRules behave.

Attributes:

backends

Where the traffic should route if this rule matches.

matches

A list of match rules applied to an outgoing request.

retry

How to retry requests.

backends: List[WeightedBackend]#

Where the traffic should route if this rule matches.

If no backends are specified, traffic is sent to the VirtualHost this route was defined with, using the request’s port to fill in any defaults.

matches: List[RouteMatch]#

A list of match rules applied to an outgoing request. Each match is independent; this rule will be matched if any of the listed matches is satsified.

If no matches are specified, this Rule matches any outgoing request.

retry: RouteRetry#

How to retry requests. If not specified, requests are not retried.

class junction.config.RouteTimeouts[source]#

Defines timeouts that can be configured for a HTTP Route.

Attributes:

backend_request

Specifies a timeout for an individual request to a backend.

request

Specifies the maximum duration for a HTTP request.

backend_request: str | int | float#

Specifies a timeout for an individual request to a backend. This covers the time from when the request first starts being sent to when the full response has been received from the backend.

Because the overall request timeout encompasses the backend request timeout, the value of this timeout must be less than or equal to the value of the overall timeout.

request: str | int | float#

Specifies the maximum duration for a HTTP request. This timeout is intended to cover as close to the whole request-response transaction as possible.

An entire client HTTP transaction may result in more than one call to destination backends, for example, if automatic retries are configured.

class junction.config.SessionAffinity[source]#
class junction.config.SessionAffinityHashParam[source]#

Attributes:

name

The name of the header to use as hash input.

terminal

Whether to stop immediately after hashing this value.

name: str#

The name of the header to use as hash input.

terminal: bool#

Whether to stop immediately after hashing this value.

This is useful if you want to try to hash a value, and then fall back to another as a default if it wasn’t set.

class junction.config.TargetDns[source]#

Attributes:

hostname

A valid RFC1123 DNS domain name.

hostname: str#

A valid RFC1123 DNS domain name.

class junction.config.TargetKubeService[source]#

Attributes:

name

The name of the Kubernetes Service to target.

namespace

The namespace of the Kubernetes service to target.

name: str#

The name of the Kubernetes Service to target.

namespace: str#

The namespace of the Kubernetes service to target. This must be explicitly specified, and won’t be inferred from context.

class junction.config.VirtualHost[source]#

A virtual hostname. VirtualHosts represent the primary layer of indirection in Junction. Traffic sent to a VirtualHost is routed to an appropriate backend based on the content of the request.

VirtualHosts uniquely map to the Authority section of a URL.

Attributes:

hostname

A valid RFC1123 DNS domain name.

name

The name of the Kubernetes Service to target.

namespace

The namespace of the Kubernetes service to target.

port

The port this virtual hostname should apply to.

hostname: str#

A valid RFC1123 DNS domain name.

name: str#

The name of the Kubernetes Service to target.

namespace: str#

The namespace of the Kubernetes service to target. This must be explicitly specified, and won’t be inferred from context.

port: int#

The port this virtual hostname should apply to. If no port is specified, traffic is allowed on any port.

class junction.config.WeightedBackend[source]#

The combination of a backend and a weight.

Attributes:

hostname

A valid RFC1123 DNS domain name.

name

The name of the Kubernetes Service to target.

namespace

The namespace of the Kubernetes service to target.

port

The port backend traffic is sent on.

weight

The relative weight of this backend relative to any other backends in [the list][RouteRule::backends].

hostname: str#

A valid RFC1123 DNS domain name.

name: str#

The name of the Kubernetes Service to target.

namespace: str#

The namespace of the Kubernetes service to target. This must be explicitly specified, and won’t be inferred from context.

port: int#

The port backend traffic is sent on.

weight: int#

The relative weight of this backend relative to any other backends in [the list][RouteRule::backends].

If not specified, defaults to 1.

An individual backend may have a weight of 0, but specifying every backend with 0 weight is an error.