ip

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ip contains logic for managing IP addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientProvider

type ClientProvider interface {
	GetClient() client.Client
}

ClientProvider is an interface for providing a Kubernetes client.

type Collector

type Collector struct{}

Collector collects IP addresses on all network interfaces.

func NewCollector

func NewCollector() *Collector

NewCollector returns a new Collector.

func (*Collector) Get

func (c *Collector) Get() (map[string]struct{}, error)

Get returns a set of IP addresses on all network interfaces.

type LoadBalancer

type LoadBalancer interface {
	AddRoute(ipPort string, upstreamAddrs []string, options ...upstream.ListOption) error
	Start() error
	Close() error
}

LoadBalancer is an interface for loadbalancer instances.

type LoadBalancerProvider

type LoadBalancerProvider interface {
	New(logger *zap.Logger) (LoadBalancer, error)
}

LoadBalancerProvider is a factory for LoadBalancer instances.

type Mapper

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

Mapper maps IP addresses on the host to Kubernetes Service resources.

func NewMapper

func NewMapper(ipSetProvider SetProvider, loadBalancerController LoadBalancerProvider, logger *zap.Logger) (*Mapper, error)

NewMapper returns a new Mapper.

func (*Mapper) Add

func (m *Mapper) Add(svcName string, hostPort, svcPort int) error

Add adds a new mapping for the given service name.

It will create a new load balancer and the related mappings.

If there is an existing mapping for another service, an error is returned.

func (*Mapper) Remove

func (m *Mapper) Remove(svcName string)

Remove removes the mapping for the given service name.

It will close any existing load balancer for that service and clear any related mappings.

type ServiceHandler

type ServiceHandler interface {
	Handle(svc *corev1.Service) error
}

ServiceHandler is an interface for handling Service resources.

type SetProvider

type SetProvider interface {
	Get() (map[string]struct{}, error)
}

SetProvider in an interface for getting a set of IP addresses.

type SetRefresher

type SetRefresher interface {
	Refresh() (ipSet map[string]struct{}, err error)
}

SetRefresher is an interface for refreshing IP sets.

type TCPLoadBalancerProvider

type TCPLoadBalancerProvider struct{}

TCPLoadBalancerProvider is a LoadBalancerProvider that creates and returns loadbalancer.TCP instances.

func (*TCPLoadBalancerProvider) New

New returns a new loadbalancer.TCP instance.

type Tracker

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

Tracker tracks changes on the IP sets on the host and updates Service resources accordingly.

func NewTracker

func NewTracker(refresher SetRefresher, clientProvider ClientProvider, serviceHandler ServiceHandler,
	period time.Duration, clck clock.Clock, logger *zap.Logger,
) (*Tracker, error)

NewTracker returns a new Tracker.

func (*Tracker) Run

func (t *Tracker) Run(ctx context.Context) error

Run runs the Tracker. It blocks until the context is canceled.

Jump to

Keyboard shortcuts

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