Documentation ¶
Overview ¶
Package workload implements the reflection logic for pods.
Index ¶
- Constants
- type FallbackPodReflector
- type MetricsFactory
- type NamespacedPodHandler
- type NamespacedPodReflector
- func (npr *NamespacedPodReflector) Exec(ctx context.Context, po, container string, cmd []string, attach api.AttachIO) error
- func (npr *NamespacedPodReflector) ForgetPodInfo(po string)
- func (npr *NamespacedPodReflector) Handle(ctx context.Context, name string) error
- func (npr *NamespacedPodReflector) HandleStatus(ctx context.Context, local, remote *corev1.Pod) error
- func (npr *NamespacedPodReflector) InferAdditionalRestarts(local, remote *corev1.PodStatus) int32
- func (npr *NamespacedPodReflector) Logs(ctx context.Context, po, container string, opts api.ContainerLogOpts) (io.ReadCloser, error)
- func (npr *NamespacedPodReflector) MapPodIP(ctx context.Context, info *PodInfo, original string) (string, error)
- func (npr *NamespacedPodReflector) RetrievePodInfo(po string) *PodInfo
- func (npr *NamespacedPodReflector) Stats(ctx context.Context) ([]statsv1alpha1.PodStats, error)
- type PodHandler
- type PodInfo
- type PodReflector
- func (pr *PodReflector) Exec(ctx context.Context, namespace, pod, container string, cmd []string, ...) error
- func (pr *PodReflector) List(_ context.Context) ([]*corev1.Pod, error)
- func (pr *PodReflector) Logs(ctx context.Context, namespace, pod, container string, ...) (io.ReadCloser, error)
- func (pr *PodReflector) NewFallback(opts *options.ReflectorOpts) manager.FallbackReflector
- func (pr *PodReflector) NewNamespaced(opts *options.NamespacedOpts) manager.NamespacedReflector
- func (pr *PodReflector) Start(ctx context.Context, opts *options.ReflectorOpts)
- func (pr *PodReflector) Stats(ctx context.Context) (*statsv1alpha1.Summary, error)
- func (pr *PodReflector) StopNamespace(local, remote string)
Constants ¶
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 ¶
func (fpr *FallbackPodReflector) Handle(ctx context.Context, key types.NamespacedName) error
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) 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) HandleStatus ¶
func (npr *NamespacedPodReflector) HandleStatus(ctx context.Context, local, remote *corev1.Pod) 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) Stats ¶
func (npr *NamespacedPodReflector) Stats(ctx context.Context) ([]statsv1alpha1.PodStats, error)
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 PodReflector ¶
PodReflector manages the Pod reflection towards a remote cluster.
func NewPodReflector ¶
func NewPodReflector( remoteRESTConfig *rest.Config, remoteMetricsFactory MetricsFactory, ipamclient ipam.IpamClient, 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) 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 ¶
func (pr *PodReflector) NewFallback(opts *options.ReflectorOpts) manager.FallbackReflector
NewFallback returns a new FallbackReflector instance.
func (*PodReflector) NewNamespaced ¶
func (pr *PodReflector) NewNamespaced(opts *options.NamespacedOpts) manager.NamespacedReflector
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 ¶
func (pr *PodReflector) Stats(ctx context.Context) (*statsv1alpha1.Summary, error)
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.