workload

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package workload implements the reflection logic for pods.

Index

Constants

View Source
const (
	// PodReflectorName -> The name associated with the Pod reflector.
	PodReflectorName = "Pod"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FallbackPodReflector

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

FallbackPodReflector handles the "orphan" pods outside the managed namespaces.

func (*FallbackPodReflector) Handle

Handle operates as fallback to reconcile pod objects not managed by namespaced handlers.

func (*FallbackPodReflector) Keys

func (fpr *FallbackPodReflector) Keys(local, _ string) []types.NamespacedName

Keys returns a set of keys to be enqueued for fallback processing for the given namespace pair.

func (*FallbackPodReflector) Ready

func (fpr *FallbackPodReflector) Ready() bool

Ready returns whether the FallbackReflector is completely initialized.

type MetricsFactory

type MetricsFactory func(namespace string) metricsv1beta1.PodMetricsInterface

MetricsFactory represents a function to generate the interface to retrieve the pod metrics for a given namespace.

type NamespacedPodHandler

type NamespacedPodHandler interface {
	// Exec executes a command in a container of a reflected pod.
	Exec(ctx context.Context, pod, container string, cmd []string, attach api.AttachIO) error
	// Logs retrieves the logs of a container of a reflected pod.
	Logs(ctx context.Context, pod, container string, opts api.ContainerLogOpts) (io.ReadCloser, error)
	// Stats retrieves the stats of the reflected pods.
	Stats(ctx context.Context) ([]statsv1alpha1.PodStats, error)
}

NamespacedPodHandler exposes an interface to interact with pods offloaded to the remote cluster in a given namespace.

type NamespacedPodReflector

type NamespacedPodReflector struct {
	generic.NamespacedReflector
	// contains filtered or unexported fields
}

NamespacedPodReflector manages the Pod reflection for a given pair of local and remote namespaces.

func (*NamespacedPodReflector) Exec

func (npr *NamespacedPodReflector) Exec(ctx context.Context, po, container string, cmd []string, attach api.AttachIO) error

Exec executes a command in a container of a reflected pod.

func (*NamespacedPodReflector) ForgeShadowPod added in v0.5.0

func (npr *NamespacedPodReflector) ForgeShadowPod(ctx context.Context, local *corev1.Pod,
	shadow *vkv1alpha1.ShadowPod, info *PodInfo) (*vkv1alpha1.ShadowPod, error)

ForgeShadowPod forges the ShadowPod object to be enforced by the reflection process.

func (*NamespacedPodReflector) ForgetPodInfo

func (npr *NamespacedPodReflector) ForgetPodInfo(po string)

ForgetPodInfo forgets about a pod and deletes the cached information.

func (*NamespacedPodReflector) Handle

func (npr *NamespacedPodReflector) Handle(ctx context.Context, name string) error

Handle reconciles pod objects.

func (*NamespacedPodReflector) HandleLabels added in v0.4.0

func (npr *NamespacedPodReflector) HandleLabels(ctx context.Context, local *corev1.Pod) error

HandleLabels mutates the local object labels, to mark the pod as offloaded and allow filtering at the informer level.

func (*NamespacedPodReflector) HandleStatus

func (npr *NamespacedPodReflector) HandleStatus(ctx context.Context, local, remote *corev1.Pod, info *PodInfo) error

HandleStatus reflects the status from the remote Pod to the local one.

func (*NamespacedPodReflector) InferAdditionalRestarts

func (npr *NamespacedPodReflector) InferAdditionalRestarts(local, remote *corev1.PodStatus) int32

InferAdditionalRestarts estimates the number of remote pod restarts comparing the previously configured statues.

func (*NamespacedPodReflector) Logs

func (npr *NamespacedPodReflector) Logs(ctx context.Context, po, container string, opts api.ContainerLogOpts) (io.ReadCloser, error)

Logs retrieves the logs of a container of a reflected pod.

func (*NamespacedPodReflector) MapPodIP

func (npr *NamespacedPodReflector) MapPodIP(ctx context.Context, info *PodInfo, original string) (string, error)

MapPodIP maps the remote Pod address to the corresponding local one.

func (*NamespacedPodReflector) RetrievePodInfo

func (npr *NamespacedPodReflector) RetrievePodInfo(po string) *PodInfo

RetrievePodInfo retrieves the pod information regarding a given pod.

func (*NamespacedPodReflector) RetrieveServiceAccountSecretName added in v0.5.0

func (npr *NamespacedPodReflector) RetrieveServiceAccountSecretName(info *PodInfo, saName string) (string, error)

RetrieveServiceAccountSecretName retrieves the name of the secret associated with a given service account.

func (*NamespacedPodReflector) ShouldUpdateShadowPod added in v0.6.0

func (npr *NamespacedPodReflector) ShouldUpdateShadowPod(ctx context.Context, shadow, target *vkv1alpha1.ShadowPod) bool

ShouldUpdateShadowPod checks whether it is necessary to update the remote shadowpod, based on the forged one.

func (*NamespacedPodReflector) Stats

Stats retrieves the stats of the reflected pods.

type PodHandler

type PodHandler interface {
	// List returns the list of reflected pods.
	List(context.Context) ([]*corev1.Pod, error)
	// Exec executes a command in a container of a reflected pod.
	Exec(ctx context.Context, namespace, pod, container string, cmd []string, attach api.AttachIO) error
	// Logs retrieves the logs of a container of a reflected pod.
	Logs(ctx context.Context, namespace, pod, container string, opts api.ContainerLogOpts) (io.ReadCloser, error)
	// Stats retrieves the stats of the reflected pods.
	Stats(ctx context.Context) (*statsv1alpha1.Summary, error)
}

PodHandler exposes an interface to interact with pods offloaded to the remote cluster.

type PodInfo

type PodInfo struct {
	PreventCreationUntilSeen bool

	Restarts  int32
	RemoteUID types.UID

	ServiceAccountSecret string
	OriginalIP           string
	TranslatedIP         string
}

PodInfo contains information about known pods.

type PodReflector

type PodReflector struct {
	manager.Reflector
	// contains filtered or unexported fields
}

PodReflector manages the Pod reflection towards a remote cluster.

func NewPodReflector

func NewPodReflector(
	remoteRESTConfig *rest.Config,
	remoteMetricsFactory MetricsFactory,
	ipamclient ipam.IpamClient,
	enableAPIServerSupport bool,
	workers uint) *PodReflector

NewPodReflector returns a new PodReflector instance.

func (*PodReflector) Exec

func (pr *PodReflector) Exec(ctx context.Context, namespace, pod, container string, cmd []string, attach api.AttachIO) error

Exec executes a command in a container of a reflected pod.

func (*PodReflector) KubernetesServiceIPGetter added in v0.5.0

func (pr *PodReflector) KubernetesServiceIPGetter() func(ctx context.Context) (string, error)

KubernetesServiceIPGetter returns a function to retrieve the IP associated with the kubernetes.default service.

func (*PodReflector) List

func (pr *PodReflector) List(_ context.Context) ([]*corev1.Pod, error)

List returns the list of reflected pods.

func (*PodReflector) Logs

func (pr *PodReflector) Logs(ctx context.Context, namespace, pod, container string, opts api.ContainerLogOpts) (io.ReadCloser, error)

Logs retrieves the logs of a container of a reflected pod.

func (*PodReflector) NewFallback

NewFallback returns a new FallbackReflector instance.

func (*PodReflector) NewNamespaced

NewNamespaced returns a new NamespacedPodReflector instance.

func (*PodReflector) Start

func (pr *PodReflector) Start(ctx context.Context, opts *options.ReflectorOpts)

Start starts the reflector.

func (*PodReflector) Stats

Stats retrieves the stats of the reflected pods.

func (*PodReflector) StopNamespace

func (pr *PodReflector) StopNamespace(local, remote string)

StopNamespace stops the reflection for a given namespace.

Jump to

Keyboard shortcuts

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