clients

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultNewCacheFn  NewCacheFn  = cache.New
	DefaultNewClientFn NewClientFn = client.New
)

The default new cache and new controller functions.

Functions

func Anonymize

func Anonymize(cfg *rest.Config) *rest.Config

Anonymize the supplied config by returning a copy with all authentication details and credentials removed.

func Config

func Config() (*rest.Config, error)

Config returns a REST config.

func RESTMapper

func RESTMapper(cfg *rest.Config) (meta.RESTMapper, error)

RESTMapper returns a 'REST mapper' that discovers an API server's available REST API endpoints. The returned REST mapper is intended to be shared by many clients. It is 'dynamic' in that it will attempt to rediscover API endpoints any time a client asks for a kind of resource that is unknown to it. Each discovery process may burst up to 100 API server requests per second, and average 20 requests per second. Rediscovery may not happen more frequently than once every 20 seconds.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

A Cache of Kubernetes clients. Each client is associated with a particular bearer token, which is used to authenticate to an API server. Each client is backed by its own cache, which is populated by automatically watching any type the client is asked to get or list. Clients (and their caches) expire and are garbage collected if they are unused for five minutes.

func NewCache

func NewCache(s *runtime.Scheme, c *rest.Config, o ...CacheOption) *Cache

NewCache creates a cache of Kubernetes clients. Clients use the supplied scheme, and connect to the API server using a copy of the supplied REST config with a specific bearer token injected.

func (*Cache) Get

func (c *Cache) Get(cr auth.Credentials, o ...GetOption) (client.Client, error)

Get a client that uses the specified bearer token.

type CacheOption

type CacheOption func(c *Cache)

A CacheOption configures the client cache.

func DoNotCache

func DoNotCache(o []client.Object) CacheOption

DoNotCache configures clients not to cache objects of the supplied types. Note that the cache machinery extracts a GVK from these objects, so they can either be types known to the scheme or *unstructured.Unstructured with their APIVersion and Kind set.

func WithExpiry

func WithExpiry(d time.Duration) CacheOption

WithExpiry configures the duration until each client expires. Each time any of a client's methods are called the expiry time is reset to this value. When a client expires its cache will be garbage collected.

func WithLogger

func WithLogger(l logging.Logger) CacheOption

WithLogger configures the logger used by the client cache. A no-op logger is used by default.

func WithRESTMapper

func WithRESTMapper(m meta.RESTMapper) CacheOption

WithRESTMapper configures the REST mapper used by cached clients. A mapper is created for each new client by default, which can take ~10 seconds.

type GetOption

type GetOption func(o *getOptions)

A GetOption modifies the kind of client returned.

func ForNamespace

func ForNamespace(n string) GetOption

ForNamespace returns a client backed by a cache scoped to the supplied namespace.

type NewCacheFn

type NewCacheFn func(cfg *rest.Config, o cache.Options) (cache.Cache, error)

A NewCacheFn creates a new controller-runtime cache.

type NewClientFn

type NewClientFn func(cfg *rest.Config, o client.Options) (client.Client, error)

A NewClientFn creates a new controller-runtime client.

Jump to

Keyboard shortcuts

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