package ipvs
import "k8s.io/kubernetes/pkg/proxy/ipvs"
Index ¶
- Constants
- func CanUseIPVSProxier(ctx context.Context, ipvs utilipvs.Interface, ipsetver IPSetVersioner, scheduler string) error
- func CleanupLeftovers(ctx context.Context, ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface) (encounteredError bool)
- func GetUniqueRSName(vs *utilipvs.VirtualServer, rs *utilipvs.RealServer) string
- func NewDualStackProxier( ctx context.Context, ipts map[v1.IPFamily]utiliptables.Interface, ipvs utilipvs.Interface, ipset utilipset.Interface, sysctl utilsysctl.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, excludeCIDRs []string, strictARP bool, tcpTimeout time.Duration, tcpFinTimeout time.Duration, udpTimeout time.Duration, masqueradeAll bool, masqueradeBit int, localDetectors map[v1.IPFamily]proxyutil.LocalTrafficDetector, nodeName string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, scheduler string, nodePortAddresses []string, initOnly bool, ) (proxy.Provider, error)
- type GracefulTerminationManager
- func NewGracefulTerminationManager(ipvs utilipvs.Interface) *GracefulTerminationManager
- func (m *GracefulTerminationManager) GracefulDeleteRS(vs *utilipvs.VirtualServer, rs *utilipvs.RealServer) error
- func (m *GracefulTerminationManager) InTerminationList(uniqueRS string) bool
- func (m *GracefulTerminationManager) MoveRSOutofGracefulDeleteList(uniqueRS string) error
- func (m *GracefulTerminationManager) Run()
- type IPSet
- type IPSetVersioner
- type NetLinkHandle
- type Proxier
- func NewProxier( ctx context.Context, ipFamily v1.IPFamily, ipt utiliptables.Interface, ipvs utilipvs.Interface, ipset utilipset.Interface, sysctl utilsysctl.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, excludeCIDRs []string, strictARP bool, tcpTimeout time.Duration, tcpFinTimeout time.Duration, udpTimeout time.Duration, masqueradeAll bool, masqueradeBit int, localDetector proxyutil.LocalTrafficDetector, nodeName string, nodeIP net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, scheduler string, nodePortAddressStrings []string, initOnly bool, ) (*Proxier, error)
- func (proxier *Proxier) OnEndpointSliceAdd(endpointSlice *discovery.EndpointSlice)
- func (proxier *Proxier) OnEndpointSliceDelete(endpointSlice *discovery.EndpointSlice)
- func (proxier *Proxier) OnEndpointSliceUpdate(_, endpointSlice *discovery.EndpointSlice)
- func (proxier *Proxier) OnEndpointSlicesSynced()
- func (proxier *Proxier) OnNodeAdd(node *v1.Node)
- func (proxier *Proxier) OnNodeDelete(node *v1.Node)
- func (proxier *Proxier) OnNodeSynced()
- func (proxier *Proxier) OnNodeUpdate(oldNode, node *v1.Node)
- func (proxier *Proxier) OnServiceAdd(service *v1.Service)
- func (proxier *Proxier) OnServiceCIDRsChanged(_ []string)
- func (proxier *Proxier) OnServiceDelete(service *v1.Service)
- func (proxier *Proxier) OnServiceSynced()
- func (proxier *Proxier) OnServiceUpdate(oldService, service *v1.Service)
- func (proxier *Proxier) Sync()
- func (proxier *Proxier) SyncLoop()
Constants ¶
const ( // MinIPSetCheckVersion is the min ipset version we need. IPv6 is supported in ipset 6.x MinIPSetCheckVersion = "6.0" )
Functions ¶
func CanUseIPVSProxier ¶
func CanUseIPVSProxier(ctx context.Context, ipvs utilipvs.Interface, ipsetver IPSetVersioner, scheduler string) error
CanUseIPVSProxier checks if we can use the ipvs Proxier. The ipset version and the scheduler are checked. If any virtual servers (VS) already exist with the configured scheduler, we just return. Otherwise we check if a dummy VS can be configured with the configured scheduler. Kernel modules will be loaded automatically if necessary.
func CleanupLeftovers ¶
func CleanupLeftovers(ctx context.Context, ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface) (encounteredError bool)
CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier.
func GetUniqueRSName ¶
func GetUniqueRSName(vs *utilipvs.VirtualServer, rs *utilipvs.RealServer) string
GetUniqueRSName return a string type unique rs name with vs information
func NewDualStackProxier ¶
func NewDualStackProxier( ctx context.Context, ipts map[v1.IPFamily]utiliptables.Interface, ipvs utilipvs.Interface, ipset utilipset.Interface, sysctl utilsysctl.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, excludeCIDRs []string, strictARP bool, tcpTimeout time.Duration, tcpFinTimeout time.Duration, udpTimeout time.Duration, masqueradeAll bool, masqueradeBit int, localDetectors map[v1.IPFamily]proxyutil.LocalTrafficDetector, nodeName string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, scheduler string, nodePortAddresses []string, initOnly bool, ) (proxy.Provider, error)
NewDualStackProxier returns a new Proxier for dual-stack operation
Types ¶
type GracefulTerminationManager ¶
type GracefulTerminationManager struct {
// contains filtered or unexported fields
}
GracefulTerminationManager manage rs graceful termination information and do graceful termination work rsList is the rs list to graceful termination, ipvs is the ipvsinterface to do ipvs delete/update work
func NewGracefulTerminationManager ¶
func NewGracefulTerminationManager(ipvs utilipvs.Interface) *GracefulTerminationManager
NewGracefulTerminationManager create a gracefulTerminationManager to manage ipvs rs graceful termination work
func (*GracefulTerminationManager) GracefulDeleteRS ¶
func (m *GracefulTerminationManager) GracefulDeleteRS(vs *utilipvs.VirtualServer, rs *utilipvs.RealServer) error
GracefulDeleteRS to update rs weight to 0, and add rs to graceful terminate list
func (*GracefulTerminationManager) InTerminationList ¶
func (m *GracefulTerminationManager) InTerminationList(uniqueRS string) bool
InTerminationList to check whether specified unique rs name is in graceful termination list
func (*GracefulTerminationManager) MoveRSOutofGracefulDeleteList ¶
func (m *GracefulTerminationManager) MoveRSOutofGracefulDeleteList(uniqueRS string) error
MoveRSOutofGracefulDeleteList to delete an rs and remove it from the rsList immediately
func (*GracefulTerminationManager) Run ¶
func (m *GracefulTerminationManager) Run()
Run start a goroutine to try to delete rs in the graceful delete rsList with an interval 1 minute
type IPSet ¶
IPSet wraps util/ipset which is used by IPVS proxier.
func NewIPSet ¶
func NewIPSet(handle utilipset.Interface, name string, setType utilipset.Type, isIPv6 bool, comment string) *IPSet
NewIPSet initialize a new IPSet struct
type IPSetVersioner ¶
IPSetVersioner can query the current ipset version.
type NetLinkHandle ¶
type NetLinkHandle interface { // EnsureAddressBind checks if address is bound to the interface and, if not, binds it. If the address is already bound, return true. EnsureAddressBind(address, devName string) (exist bool, err error) // UnbindAddress unbind address from the interface UnbindAddress(address, devName string) error // EnsureDummyDevice checks if dummy device is exist and, if not, create one. If the dummy device is already exist, return true. EnsureDummyDevice(devName string) (exist bool, err error) // DeleteDummyDevice deletes the given dummy device by name. DeleteDummyDevice(devName string) error // ListBindAddress will list all IP addresses which are bound in a given interface ListBindAddress(devName string) ([]string, error) // GetAllLocalAddresses return all local addresses on the node. // Only the addresses of the current family are returned. // IPv6 link-local and loopback addresses are excluded. GetAllLocalAddresses() (sets.Set[string], error) // GetLocalAddresses return all local addresses for an interface. // Only the addresses of the current family are returned. // IPv6 link-local and loopback addresses are excluded. GetLocalAddresses(dev string) (sets.Set[string], error) // GetAllLocalAddressesExcept return all local addresses on the node, except from the passed dev. // This is not the same as to take the diff between GetAllLocalAddresses and GetLocalAddresses // since an address can be assigned to many interfaces. This problem raised // https://github.com/kubernetes/kubernetes/issues/114815 GetAllLocalAddressesExcept(dev string) (sets.Set[string], error) }
NetLinkHandle for revoke netlink interface
func NewNetLinkHandle ¶
func NewNetLinkHandle(isIPv6 bool) NetLinkHandle
NewNetLinkHandle will create a new NetLinkHandle
type Proxier ¶
type Proxier struct {
// contains filtered or unexported fields
}
Proxier is an ipvs-based proxy
func NewProxier ¶
func NewProxier( ctx context.Context, ipFamily v1.IPFamily, ipt utiliptables.Interface, ipvs utilipvs.Interface, ipset utilipset.Interface, sysctl utilsysctl.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, excludeCIDRs []string, strictARP bool, tcpTimeout time.Duration, tcpFinTimeout time.Duration, udpTimeout time.Duration, masqueradeAll bool, masqueradeBit int, localDetector proxyutil.LocalTrafficDetector, nodeName string, nodeIP net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, scheduler string, nodePortAddressStrings []string, initOnly bool, ) (*Proxier, error)
NewProxier returns a new single-stack IPVS proxier.
func (*Proxier) OnEndpointSliceAdd ¶
func (proxier *Proxier) OnEndpointSliceAdd(endpointSlice *discovery.EndpointSlice)
OnEndpointSliceAdd is called whenever creation of a new endpoint slice object is observed.
func (*Proxier) OnEndpointSliceDelete ¶
func (proxier *Proxier) OnEndpointSliceDelete(endpointSlice *discovery.EndpointSlice)
OnEndpointSliceDelete is called whenever deletion of an existing endpoint slice object is observed.
func (*Proxier) OnEndpointSliceUpdate ¶
func (proxier *Proxier) OnEndpointSliceUpdate(_, endpointSlice *discovery.EndpointSlice)
OnEndpointSliceUpdate is called whenever modification of an existing endpoint slice object is observed.
func (*Proxier) OnEndpointSlicesSynced ¶
func (proxier *Proxier) OnEndpointSlicesSynced()
OnEndpointSlicesSynced is called once all the initial event handlers were called and the state is fully propagated to local cache.
func (*Proxier) OnNodeAdd ¶
OnNodeAdd is called whenever creation of new node object is observed.
func (*Proxier) OnNodeDelete ¶
OnNodeDelete is called whenever deletion of an existing node object is observed.
func (*Proxier) OnNodeSynced ¶
func (proxier *Proxier) OnNodeSynced()
OnNodeSynced is called once all the initial event handlers were called and the state is fully propagated to local cache.
func (*Proxier) OnNodeUpdate ¶
OnNodeUpdate is called whenever modification of an existing node object is observed.
func (*Proxier) OnServiceAdd ¶
OnServiceAdd is called whenever creation of new service object is observed.
func (*Proxier) OnServiceCIDRsChanged ¶
OnServiceCIDRsChanged is called whenever a change is observed in any of the ServiceCIDRs, and provides complete list of service cidrs.
func (*Proxier) OnServiceDelete ¶
OnServiceDelete is called whenever deletion of an existing service object is observed.
func (*Proxier) OnServiceSynced ¶
func (proxier *Proxier) OnServiceSynced()
OnServiceSynced is called once all the initial event handlers were called and the state is fully propagated to local cache.
func (*Proxier) OnServiceUpdate ¶
OnServiceUpdate is called whenever modification of an existing service object is observed.
func (*Proxier) Sync ¶
func (proxier *Proxier) Sync()
Sync is called to synchronize the proxier state to iptables and ipvs as soon as possible.
func (*Proxier) SyncLoop ¶
func (proxier *Proxier) SyncLoop()
SyncLoop runs periodic work. This is expected to run as a goroutine or as the main loop of the app. It does not return.
Source Files ¶
graceful_termination.go ipset.go netlink.go netlink_linux.go proxier.go
Directories ¶
Path | Synopsis |
---|---|
pkg/proxy/ipvs/ipset | |
pkg/proxy/ipvs/ipset/testing | |
pkg/proxy/ipvs/testing | |
pkg/proxy/ipvs/util | |
pkg/proxy/ipvs/util/testing |
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 35 packages
- Last checked
- 3 hours ago –
Tools for package owners.