ipvs

package
v0.0.0-...-501ccff Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KernelModuleIPVS is the kernel module "ip_vs"
	KernelModuleIPVS string = "ip_vs"
	// KernelModuleIPVSRR is the kernel module "ip_vs_rr"
	KernelModuleIPVSRR string = "ip_vs_rr"
	// KernelModuleIPVSWRR is the kernel module "ip_vs_wrr"
	KernelModuleIPVSWRR string = "ip_vs_wrr"
	// KernelModuleIPVSSH is the kernel module "ip_vs_sh"
	KernelModuleIPVSSH string = "ip_vs_sh"
	// KernelModuleNfConntrackIPV4 is the module "nf_conntrack_ipv4"
	KernelModuleNfConntrackIPV4 string = "nf_conntrack_ipv4"
	// KernelModuleNfConntrack is the kernel module "nf_conntrack"
	KernelModuleNfConntrack string = "nf_conntrack"
)

IPVS required kernel modules.

Variables

This section is empty.

Functions

func EnsureSysctl

func EnsureSysctl(sysctl sysInterface, name string, newVal int) error

EnsureSysctl sets a kernel sysctl to a given numeric value.

func GetRequiredIPVSModules

func GetRequiredIPVSModules(kernelVersion *version.Version) []string

GetRequiredIPVSModules returns the required ipvs modules for the given linux kernel version.

func NewSysInterface

func NewSysInterface() sysInterface

New returns a new Interface for accessing sysctl

Types

type Destination

type Destination struct {
	IP   string
	Port int32
	// contains filtered or unexported fields
}

Destination represents a virtual server's destination. This structure should not hold any static information (e.g. weight) to save memory. The data types of this structure should match the data types given by the KPNG server to avoid type casting and parsing, saving cpu.

func (*Destination) Equal

func (d *Destination) Equal(o *Destination) bool

Equal compares two destinations and their virtual servers, is used for diffstore equality assertion.

func (*Destination) IPPort

func (d *Destination) IPPort() string

IPPort return combination of IP and Port for the destination.

func (*Destination) Key

func (d *Destination) Key() string

Key returns a combination of ip, port and protocol of the virtual server.

type KernelHandler

type KernelHandler interface {
	GetModules() ([]string, error)
	GetKernelVersion() (string, error)
}

KernelHandler can handle the current installed kernel modules.

type LinuxKernelHandler

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

LinuxKernelHandler implements KernelHandler interface.

func NewLinuxKernelHandler

func NewLinuxKernelHandler() *LinuxKernelHandler

NewLinuxKernelHandler initializes LinuxKernelHandler with exec.

func (*LinuxKernelHandler) GetKernelVersion

func (handle *LinuxKernelHandler) GetKernelVersion() (string, error)

GetKernelVersion returns currently running kernel version.

func (*LinuxKernelHandler) GetModules

func (handle *LinuxKernelHandler) GetModules() ([]string, error)

GetModules returns all installed kernel modules.

type Manager

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

Manager acts as a proxy between backend and IPVS operations, leverages diffstore to maintain state, executes only the changes when triggered by backend.

func NewManager

func NewManager(schedulingMethod string, weight int32, ipInterface string) *Manager

func (*Manager) AddDestination

func (m *Manager) AddDestination(destination *Destination, virtualServer *VirtualServer)

AddDestination instead of directly adding destination to virtual server, adds destination to destination diffstore, actions will be taken only in case of create, update and delete.

func (*Manager) Apply

func (m *Manager) Apply()

Apply has side effects. Apply should be called after processing fullstate callback, done will iterate over changes from all the diffstores and create, update and delete required objects accordingly.

func (*Manager) ApplyServer

func (m *Manager) ApplyServer(virtualServer *VirtualServer)

ApplyServer instead of directly creating the server, adds the server config to the service diffstore, actions will be taken only in case of create, update and delete.

func (*Manager) BindServerToInterface

func (m *Manager) BindServerToInterface(server *VirtualServer)

BindServerToInterface instead of directly binding ip to interface, adds it to the ip store. actions will be taken only in case of create and delete.

func (*Manager) Done

func (m *Manager) Done()

Done calls Done on all diffstores for computing diffs.

func (*Manager) Reset

func (m *Manager) Reset()

Reset resets all the diffstores, should be called before processing the fullstate callback.

func (*Manager) Setup

func (m *Manager) Setup() error

type VirtualServer

type VirtualServer struct {
	IP       string
	Port     int32
	Protocol localv1.Protocol
	Timeout  int32
}

VirtualServer represents a virtual server. This structure should not hold any static information (eg. scheduling method) to save memory. The data types of this structure should match the data types given by the KPNG server to avoid type casting and parsing, saving cpu.

func (VirtualServer) Equal

func (vs VirtualServer) Equal(o *VirtualServer) bool

Equal compares two virtual servers, is used for diffstore equality assertion.

func (VirtualServer) IPPort

func (vs VirtualServer) IPPort() string

IPPort return combination of IP and port for the server

func (VirtualServer) Key

func (vs VirtualServer) Key() string

Key returns a combination of IP, Port and Protocol of the virtual server.

Jump to

Keyboard shortcuts

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