generic

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package generic implements the generic logic to reflect Kubernetes objects between the local and the remote cluster, for a set of resources and namespaces.

Index

Constants

This section is empty.

Variables

Reflectors is the list of all resources that can be reflected.

View Source
var ReflectorsCustomizableType = []ResourceReflected{Service, Ingress, ConfigMap, Secret, Event}

ReflectorsCustomizableType is the list of resources for which the reflection type can be customized.

Functions

func BasicKeyer added in v0.3.2

func BasicKeyer() func(metadata metav1.Object) []types.NamespacedName

BasicKeyer returns a keyer retrieving the name and namespace from the object metadata.

func EnqueueAfter added in v0.7.0

func EnqueueAfter(interval time.Duration) error

EnqueueAfter returns an error to convey that the current key should be reenqueued after a given duration.

func NamespacedKeyer

func NamespacedKeyer(namespace string) func(metadata metav1.Object) []types.NamespacedName

NamespacedKeyer returns a keyer associated with the given namespace, retrieving the object name from its metadata.

func NewReflector

func NewReflector(name string, namespaced NamespacedReflectorFactoryFunc, fallback FallbackReflectorFactoryFunc,
	workers uint, reflectionType consts.ReflectionType, concurrencyMode ConcurrencyMode) manager.Reflector

NewReflector returns a new reflector to implement the reflection towards a remote clusters, of a dummy one if no workers are specified.

Types

type ConcurrencyMode added in v0.9.0

type ConcurrencyMode string

ConcurrencyMode returns the concurrency mode of the reflector.

const (
	// ConcurrencyModeLeader is the concurrency mode that allows to run the reflector only on the leader node.
	ConcurrencyModeLeader ConcurrencyMode = "leader"
	// ConcurrencyModeAll is the concurrency mode that allows to run the reflector on all the nodes.
	ConcurrencyModeAll ConcurrencyMode = "all"
)

type FallbackReflectorFactoryFunc added in v0.3.2

type FallbackReflectorFactoryFunc func(*options.ReflectorOpts) manager.FallbackReflector

FallbackReflectorFactoryFunc represents the function type to create a new FallbackReflector.

func WithoutFallback added in v0.3.2

func WithoutFallback() FallbackReflectorFactoryFunc

WithoutFallback returns a FallbackReflectorFactoryFunc which disables the fallback functionality.

type NamespacedReflector

type NamespacedReflector struct {
	record.EventRecorder

	ForgingOpts *forge.ForgingOpts
	// contains filtered or unexported fields
}

NamespacedReflector implements the logic common to all namespaced reflectors.

func NewNamespacedReflector

func NewNamespacedReflector(opts *options.NamespacedOpts, name string) NamespacedReflector

NewNamespacedReflector returns a new NamespacedReflector for the given namespaces.

func (*NamespacedReflector) DeleteLocal added in v0.9.0

func (gnr *NamespacedReflector) DeleteLocal(ctx context.Context, deleter ResourceDeleter, resource, name string, uid types.UID) error

DeleteLocal deletes the given local resource from the cluster.

func (*NamespacedReflector) DeleteRemote

func (gnr *NamespacedReflector) DeleteRemote(ctx context.Context, deleter ResourceDeleter, resource, name string, uid types.UID) error

DeleteRemote deletes the given remote resource from the cluster.

func (*NamespacedReflector) ForcedAllowOrSkip added in v0.10.0

func (gnr *NamespacedReflector) ForcedAllowOrSkip(obj metav1.Object) (*bool, error)

ForcedAllowOrSkip checks whether the given object is *explicitly* marked to be allowed or skipped (i.e., it has the allow or the deny annotation), independently from the reflection policy. If so, it returns whether the object should be skipped, or an error if unable to determine it. Otherwise, it return a nil bool as it is undeterminated, since we are not considering the reflection policy at this stage.

func (*NamespacedReflector) GetReflectionType added in v0.9.4

func (gnr *NamespacedReflector) GetReflectionType() consts.ReflectionType

GetReflectionType returns the reflection type of the reflector.

func (*NamespacedReflector) LocalNamespace

func (gnr *NamespacedReflector) LocalNamespace() string

LocalNamespace returns the local namespace associated with the reflector.

func (*NamespacedReflector) LocalRef

func (gnr *NamespacedReflector) LocalRef(name string) klog.ObjectRef

LocalRef returns the ObjectRef associated with the local namespace.

func (*NamespacedReflector) Ready

func (gnr *NamespacedReflector) Ready() bool

Ready returns whether the NamespacedReflector is completely initialized.

func (*NamespacedReflector) RemoteNamespace

func (gnr *NamespacedReflector) RemoteNamespace() string

RemoteNamespace returns the remote namespace associated with the reflector.

func (*NamespacedReflector) RemoteRef

func (gnr *NamespacedReflector) RemoteRef(name string) klog.ObjectRef

RemoteRef returns the ObjectRef associated with the remote namespace.

func (*NamespacedReflector) ShouldSkipReflection added in v0.6.0

func (gnr *NamespacedReflector) ShouldSkipReflection(obj metav1.Object) (bool, error)

ShouldSkipReflection returns whether the reflection of the given object should be skipped.

type NamespacedReflectorFactoryFunc

type NamespacedReflectorFactoryFunc func(*options.NamespacedOpts) manager.NamespacedReflector

NamespacedReflectorFactoryFunc represents the function type to create a new NamespacedReflector.

type ReflectorConfig added in v0.9.4

type ReflectorConfig struct {
	// Number of workers for the reflector.
	NumWorkers uint
	// Type of reflection.
	Type consts.ReflectionType
}

ReflectorConfig contains configuration parameters of the reflector.

type ResourceDeleter

type ResourceDeleter interface {
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
}

ResourceDeleter know how to delete a Kubernetes object with the given name.

type ResourceReflected added in v0.9.4

type ResourceReflected string

ResourceReflected represents a resource that can be reflected.

const (
	Pod                   ResourceReflected = "pod"
	Service               ResourceReflected = "service"
	EndpointSlice         ResourceReflected = "endpointslice"
	Ingress               ResourceReflected = "ingress"
	ConfigMap             ResourceReflected = "configmap"
	Secret                ResourceReflected = "secret"
	ServiceAccount        ResourceReflected = "serviceaccount"
	PersistentVolumeClaim ResourceReflected = "persistentvolumeclaim"
	Event                 ResourceReflected = "event"
)

List of all resources that can be reflected.

Directories

Path Synopsis
Package fake implements the reflector interfaces for testing purposes.
Package fake implements the reflector interfaces for testing purposes.

Jump to

Keyboard shortcuts

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