proxy

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSyncSeconds indicates the time.Duration (minimum) that will occur between
	// updates to the Kong Proxy Admin API when using the NewProxy() constructor.
	//
	// NOTE: this default was originally inherited from KIC v1.x.
	DefaultSyncSeconds float32 = 0.3

	// DefaultObjectBufferSize is the number of client.Objects that the server will buffer
	// before it starts rejecting new objects while it processes the originals.
	// If you get to the point that objects are rejected, you'll find that the
	// UpdateObject() and DeleteObject() methods will start throwing errors and you'll
	// need to retry queing the object at a later time.
	//
	// NOTE: implementations of the Proxy interface should error, not block on full buffer.
	//
	// TODO: the current default of 50 is based on a loose approximation to allow ~5mb
	//       of buffer space for client.Objects and assuming a throughput of ~50 API
	//       updates per second, but in the future we may want to make this configurable,
	//       provide metrics for it, and furthermore automate detecting good values for it.
	//       depending on configuration and/or available system memory and the amount of
	//       throughput (in Kubernetes object updates) that the API is meant to handle.
	DefaultObjectBufferSize = 500
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KongUpdater

type KongUpdater func(ctx context.Context,
	lastConfigSHA []byte,
	cache *store.CacheStores,
	ingressClassName string,
	deprecatedLogger logrus.FieldLogger,
	kongConfig sendconfig.Kong,
	enableReverseSync bool) ([]byte, error)

KongUpdater is a type of function that describes how to provide updates to the Kong Admin API and implementations will report the configuration SHA that results from any update performed.

type Proxy

type Proxy interface {
	// UpdateObject accepts a Kubernetes controller-runtime client.Object and adds/updates that to the configuration cache.
	// It will be asynchronously converted into the upstream Kong DSL and applied to the Kong Admin API.
	// A status will later be added to the object whether the configuration update succeeds or fails.
	UpdateObject(obj client.Object) error

	// DeleteObject accepts a Kubernetes controller-runtime client.Object and removes it from the configuration cache.
	// The delete action will asynchronously be converted to Kong DSL and applied to the Kong Admin API.
	// A status will later be added to the object whether the configuration update succeeds or fails.
	DeleteObject(obj client.Object) error
}

Proxy represents the Kong Proxy from the perspective of Kubernetes allowing callers to update and remove Kubernetes objects in the backend proxy without having to understand or be aware of Kong DSLs or how types are converted between Kubernetes and the Kong Admin API.

NOTE: implementations of this interface are: threadsafe, non-blocking

func NewCacheBasedProxy

func NewCacheBasedProxy(ctx context.Context,
	logger logrus.FieldLogger,
	k8s client.Client,
	kongConfig sendconfig.Kong,
	ingressClassName string,
	enableReverseSync bool,
	kongUpdater KongUpdater,
) (Proxy, error)

NewCacheBasedProxy will provide a new Proxy object. Note that this starts some background goroutines and the caller is resonsible for marking the provided context.Context as "Done()" to shut down the background routines.

func NewCacheBasedProxyWithStagger

func NewCacheBasedProxyWithStagger(ctx context.Context,
	logger logrus.FieldLogger,
	k8s client.Client,
	kongConfig sendconfig.Kong,
	ingressClassName string,
	enableReverseSync bool,
	stagger time.Duration,
	kongUpdater KongUpdater,
) (Proxy, error)

NewCacheBasedProxy will provide a new Proxy object. Note that this starts some background goroutines and the caller is resonsible for marking the provided context.Context as "Done()" to shut down the background routines. A "stagger" time duration is provided to indicate how often the background routines will sync configuration to the Kong Admin API.

Jump to

Keyboard shortcuts

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