proxy

package
v2.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultProxyTimeoutSeconds indicates the time.Duration allowed for responses to
	// come back from the backend proxy API.
	//
	// NOTE: the current default is based on observed latency in a CI environment using
	// the GKE cloud provider.
	DefaultProxyTimeoutSeconds float32 = 10.0

	// DefaultSyncSeconds indicates the time.Duration (minimum) that will occur between
	// updates to the Kong Proxy Admin API when using the NewProxy() constructor.
	// this 1s default was based on local testing wherein it appeared sub-second updates
	// to the Admin API could be problematic (or at least operate differently) based on
	// which storage backend was in use (i.e. "dbless", "postgres"). This is a workaround
	// for improvements we still need to investigate upstream.
	//
	// See Also: https://github.com/Kong/kubernetes-ingress-controller/issues/1398
	DefaultSyncSeconds float32 = 3.0
)

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,
	diagnostic util.ConfigDumpDiagnostic,
	proxyRequestTimeout time.Duration,
	promMetrics *metrics.CtrlFuncMetrics) ([]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

	// ObjectExists indicates whether or not any version of the provided object is already present in the proxy.
	ObjectExists(obj client.Object) (bool, error)

	// IsReady returns true if the proxy is considered ready.
	// A ready proxy has configuration available and can handle traffic.
	IsReady() bool

	// Listeners retrieves the currently configured listeners from the
	// underlying proxy so that callers can gather this metadata to
	// know which ports and protocols are in use by the proxy.
	Listeners(ctx context.Context) ([]kong.ProxyListener, []kong.StreamListener, error)

	manager.Runnable
	manager.LeaderElectionRunnable
}

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(logger logrus.FieldLogger,
	k8s client.Client,
	kongConfig sendconfig.Kong,
	ingressClassName string,
	enableReverseSync bool,
	kongUpdater KongUpdater,
	diagnostic util.ConfigDumpDiagnostic,
	proxyRequestTimeout time.Duration,
) (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(logger logrus.FieldLogger,
	k8s client.Client,
	kongConfig sendconfig.Kong,
	ingressClassName string,
	enableReverseSync bool,
	stagger time.Duration,
	proxyRequestTimeout time.Duration,
	diagnostic util.ConfigDumpDiagnostic,
	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