Documentation ¶
Index ¶
- func NewK8sServicePort(clusterIP net.IP, port int, proto v1.Protocol, opts ...K8sServicePortOption) k8sp.ServicePort
- func ProtoV1ToInt(p v1.Protocol) (uint8, error)
- func ProtoV1ToIntPanic(p v1.Protocol) uint8
- func ServicePortEqual(a, b k8sp.ServicePort) bool
- func ShouldAppendTopologyAwareEndpoint(nodeZone string, hintsAnnotation string, zoneHints sets.String) bool
- type DPSyncer
- type DPSyncerState
- type K8sServicePortOption
- func K8sSvcWithExternalIPs(ips []string) K8sServicePortOption
- func K8sSvcWithHintsAnnotation(hintsAnnotation string) K8sServicePortOption
- func K8sSvcWithLBSourceRangeIPs(ips []string) K8sServicePortOption
- func K8sSvcWithLoadBalancerIPs(ips []string) K8sServicePortOption
- func K8sSvcWithLocalOnly() K8sServicePortOption
- func K8sSvcWithNodePort(np int) K8sServicePortOption
- func K8sSvcWithStickyClientIP(seconds int) K8sServicePortOption
- type KubeProxy
- func (kp *KubeProxy) ConntrackFrontendHasBackend(ip net.IP, port uint16, backendIP net.IP, backendPort uint16, proto uint8) bool
- func (kp *KubeProxy) ConntrackScanEnd()
- func (kp *KubeProxy) ConntrackScanStart()
- func (kp *KubeProxy) OnHostIPsUpdate(IPs []net.IP)
- func (kp *KubeProxy) OnRouteDelete(k routes.Key)
- func (kp *KubeProxy) OnRouteUpdate(k routes.Key, v routes.Value)
- func (kp *KubeProxy) Stop()
- type Option
- type Proxy
- type RTCache
- func (rt *RTCache) Delete(k routes.Key) error
- func (rt *RTCache) DeleteV4(k routes.Key) error
- func (rt *RTCache) Lookup(addr ip.Addr) (routes.Value, bool)
- func (rt *RTCache) LookupV4(addr ip.V4Addr) (routes.Value, bool)
- func (rt *RTCache) Update(k routes.Key, v routes.Value) error
- func (rt *RTCache) UpdateV4(k routes.Key, v routes.Value) error
- func (rt *RTCache) WaitAfter(ctx context.Context, ...)
- type Routes
- type Syncer
- func (s *Syncer) Apply(state DPSyncerState) error
- func (s *Syncer) ConntrackFrontendHasBackend(ip net.IP, port uint16, backendIP net.IP, backendPort uint16, proto uint8) (ret bool)
- func (s *Syncer) ConntrackScanEnd()
- func (s *Syncer) ConntrackScanStart()
- func (s *Syncer) SetTriggerFn(f func())
- func (s *Syncer) Stop()
- func (s *Syncer) StopExpandNPFixup()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewK8sServicePort ¶
func NewK8sServicePort(clusterIP net.IP, port int, proto v1.Protocol, opts ...K8sServicePortOption) k8sp.ServicePort
NewK8sServicePort creates a new k8s ServicePort
func ProtoV1ToInt ¶
ProtoV1ToInt translates k8s v1.Protocol to its IANA number and returns error if the proto is not recognized
func ProtoV1ToIntPanic ¶
ProtoV1ToIntPanic translates k8s v1.Protocol to its IANA number and panics if the protocol is not recognized
func ServicePortEqual ¶
func ServicePortEqual(a, b k8sp.ServicePort) bool
ServicePortEqual compares if two k8sp.ServicePort are equal, that is all of their methods return equal values, i.e., they may differ in implementation, but present themselves equally. String() is not considered as it may differ for debugging reasons.
Types ¶
type DPSyncer ¶
type DPSyncer interface { Apply(state DPSyncerState) error ConntrackScanStart() ConntrackScanEnd() ConntrackFrontendHasBackend(ip net.IP, port uint16, backendIP net.IP, backendPort uint16, proto uint8) bool Stop() SetTriggerFn(func()) }
DPSyncer is an interface representing the dataplane syncer that applies the observed changes to the dataplane
type DPSyncerState ¶
type DPSyncerState struct { SvcMap k8sp.ServiceMap EpsMap k8sp.EndpointsMap NodeZone string }
DPSyncerState groups the information passed to the DPSyncer's Apply
type K8sServicePortOption ¶
type K8sServicePortOption func(interface{})
K8sServicePortOption defines options for NewK8sServicePort
func K8sSvcWithExternalIPs ¶
func K8sSvcWithExternalIPs(ips []string) K8sServicePortOption
K8sSvcWithExternalIPs sets ExternalIPs
func K8sSvcWithHintsAnnotation ¶
func K8sSvcWithHintsAnnotation(hintsAnnotation string) K8sServicePortOption
K8sSvcWithHintsAnnotation sets hints annotation to service info object
func K8sSvcWithLBSourceRangeIPs ¶
func K8sSvcWithLBSourceRangeIPs(ips []string) K8sServicePortOption
K8sSvcWithLBSourceRangeIPs sets LBSourcePortRangeIPs
func K8sSvcWithLoadBalancerIPs ¶
func K8sSvcWithLoadBalancerIPs(ips []string) K8sServicePortOption
K8sSvcWithLoadBalancerIPs set LoadBalancerIPStrings
func K8sSvcWithLocalOnly ¶
func K8sSvcWithLocalOnly() K8sServicePortOption
K8sSvcWithLocalOnly sets OnlyNodeLocalEndpoints=true
func K8sSvcWithNodePort ¶
func K8sSvcWithNodePort(np int) K8sServicePortOption
K8sSvcWithNodePort sets the nodeport
func K8sSvcWithStickyClientIP ¶
func K8sSvcWithStickyClientIP(seconds int) K8sServicePortOption
K8sSvcWithStickyClientIP sets ServiceAffinityClientIP to seconds
type KubeProxy ¶
type KubeProxy struct {
// contains filtered or unexported fields
}
KubeProxy is a wrapper of Proxy that deals with higher level issue like configuration, restarting etc.
func StartKubeProxy ¶
func StartKubeProxy(k8s kubernetes.Interface, hostname string, bpfMaps *bpfmap.Maps, opts ...Option) (*KubeProxy, error)
StartKubeProxy start a new kube-proxy if there was no error
func (*KubeProxy) ConntrackFrontendHasBackend ¶
func (kp *KubeProxy) ConntrackFrontendHasBackend(ip net.IP, port uint16, backendIP net.IP, backendPort uint16, proto uint8) bool
ConntrackFrontendHasBackend to satisfy conntrack.NATChecker - forwards to syncer.
func (*KubeProxy) ConntrackScanEnd ¶
func (kp *KubeProxy) ConntrackScanEnd()
ConntrackScanEnd to satisfy conntrack.NATChecker - forwards to syncer.
func (*KubeProxy) ConntrackScanStart ¶
func (kp *KubeProxy) ConntrackScanStart()
ConntrackScanStart to satisfy conntrack.NATChecker - forwards to syncer.
func (*KubeProxy) OnHostIPsUpdate ¶
OnHostIPsUpdate should be used by an external user to update the proxy's list of host IPs
func (*KubeProxy) OnRouteDelete ¶
OnRouteDelete should be used to update the internal state of routing tables
func (*KubeProxy) OnRouteUpdate ¶
OnRouteUpdate should be used to update the internal state of routing tables
type Option ¶
Option defines Proxy options
func WithImmediateSync ¶
func WithImmediateSync() Option
WithImmediateSync triggers sync with dataplane on immediately on every update
func WithMinSyncPeriod ¶
WithMinSyncPeriod sets the minimum duration between two attempts to sync with the dataplane
func WithTopologyNodeZone ¶
WithTopologyNodeZone sets the topology node zone
type Proxy ¶
type Proxy interface {
// Stop stops the proxy and waits for its exit
Stop()
}
Proxy watches for updates of Services and Endpoints, maintains their mapping and programs it into the dataplane
type RTCache ¶
type RTCache struct {
// contains filtered or unexported fields
}
RTCache is a lookup data structure that allow inserting and deleting routes and to do a LPM prefix match for IP addresses
func (*RTCache) WaitAfter ¶
func (rt *RTCache) WaitAfter(ctx context.Context, fn func(lookup func(addr ip.Addr) (routes.Value, bool)) bool)
WaitAfter executes a function and if it returns false, it blocks until another update or until the provided context is canceled. The function can do only lookups as the state of the cache is read-locked. It must use the provided lookup function.
type Routes ¶
type Routes interface { Lookup(ip.Addr) (routes.Value, bool) WaitAfter(ctx context.Context, fn func(lookup func(addr ip.Addr) (routes.Value, bool)) bool) }
Routes is an interface to query routes
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer is an implementation of DPSyncer interface. It is not thread safe and should be called only once at a time
func NewSyncer ¶
func NewSyncer(nodePortIPs []net.IP, svcsmap *cachingmap.CachingMap[nat.FrontendKey, nat.FrontendValue], epsmap *cachingmap.CachingMap[nat.BackendKey, nat.BackendValue], affmap maps.Map, rt Routes) (*Syncer, error)
NewSyncer returns a new Syncer
func (*Syncer) Apply ¶
func (s *Syncer) Apply(state DPSyncerState) error
Apply applies the new state
func (*Syncer) ConntrackFrontendHasBackend ¶
func (s *Syncer) ConntrackFrontendHasBackend(ip net.IP, port uint16, backendIP net.IP, backendPort uint16, proto uint8) (ret bool)
ConntrackFrontendHasBackend returns true if the given front-backend pair exists
func (*Syncer) ConntrackScanEnd ¶
func (s *Syncer) ConntrackScanEnd()
ConntrackScanEnd enables Apply and frees active maps
func (*Syncer) ConntrackScanStart ¶
func (s *Syncer) ConntrackScanStart()
ConntrackScanStart excludes Apply from running and builds the active maps from ConntrackFrontendHasBackend
func (*Syncer) SetTriggerFn ¶
func (s *Syncer) SetTriggerFn(f func())
func (*Syncer) StopExpandNPFixup ¶
func (s *Syncer) StopExpandNPFixup()