Documentation ¶
Overview ¶
Package workload implements the reflection logic for pods.
Index ¶
- Constants
- type FallbackPodReflector
- type MetricsFactory
- type NamespacedPodHandler
- type NamespacedPodReflector
- func (npr *NamespacedPodReflector) Attach(ctx context.Context, po, container string, attach api.AttachIO) error
- func (npr *NamespacedPodReflector) Exec(ctx context.Context, po, container string, cmd []string, attach api.AttachIO) error
- func (npr *NamespacedPodReflector) ForgeShadowPod(ctx context.Context, local *corev1.Pod, shadow *vkv1alpha1.ShadowPod, ...) (*vkv1alpha1.ShadowPod, error)
- func (npr *NamespacedPodReflector) ForgetPodInfo(po string)
- func (npr *NamespacedPodReflector) Handle(ctx context.Context, name string) error
- func (npr *NamespacedPodReflector) HandleLabels(ctx context.Context, local *corev1.Pod) error
- func (npr *NamespacedPodReflector) HandleStatus(ctx context.Context, local, remote *corev1.Pod, info *PodInfo) 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) PortForward(ctx context.Context, name string, port int32, stream io.ReadWriteCloser) error
- func (npr *NamespacedPodReflector) RetrieveLegacyServiceAccountSecretName(info *PodInfo, saName string) (string, error)
- func (npr *NamespacedPodReflector) RetrievePodInfo(po string) *PodInfo
- func (npr *NamespacedPodReflector) ShouldUpdateShadowPod(ctx context.Context, shadow, target *vkv1alpha1.ShadowPod) bool
- func (npr *NamespacedPodReflector) Stats(ctx context.Context) ([]statsv1alpha1.PodStats, error)
- type PodHandler
- type PodInfo
- type PodReflector
- func (pr *PodReflector) Attach(ctx context.Context, namespace, pod, container string, attach api.AttachIO) error
- func (pr *PodReflector) Exec(ctx context.Context, namespace, pod, container string, cmd []string, ...) error
- func (pr *PodReflector) KubernetesServiceIPGetter() func(ctx context.Context) (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) PortForward(ctx context.Context, namespace, pod string, port int32, ...) error
- 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)
- type PodReflectorConfig
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 // Attach attaches to a process that is already running inside an existing container of a reflected pod. Attach(ctx context.Context, pod, container string, attach api.AttachIO) error // PortForward forwards a connection from local to the ports of a reflected pod. PortForward(ctx context.Context, name string, port int32, stream io.ReadWriteCloser) 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) Attach ¶ added in v0.7.0
func (npr *NamespacedPodReflector) Attach(ctx context.Context, po, container string, attach api.AttachIO) error
Attach attaches to a process that is already running inside an existing container of a reflected pod.
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
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) PortForward ¶ added in v0.7.1
func (npr *NamespacedPodReflector) PortForward(ctx context.Context, name string, port int32, stream io.ReadWriteCloser) error
PortForward forwards a connection from local to the ports of a reflected pod.
func (*NamespacedPodReflector) RetrieveLegacyServiceAccountSecretName ¶ added in v0.7.0
func (npr *NamespacedPodReflector) RetrieveLegacyServiceAccountSecretName(info *PodInfo, saName string) (string, error)
RetrieveLegacyServiceAccountSecretName retrieves the name of the secret associated with a given service account (using the legacy approach).
func (*NamespacedPodReflector) RetrievePodInfo ¶
func (npr *NamespacedPodReflector) RetrievePodInfo(po string) *PodInfo
RetrievePodInfo retrieves the pod information regarding a given pod.
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 ¶
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 // Attach attaches to a process that is already running inside an existing container of a reflected pod. Attach(ctx context.Context, namespace, pod, container string, attach api.AttachIO) error // PortForward forwards a connection from local to the ports of a reflected pod. PortForward(ctx context.Context, namespace, pod string, port int32, stream io.ReadWriteCloser) 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 ¶
PodReflector manages the Pod reflection towards a remote cluster.
func NewPodReflector ¶
func NewPodReflector( remoteRESTConfig *rest.Config, remoteMetricsFactory MetricsFactory, ipamclient ipam.IpamClient, config *PodReflectorConfig, workers uint) *PodReflector
NewPodReflector returns a new PodReflector instance.
func (*PodReflector) Attach ¶ added in v0.7.0
func (pr *PodReflector) Attach(ctx context.Context, namespace, pod, container string, attach api.AttachIO) error
Attach attaches to a process that is already running inside an existing container of a reflected pod.
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) 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) PortForward ¶ added in v0.7.1
func (pr *PodReflector) PortForward(ctx context.Context, namespace, pod string, port int32, stream io.ReadWriteCloser) error
PortForward forwards a connection from local to the ports of a reflected pod.
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.
type PodReflectorConfig ¶ added in v0.8.0
type PodReflectorConfig struct { APIServerSupport forge.APIServerSupportType DisableIPReflection bool HomeAPIServerHost string HomeAPIServerPort string }
PodReflectorConfig represents the configuration of a PodReflector.