podpercon

package module
v0.0.0-...-80bda5f Latest Latest
Warning

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

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

README

PodPerConn

Pod Per Conn accepts an incoming connection and spawns a new pod, then forwards the connection to the new pod.

This is forwarded as a basic TCP forwarder without regard to the underlying protocol.

Copyright 2022 Google LLC. This is not an official Google Product.

Design

Initial Setup
  1. Load template Deployment.
  2. Verify connectivity to k8s cluster.
  3. Start listening for connections.
Per-Connection
  1. Accept incoming connection.
  2. Attempt spawning a new pod that exposes exactly one port.
  3. Start forwarding traffic to port on new pod.
  4. On connection close, shut down deployment and close remaining connection.

Resources

Documentation

Index

Constants

View Source
const (
	DEFAULT_NAMESPACE = "default"
	UNIQUEID_LABEL    = "uniqid"
	APP_LABEL         = "app"
)

Variables

This section is empty.

Functions

func GetFirstPortFromPod

func GetFirstPortFromPod(p *corev1.Pod, podLog log.Logger) (uint16, error)

func NewContainerProxyFactory

func NewContainerProxyFactory(controller *ContainerController, deploymentTimeout time.Duration) func(net.Conn) *ContainerProxy

func RandID

func RandID() string

Generate a pseudorandom 40 bit ID, 8 chars long

func WithCAPath

func WithCAPath(caPath string) func(*ContainerController)

func WithCertPath

func WithCertPath(certPath string) func(*ContainerController)

func WithDeploymentPath

func WithDeploymentPath(deploymentPath string) func(*ContainerController)

func WithEndpoint

func WithEndpoint(endpoint string) func(*ContainerController)

func WithKeyPath

func WithKeyPath(keyPath string) func(*ContainerController)

func WithNamespace

func WithNamespace(namespace string) func(*ContainerController)

Types

type ContainerController

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

func NewContainerController

func NewContainerController(opts ...ContainerControllerOpt) (*ContainerController, error)

func (*ContainerController) CheckServerVersion

func (c *ContainerController) CheckServerVersion() error

func (*ContainerController) DeleteDeployment

func (c *ContainerController) DeleteDeployment(dep *appsv1.Deployment) error

func (*ContainerController) GetPodsForDeployment

func (c *ContainerController) GetPodsForDeployment(dep *appsv1.Deployment) ([]corev1.Pod, error)

func (*ContainerController) MakeDeployment

func (c *ContainerController) MakeDeployment(ctx context.Context, uniqid string) (*appsv1.Deployment, error)

func (*ContainerController) MakeDeploymentAndWaitForReady

func (c *ContainerController) MakeDeploymentAndWaitForReady(ctx context.Context, uniqid string) (*appsv1.Deployment, error)

TODO: delete deployment on failure

type ContainerControllerOpt

type ContainerControllerOpt func(*ContainerController)

type ContainerProxy

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

We create one of these per connection

func NewContainerProxy

func NewContainerProxy(controller *ContainerController, client net.Conn) *ContainerProxy

func (*ContainerProxy) Run

func (p *ContainerProxy) Run(ctx context.Context) error

type Listener

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

func NewListener

func NewListener(controller *ContainerController, port uint16, deploymentTimeout, sessionTimeout time.Duration) *Listener

func (*Listener) HandleConn

func (l *Listener) HandleConn(c net.Conn)

func (*Listener) ListenAndServe

func (l *Listener) ListenAndServe() error

type LoadedObject

type LoadedObject struct {
	GroupVersionKind schema.GroupVersionKind
	Object           runtime.Object
}

func LoadObjectsFromFile

func LoadObjectsFromFile(fname string) ([]LoadedObject, error)

func (*LoadedObject) GetDeployment

func (lo *LoadedObject) GetDeployment() *appsv1.Deployment

Converts LoadedObject to Deployment, or nil if not a deployment

Directories

Path Synopsis
cmd
Log is a separate package to provide access restrictions to the singleton.
Log is a separate package to provide access restrictions to the singleton.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳