internal

package
v1.82.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LookupHost is an alias to net.LookupHost which allows it to be mocked for testing.
	LookupHost = net.LookupHost
)

net aliases

View Source
var MaxRefreshInterval = 5 * time.Second

MaxRefreshInterval is the maximum rate at which the version and hash of a single ClientSet are checked, to decide whether the ClientSet should be refreshed. Also, the GenericClientMap waits at least MaxRefreshInterval after creating a new ClientSet before checking if it should be refreshed.

View Source
var (
	// NewClientFromSecretObject is an alias to kubernetes.NewClientFromSecretObject which allows it to be mocked for testing.
	NewClientFromSecretObject = kubernetes.NewClientFromSecretObject
)

github.com/gardener/gardener/pkg/client/kubernetes aliases

View Source
var (
	// ProjectForNamespaceFromReader is an alias to gardenerutils.ProjectForNamespaceFromReader which allows it to be mocked for testing.
	ProjectForNamespaceFromReader = gardenerutils.ProjectForNamespaceFromReader
)

github.com/gardener/gardener/pkg/utils/gardener aliases

Functions

func NewGardenClientMap

func NewGardenClientMap(log logr.Logger, factory *GardenClientSetFactory) clientmap.ClientMap

NewGardenClientMap creates a new gardenClientMap with the given factory.

func NewShootClientMap

func NewShootClientMap(log logr.Logger, factory *ShootClientSetFactory) clientmap.ClientMap

NewShootClientMap creates a new shootClientMap with the given factory.

Types

type GardenClientSetFactory

type GardenClientSetFactory struct {
	// RuntimeClient is the runtime cluster client.
	RuntimeClient client.Client
	// ClientConnectionConfiguration is the configuration that will be used by created ClientSets.
	ClientConnectionConfig componentbaseconfig.ClientConnectionConfiguration
	// GardenNamespace is the namespace the virtual gardens run in. Defaults to `garden` if not set.
	GardenNamespace string
	// contains filtered or unexported fields
}

GardenClientSetFactory is a ClientSetFactory that can produce new ClientSets to virtual gardens.

func (*GardenClientSetFactory) CalculateClientSetHash

func (f *GardenClientSetFactory) CalculateClientSetHash(ctx context.Context, k clientmap.ClientSetKey) (string, error)

CalculateClientSetHash calculates a SHA256 hash of the kubeconfig in the 'gardener' secret in the Garden's Garden namespace.

func (*GardenClientSetFactory) InvalidateClient added in v1.76.0

func (f *GardenClientSetFactory) InvalidateClient(k clientmap.ClientSetKey) error

InvalidateClient invalidates information cached for the given ClientSetKey in the factory.

func (*GardenClientSetFactory) NewClientSet

NewClientSet creates a new ClientSet for a Garden cluster.

type GardenClientSetKey

type GardenClientSetKey struct {
	Name string
}

GardenClientSetKey is a ClientSetKey for a Garden cluster.

func (GardenClientSetKey) Key

func (k GardenClientSetKey) Key() string

Key returns the string representation of the ClientSetKey.

type GenericClientMap

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

GenericClientMap is a generic implementation of clientmap.ClientMap, which can be used by specific ClientMap implementations to reuse the core logic for storing, requesting, invalidating and starting ClientSets. Specific implementations only need to provide a ClientSetFactory that can produce new ClientSets for the respective keys if a corresponding entry is not found in the GenericClientMap.

func NewGenericClientMap

func NewGenericClientMap(factory clientmap.ClientSetFactory, logger logr.Logger, clock clock.Clock) *GenericClientMap

NewGenericClientMap creates a new GenericClientMap with the given factory and logger.

func (*GenericClientMap) GetClient

GetClient requests a ClientSet for a cluster identified by the given key. If the ClientSet was already created before, it returns the one saved in the map, otherwise it creates a new ClientSet by using the provided ClientSetFactory. New ClientSets are immediately started if the ClientMap has already been started before. Also GetClient will regularly rediscover the server version of the targeted cluster and check if the config hash has changed and recreate the ClientSet if a config hash change is detected.

func (*GenericClientMap) InvalidateClient

func (cm *GenericClientMap) InvalidateClient(key clientmap.ClientSetKey) error

InvalidateClient removes the ClientSet identified by the given key from the ClientMap after stopping its cache.

func (*GenericClientMap) Start

func (cm *GenericClientMap) Start(ctx context.Context) error

Start starts the caches of all contained ClientSets and saves the stopCh to start the caches of ClientSets, that will be created afterwards.

type ShootClientSetFactory

type ShootClientSetFactory struct {
	// GardenClient is the garden cluster client.
	GardenClient client.Client
	// SeedClient is the seed cluster client.
	SeedClient client.Client
	// ClientConnectionConfiguration is the configuration that will be used by created ClientSets.
	ClientConnectionConfig componentbaseconfig.ClientConnectionConfiguration
	// contains filtered or unexported fields
}

ShootClientSetFactory is a ClientSetFactory that can produce new ClientSets to Shoot clusters.

func (*ShootClientSetFactory) CalculateClientSetHash

func (f *ShootClientSetFactory) CalculateClientSetHash(ctx context.Context, k clientmap.ClientSetKey) (string, error)

CalculateClientSetHash calculates a SHA256 hash of the kubeconfig in the 'gardener' secret in the Shoot's Seed namespace.

func (*ShootClientSetFactory) InvalidateClient added in v1.15.0

func (f *ShootClientSetFactory) InvalidateClient(k clientmap.ClientSetKey) error

InvalidateClient invalidates information cached for the given ClientSetKey in the factory.

func (*ShootClientSetFactory) NewClientSet

NewClientSet creates a new ClientSet for a Shoot cluster.

type ShootClientSetKey

type ShootClientSetKey struct {
	Namespace, Name string
}

ShootClientSetKey is a ClientSetKey for a Shoot cluster.

func (ShootClientSetKey) Key

func (k ShootClientSetKey) Key() string

Key returns the string representation of the ClientSetKey.

Jump to

Keyboard shortcuts

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