internal

package
v1.28.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

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 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.
	MaxRefreshInterval = 5 * time.Second
)
View Source
var (
	// ProjectForNamespaceFromReader is an alias to gutil.ProjectForNamespaceFromReader which allows it to be mocked for testing.
	ProjectForNamespaceFromReader = gutil.ProjectForNamespaceFromReader
)

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

Functions

func NewDelegatingClientMap

func NewDelegatingClientMap(gardenClientMap, seedClientMap, shootClientMap, plantClientMap clientmap.ClientMap) clientmap.ClientMap

NewDelegatingClientMap constructs a new delegatingClientMap consisting of the given different ClientMaps. It will panic if `gardenClientMap` is nil.

func NewGardenClientMap

func NewGardenClientMap(factory *GardenClientSetFactory, logger logrus.FieldLogger) clientmap.ClientMap

NewGardenClientMap creates a new gardenClientMap with the given factory and logger.

func NewPlantClientMap

func NewPlantClientMap(factory *PlantClientSetFactory, logger logrus.FieldLogger) clientmap.ClientMap

NewPlantClientMap creates a new plantClientMap with the given factory and logger.

func NewSeedClientMap

func NewSeedClientMap(factory *SeedClientSetFactory, logger logrus.FieldLogger) clientmap.ClientMap

NewSeedClientMap creates a new seedClientMap with the given factory and logger.

func NewShootClientMap

func NewShootClientMap(factory *ShootClientSetFactory, logger logrus.FieldLogger) clientmap.ClientMap

NewShootClientMap creates a new shootClientMap with the given factory and logger.

Types

type GardenClientSetFactory

type GardenClientSetFactory struct {
	// RESTConfig is a rest.Config that will be used by the created ClientSets.
	RESTConfig *rest.Config
	// UncachedObjects is a list of objects that will not be cached.
	UncachedObjects []client.Object
	// SeedName is the name of the seed that will be used by the created ClientSets.
	SeedName string
}

GardenClientSetFactory is a ClientSetFactory that can produce new ClientSets to the garden cluster.

func (*GardenClientSetFactory) CalculateClientSetHash

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

CalculateClientSetHash returns "" as the garden client config cannot change during runtime

func (*GardenClientSetFactory) NewClientSet

NewClientSet creates a new ClientSet to the garden cluster.

type GardenClientSetKey

type GardenClientSetKey struct{}

GardenClientSetKey is a ClientSetKey for the garden cluster.

func (GardenClientSetKey) Key

func (k GardenClientSetKey) Key() string

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 logrus.FieldLogger) *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(stopCh <-chan struct{}) 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 PlantClientSetFactory

type PlantClientSetFactory struct {
	// GetGardenClient is a func that will be used to get a client to the garden cluster to retrieve the Plant's
	// kubeconfig secret.
	GetGardenClient func(ctx context.Context) (kubernetes.Interface, error)
}

PlantClientSetFactory is a ClientSetFactory that can produce new ClientSets to Plant clusters.

func (*PlantClientSetFactory) CalculateClientSetHash

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

CalculateClientSetHash calculates a SHA256 hash of the kubeconfig in the plant secret.

func (*PlantClientSetFactory) NewClientSet

NewClientSet creates a new ClientSet for a Plant cluster.

type PlantClientSetKey

type PlantClientSetKey struct {
	Namespace, Name string
}

PlantClientSetKey is a ClientSetKey for a Plant cluster.

func (PlantClientSetKey) Key

func (k PlantClientSetKey) Key() string

type SeedClientSetFactory

type SeedClientSetFactory struct {
	// ClientConnectionConfiguration is the configuration that will be used by created ClientSets.
	ClientConnectionConfig baseconfig.ClientConnectionConfiguration
}

SeedClientSetFactory is a ClientSetFactory that can produce new ClientSets to Seed clusters.

func (*SeedClientSetFactory) CalculateClientSetHash

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

CalculateClientSetHash always returns "" and nil.

func (*SeedClientSetFactory) NewClientSet

NewClientSet creates a new ClientSet for a Seed cluster.

type SeedClientSetKey

type SeedClientSetKey string

SeedClientSetKey is a ClientSetKey for a Seed cluster.

func (SeedClientSetKey) Key

func (k SeedClientSetKey) Key() string

type ShootClientSetFactory

type ShootClientSetFactory struct {
	// GetGardenClient is a func that will be used to get a client to the garden cluster to retrieve the Shoot's
	// Project name (which is used for determining the Shoot's technical ID).
	GetGardenClient func(ctx context.Context) (kubernetes.Interface, error)
	// GetSeedClient is a func that will be used to get a client to the Shoot's Seed cluster to retrieve the Shoot's
	// kubeconfig secret ('gardener-internal' or 'gardener').
	GetSeedClient func(ctx context.Context, name string) (kubernetes.Interface, error)
	// ClientConnectionConfiguration is the configuration that will be used by created ClientSets.
	ClientConnectionConfig baseconfig.ClientConnectionConfiguration

	// Log is a logger for logging entries related to creating Shoot ClientSets.
	Log logrus.FieldLogger
	// 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

Jump to

Keyboard shortcuts

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