Documentation ¶
Index ¶
- Constants
- func CanUseIPVSProxier(handle KernelHandler, ipsetver IPSetVersioner) (bool, error)
- func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, ...) (encounteredError bool)
- type IPGetter
- type IPSet
- type IPSetVersioner
- type KernelHandler
- type LinuxKernelHandler
- type NetLinkHandle
- type Proxier
- func (proxier *Proxier) OnEndpointsAdd(endpoints *api.Endpoints)
- func (proxier *Proxier) OnEndpointsDelete(endpoints *api.Endpoints)
- func (proxier *Proxier) OnEndpointsSynced()
- func (proxier *Proxier) OnEndpointsUpdate(oldEndpoints, endpoints *api.Endpoints)
- func (proxier *Proxier) OnServiceAdd(service *api.Service)
- func (proxier *Proxier) OnServiceDelete(service *api.Service)
- func (proxier *Proxier) OnServiceSynced()
- func (proxier *Proxier) OnServiceUpdate(oldService, service *api.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" // KubeLoopBackIPSet is used to store endpoints dst ip:port, source ip for solving hairpin purpose. KubeLoopBackIPSet = "KUBE-LOOP-BACK" // KubeClusterIPSet is used to store service cluster ip + port for masquerade purpose. KubeClusterIPSet = "KUBE-CLUSTER-IP" // KubeExternalIPSet is used to store service external ip + port for masquerade and filter purpose. KubeExternalIPSet = "KUBE-EXTERNAL-IP" // KubeLoadBalancerSet is used to store service load balancer ingress ip + port, it is the service lb portal. KubeLoadBalancerSet = "KUBE-LOAD-BALANCER" // KubeLoadBalancerIngressLocalSet is used to store service load balancer ingress ip + port with externalTrafficPolicy=local. KubeLoadBalancerIngressLocalSet = "KUBE-LB-INGRESS-LOCAL" // KubeLoadBalancerSourceIPSet is used to store service load balancer ingress ip + port + source IP for packet filter purpose. KubeLoadBalancerSourceIPSet = "KUBE-LOAD-BALANCER-SOURCE-IP" // KubeLoadBalancerSourceCIDRSet is used to store service load balancer ingress ip + port + source cidr for packet filter purpose. KubeLoadBalancerSourceCIDRSet = "KUBE-LOAD-BALANCER-SOURCE-CIDR" // KubeNodePortSetTCP is used to store the nodeport TCP port for masquerade purpose. KubeNodePortSetTCP = "KUBE-NODE-PORT-TCP" // KubeNodePortLocalSetTCP is used to store the nodeport TCP port with externalTrafficPolicy=local. KubeNodePortLocalSetTCP = "KUBE-NODE-PORT-LOCAL-TCP" // KubeNodePortSetUDP is used to store the nodeport UDP port for masquerade purpose. KubeNodePortSetUDP = "KUBE-NODE-PORT-UDP" // KubeNodePortLocalSetUDP is used to store the nodeport UDP port with externalTrafficPolicy=local. KubeNodePortLocalSetUDP = "KUBE-NODE-PORT-LOCAL-UDP" )
const ( // KubeFireWallChain is the kubernetes firewall chain. KubeFireWallChain utiliptables.Chain = "KUBE-FIRE-WALL" // KubeMarkMasqChain is the mark-for-masquerade chain KubeMarkMasqChain utiliptables.Chain = "KUBE-MARK-MASQ" // KubeNodePortChain is the kubernetes node port chain KubeNodePortChain utiliptables.Chain = "KUBE-NODE-PORT" // KubeMarkDropChain is the mark-for-drop chain KubeMarkDropChain utiliptables.Chain = "KUBE-MARK-DROP" // KubeForwardChain is the kubernetes forward chain KubeForwardChain utiliptables.Chain = "KUBE-FORWARD" // DefaultScheduler is the default ipvs scheduler algorithm - round robin. DefaultScheduler = "rr" // DefaultDummyDevice is the default dummy interface which ipvs service address will bind to it. DefaultDummyDevice = "kube-ipvs0" )
const EntryInvalidErr = "error adding entry %s to ipset %s"
EntryInvalidErr indicates if an ipset entry is invalid or not
Variables ¶
This section is empty.
Functions ¶
func CanUseIPVSProxier ¶
func CanUseIPVSProxier(handle KernelHandler, ipsetver IPSetVersioner) (bool, error)
CanUseIPVSProxier returns true if we can use the ipvs Proxier. This is determined by checking if all the required kernel modules can be loaded. It may return an error if it fails to get the kernel modules information without error, in which case it will also return false.
func CleanupLeftovers ¶
func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, cleanupIPVS bool) (encounteredError bool)
CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier.
Types ¶
type IPSetVersioner ¶ added in v1.9.0
IPSetVersioner can query the current ipset version.
type KernelHandler ¶ added in v1.10.0
KernelHandler can handle the current installed kernel modules.
type LinuxKernelHandler ¶ added in v1.10.0
type LinuxKernelHandler struct {
// contains filtered or unexported fields
}
LinuxKernelHandler implements KernelHandler interface.
func NewLinuxKernelHandler ¶ added in v1.10.0
func NewLinuxKernelHandler() *LinuxKernelHandler
NewLinuxKernelHandler initializes LinuxKernelHandler with exec.
func (*LinuxKernelHandler) GetModules ¶ added in v1.10.0
func (handle *LinuxKernelHandler) GetModules() ([]string, error)
GetModules returns all installed kernel modules.
type NetLinkHandle ¶ added in v1.9.0
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 // GetLocalAddresses returns all unique local type IP addresses based on filter device interface. If filter device is not given, // it will list all unique local type addresses. GetLocalAddresses(filterDev string) (sets.String, error) }
NetLinkHandle for revoke netlink interface
func NewNetLinkHandle ¶ added in v1.9.0
func NewNetLinkHandle() NetLinkHandle
NewNetLinkHandle will crate a new NetLinkHandle
type Proxier ¶
type Proxier struct {
// contains filtered or unexported fields
}
Proxier is an ipvs based proxy for connections between a localhost:lport and services that provide the actual backends.
func NewProxier ¶
func NewProxier(ipt utiliptables.Interface, ipvs utilipvs.Interface, ipset utilipset.Interface, sysctl utilsysctl.Interface, exec utilexec.Interface, syncPeriod time.Duration, minSyncPeriod time.Duration, excludeCIDRs []string, masqueradeAll bool, masqueradeBit int, clusterCIDR string, hostname string, nodeIP net.IP, recorder record.EventRecorder, healthzServer healthcheck.HealthzUpdater, scheduler string, nodePortAddresses []string, ) (*Proxier, error)
NewProxier returns a new Proxier given an iptables and ipvs Interface instance. Because of the iptables and ipvs logic, it is assumed that there is only a single Proxier active on a machine. An error will be returned if it fails to update or acquire the initial lock. Once a proxier is created, it will keep iptables and ipvs rules up to date in the background and will not terminate if a particular iptables or ipvs call fails.
func (*Proxier) OnEndpointsAdd ¶
OnEndpointsAdd is called whenever creation of new endpoints object is observed.
func (*Proxier) OnEndpointsDelete ¶
OnEndpointsDelete is called whenever deletion of an existing endpoints object is observed.
func (*Proxier) OnEndpointsSynced ¶
func (proxier *Proxier) OnEndpointsSynced()
OnEndpointsSynced is called once all the initial event handlers were called and the state is fully propagated to local cache.
func (*Proxier) OnEndpointsUpdate ¶
OnEndpointsUpdate is called whenever modification of an existing endpoints object is observed.
func (*Proxier) OnServiceAdd ¶
OnServiceAdd is called whenever creation of new service object is observed.
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 even 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.