proxier

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Description: This file has the package proxier.

Package proxier has helpers for creating proxier instances

Description: This file has the package proxier.

Description: This file has the package proxier.

Index

Constants

View Source
const PodKind = "Pod"

Variables

View Source
var (
	// ErrAlreadyExists is returned when we've already created a
	// port-forward for this service. This can happen when an update event
	// is recieved for a service that we've already created a port-forward
	// for. This should generally be ignored but may be useful to log a
	// warning about.
	ErrAlreadyExists = errors.New("already have a port-forward for this service")
)

Contains error types that are returned by the port-forward worker.

Functions

func NewPortForwarder

func NewPortForwarder(ctx context.Context, k kubernetes.Interface,
	r *rest.Config, log logrus.FieldLogger, opts *ProxyOpts) (chan<- PortForwardRequest, <-chan struct{}, *worker, error)

NewPortForwarder creates a new port-forward worker that handles creating port-forwards and destroying port-forwards.

nolint:gocritic,golint,revive // Why: It's by design that we're returning an unexported type.

Types

type CreatePortForwardRequest

type CreatePortForwardRequest struct {
	// Service is the service this port-forward implements.
	Service ServiceInfo

	// Hostnames are the DNS entries to inject into our host's DNS
	// for this port-forward. This will be attached to the IP that
	// is created for this service.
	Hostnames []string

	// Ports are the ports this port-forward exposes
	Ports []string

	// Endpoint is the specific pod to use for this service.
	Endpoint *PodInfo

	// Recreate specifies if this should be recreated if it already
	// exists
	Recreate       bool
	RecreateReason string
}

CreatePortForwardRequest is a request to create port-forward

type DeletePortForwardRequest

type DeletePortForwardRequest struct {
	// Service is the service that should delete being port-forwarded
	Service ServiceInfo

	// IsShuttingDown denotes if the entire process is shutting down as
	// opposed to a single port-forward, or group, being deleted.
	IsShuttingDown bool
}

DeletePortForwardRequest is a request to delete a port-forward

type PodInfo

type PodInfo struct {
	// Name is the name of this pod
	Name string

	// Namespace is the namespace this pod is in
	Namespace string
}

func (*PodInfo) Key

func (s *PodInfo) Key() string

type PortForwardConnection

type PortForwardConnection struct {
	Service      ServiceInfo
	Pod          PodInfo
	Status       PortForwardStatus
	StatusReason string

	// IP that this port-forward allocates
	IP        netip.Addr
	Hostnames []string

	// Ports is a local -> remote port list
	Ports []string
	// contains filtered or unexported fields
}

PortForwardConnection is a port-forward that is managed by the port-forward worker.

type PortForwardRequest

type PortForwardRequest struct {
	DeletePortForwardRequest *DeletePortForwardRequest
	CreatePortForwardRequest *CreatePortForwardRequest
}

PortForwardRequest is a port-forward request, the non-nil struct is the type of request this is. There should only ever be one non-nil struct.

type PortForwardStatus

type PortForwardStatus string
var (
	PortForwardStatusRunning    PortForwardStatus = "running"
	PortForwardStatusRecreating PortForwardStatus = "recreating"
	PortForwardStatusWaiting    PortForwardStatus = "waiting"
)

type Proxier

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

Proxier handles creating an maintaining proxies to a remote Kubernetes service

func NewProxier

func NewProxier(ctx context.Context, k kubernetes.Interface, kconf *rest.Config, log logrus.FieldLogger, opts *ProxyOpts) (*Proxier, error)

NewProxier creates a new proxier instance

func (*Proxier) IsStable added in v1.12.0

func (p *Proxier) IsStable() bool

IsStable is a pass-through function to *worker.isStable. This is mostly to determine if the initial queue has been drained by checking if the worker that the proxier is using has created, deleted, or updated a port-forward in the last 2 seconds.

func (*Proxier) List

func (p *Proxier) List(ctx context.Context) ([]ServiceStatus, error)

func (*Proxier) Start

func (p *Proxier) Start(ctx context.Context) error

Start starts the proxier TODO(jaredallard): replace raw cluster domain with options struct, maybe also move into NewProxier

type ProxyOpts

type ProxyOpts struct {
	ClusterDomain string
	IPCidr        string

	// SkipNamespaces is a list of namespaces to skip when forwarding
	// services.
	SkipNamespaces []string
}

type ServiceInfo

type ServiceInfo struct {
	// Name is the name of this service
	Name string

	// Namespace is the namespace of this service
	Namespace string
}

func (*ServiceInfo) Key

func (s *ServiceInfo) Key() string

type ServiceStatus

type ServiceStatus struct {
	ServiceInfo ServiceInfo

	Endpoint PodInfo

	// Statuses is dependent on the number of tunnels that exist for this
	// connection. Generally this is one, since a service is usually one
	// connection. Currently only one is supported, but in the future
	// certain services will have more than one.
	Statuses []PortForwardStatus

	// Reason is the reason that this service is in this status.
	// This is generally only set for services that are in a
	// non-running state.
	Reason string

	// IP is the IP address of this tunnel
	IP string

	// Ports are the ports this service is exposing
	Ports []string
}

Jump to

Keyboard shortcuts

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