config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config contains the configuration sent to the agent for nginx.

Index

Constants

View Source
const (
	EgressSSLPort = 443
	EgressPort    = 80
)

Egress ports.

Variables

This section is empty.

Functions

func TrafficSplitBackendExists

func TrafficSplitBackendExists(backend split.TrafficSplitBackend, backends []split.TrafficSplitBackend) bool

TrafficSplitBackendExists returns whether or not a TrafficSplitBackend exists in the list.

Types

type AgentBreaker

type AgentBreaker map[string]specs.CircuitBreakerSpec

AgentBreaker is a map of destination names to their associated circuit breaker specs.

type AgentKeyval

type AgentKeyval map[string]string

AgentKeyval holds the data for configuring a single keyval in the agent.

type AgentLimit

type AgentLimit map[string][]AgentRateLimit

AgentLimit holds a one-to-one mapping of how the agent will configure rate limiting.

func NewAgentLimit

func NewAgentLimit() AgentLimit

NewAgentLimit returns an initialized map from dest string to array of sources.

type AgentRateLimit

type AgentRateLimit struct {
	// Delay sets the amount a request will be delayed (in seconds) when the rate
	// limit is hit. Set to "nodelay" to send back an 503 status immediately
	// see: https://www.nginx.com/blog/rate-limiting-nginx/#bursts
	// +optional
	Delay *intstr.IntOrString `json:"delay,omitempty"`

	// Name of Rate Limit, i.e. 10rs
	Name string `json:"name"`

	// Maximum allowed rate of traffic
	Rate string `json:"rate"`

	// Matches is a string representation of a list of specs.HTTPMatch that should be applied to the rate limit.
	Matches string `json:"matches,omitempty"`

	// Sources defines from where traffic should be limited
	// +optional
	Sources []v1.ObjectReference `json:"sources,omitempty"`

	// Burst sets the maximum number of requests a client can make in excess of rate
	// see: https://www.nginx.com/blog/rate-limiting-nginx/#bursts
	// +optional
	Burst int `json:"burst,omitempty"`
}

AgentRateLimit is a wrapper around the RateLimitSpec that contains a string of specs.HTTPMatch instead of the rules field.

type AgentTrafficSplit

type AgentTrafficSplit struct {
	// Service represents the apex service.
	Service string `json:"service"`

	// Matches is a string representation of a list of specs.HTTPMatch that should be applied to the traffic split.
	Matches string `json:"matches,omitempty"`

	// Backends defines a list of Kubernetes services
	// used as the traffic split destination.
	Backends []split.TrafficSplitBackend `json:"backends"`
}

AgentTrafficSplit mirrors a split.TrafficSplitSpec, but uses a map of specs.HTTPMatch json strings instead of v1.TypedLocalObjectReference, for easier handling by the agent.

func (*AgentTrafficSplit) Equals

func (a *AgentTrafficSplit) Equals(tsplit AgentTrafficSplit) bool

Equals returns whether or not two AgentTrafficSplits are equal.

type Block

type Block int

Block defines model for Block.

const (
	HTTP Block = iota
	Stream
)

HTTP and Stream are the two major Blocks in the NGINX config. It's very important to keep track of which Block a Port belongs in.

func (Block) MarshalJSON

func (b Block) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Block enum into JSON.

func (Block) String

func (b Block) String() string

String returns a Block as a string.

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(blockBytes []byte) error

UnmarshalJSON unmarshals a Block, to a Block enum.

type CombinedConfig

type CombinedConfig struct {
	Pods                map[string]Pod
	ServiceAddresses    AgentKeyval
	HTTPPlaceholders    AgentKeyval
	StreamPlaceholders  AgentKeyval
	HTTPSvcNames        AgentKeyval
	StreamSvcNames      AgentKeyval
	Redirects           AgentKeyval
	HTTPLBMethods       map[string]string
	StreamLBMethods     map[string]string
	HTTPUpstreams       map[string][]UpstreamServer
	StreamUpstreams     map[string][]UpstreamServer
	HTTPEgressUpstream  *EgressEndpoint
	TrafficSplits       map[string]AgentTrafficSplit
	RateLimits          AgentLimit
	CircuitBreakers     AgentBreaker
	HTTPAccessControl   map[string]AgentKeyval
	StreamAccessControl map[string]AgentKeyval
	MeshConfig          mesh.MeshConfig
}

CombinedConfig contains all the configs consumed by the sidecar agent. For use by agent when unmarshaling config.

type EgressEndpoint

type EgressEndpoint struct {
	DNSName   string
	Upstreams []UpstreamServer
}

EgressEndpoint contains the DNS name and the upstream servers for egress.

type LBMethod

type LBMethod struct {
	Method mesh.MeshConfigLoadBalancingMethod
	Block  Block
}

LBMethod represents a load balancing method for an nginx block.

func (LBMethod) String

func (lb LBMethod) String() string

String returns the string representation of an LBMethod.

type NginxDynSplitBackend

type NginxDynSplitBackend struct {
	Service string `json:"name"`
	Weight  int    `json:"weight"`
}

NginxDynSplitBackend is the expected backend struct of ngx_http_dyn_split_module.

type Pod

type Pod struct {
	ContainerPorts       map[string]string
	ParentName           string
	ParentType           string
	Name                 string
	Namespace            string
	ServiceAccountName   string
	PodIP                string
	IsIngressController  bool
	IsEgressController   bool
	Injected             bool
	DefaultEgressAllowed bool
}

Pod defines the configuration of a single pod.

func (*Pod) ToK8s

func (p *Pod) ToK8s() *v1.Pod

ToK8s returns the K8s resource associated with the API object.

type Upstream

type Upstream struct {
	Name            string
	UpstreamServers []UpstreamServer
	Block           Block
}

Upstream should correspond to a service DNS name.

type UpstreamServer

type UpstreamServer struct {
	Address string `json:"address"`
	Port    int32  `json:"port"`
}

UpstreamServer defines an upstream address and port.

Jump to

Keyboard shortcuts

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