common

package
v0.0.0-alpha.0....-18a57d7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 41 Imported by: 3

Documentation

Overview

Package common contains the OpenShift SDN code that is shared between master, node, and proxy

Index

Constants

View Source
const (

	// DefaultPollInterval default poll interval used for egress node reachability check
	DefaultPollInterval = 5 * time.Second

	// RepollInterval poll interval used for egress node reachability check retries
	RepollInterval = time.Second
)
View Source
const (
	// Maximum VXLAN Virtual Network Identifier(VNID) as per RFC#7348
	MaxVNID = uint32((1 << 24) - 1)
	// VNID: 2 to 9 are internally reserved for any special cases in the future
	MinVNID = uint32(10)
	// VNID: 0 reserved for default namespace and can reach any network in the cluster
	GlobalVNID = uint32(0)
)

Variables

This section is empty.

Functions

func ClusterNetworkListContains

func ClusterNetworkListContains(clusterNetworks []ParsedClusterNetworkEntry, ipaddr net.IP) (*net.IPNet, bool)

func ClusterNetworkToString

func ClusterNetworkToString(n *osdnv1.ClusterNetwork) string

func GenerateDefaultGateway

func GenerateDefaultGateway(sna *net.IPNet) net.IP

Generate the default gateway IP Address for a subnet

func GetHostIPNetworks

func GetHostIPNetworks(skipInterfaces []string) ([]*net.IPNet, []net.IP, error)

Return Host IP Networks Ignores provided interfaces and filters loopback and non IPv4 addrs.

func GetNodeInternalIP

func GetNodeInternalIP(node *corev1.Node) string

func HSEgressIPsToStrings

func HSEgressIPsToStrings(ips []osdnv1.HostSubnetEgressIP) []string

func HostSubnetToString

func HostSubnetToString(subnet *osdnv1.HostSubnet) string

func InformerFuncs

func InformerFuncs(objType runtime.Object, addOrUpdateFunc InformerAddOrUpdateFunc, deleteFunc InformerDeleteFunc) kcache.ResourceEventHandlerFuncs

func ListAllEgressNetworkPolicies

func ListAllEgressNetworkPolicies(ctx context.Context, client osdnclient.Interface) ([]*osdnv1.EgressNetworkPolicy, error)

func ListAllHostSubnets

func ListAllHostSubnets(ctx context.Context, client osdnclient.Interface) ([]*osdnv1.HostSubnet, error)

func ListAllNamespaces

func ListAllNamespaces(ctx context.Context, client kubernetes.Interface) ([]*corev1.Namespace, error)

func ListAllNetNamespaces

func ListAllNetNamespaces(ctx context.Context, client osdnclient.Interface) ([]*osdnv1.NetNamespace, error)

func ListAllNetworkPolicies

func ListAllNetworkPolicies(ctx context.Context, client kubernetes.Interface) ([]*networkingv1.NetworkPolicy, error)

func ListAllPods

func ListAllPods(ctx context.Context, client kubernetes.Interface) ([]*corev1.Pod, error)

func ListAllServices

func ListAllServices(ctx context.Context, client kubernetes.Interface) ([]*corev1.Service, error)

func ListPodsInNodeAndNamespace

func ListPodsInNodeAndNamespace(ctx context.Context, client kubernetes.Interface, node, namespace string) ([]*corev1.Pod, error)

func ListServicesInNamespace

func ListServicesInNamespace(ctx context.Context, client kubernetes.Interface, namespace string) ([]*corev1.Service, error)

func NetnsIsMulticastEnabled

func NetnsIsMulticastEnabled(netns *osdnv1.NetNamespace) bool

func PlatformUsesCloudEgressIP

func PlatformUsesCloudEgressIP(platformType string) bool

func StringsToHSEgressIPs

func StringsToHSEgressIPs(ips []string) []osdnv1.HostSubnetEgressIP

func ValidateClusterNetwork

func ValidateClusterNetwork(clusterNet *osdnv1.ClusterNetwork) error

ValidateClusterNetwork tests if required fields in the ClusterNetwork are set, and ensures that the "default" ClusterNetwork can only be set to the correct values

func ValidateHostSubnet

func ValidateHostSubnet(hs *osdnv1.HostSubnet) error

ValidateHostSubnet checks if the system-maintained fields of hostsubnet are valid.

func ValidateHostSubnetEgress

func ValidateHostSubnetEgress(hs *osdnv1.HostSubnet) error

ValidateHostSubnetEgress checks if the user-maintained fields of hostsubnet are valid.

Types

type DNS

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

func NewDNS

func NewDNS(resolverConfigFile string, ipv4, ipv6 bool) (*DNS, error)

func (*DNS) Add

func (d *DNS) Add(dns string) error

func (*DNS) Delete

func (d *DNS) Delete(dns string)

func (*DNS) Get

func (d *DNS) Get(dns string) dnsValue

func (*DNS) GetNextQueryTime

func (d *DNS) GetNextQueryTime() (time.Time, string, bool)

func (*DNS) SetUpdating

func (d *DNS) SetUpdating(dns string) error

func (*DNS) Size

func (d *DNS) Size() int

func (*DNS) Update

func (d *DNS) Update(dns string) (bool, error)

type DNSInterface

type DNSInterface interface {
	Add(dns string) error
	Size() int
	Get(dns string) dnsValue
	Delete(dns string)
	SetUpdating(dns string) error
	Update(dns string) (bool, error)
	GetNextQueryTime() (time.Time, string, bool)
}

type DNSResponseNotification

type DNSResponseNotification struct {
	Name    string
	Changed bool
}

type EgressDNS

type EgressDNS struct {

	// Report changes when there are dns updates
	Updates chan EgressDNSUpdates
	// contains filtered or unexported fields
}

func NewEgressDNS

func NewEgressDNS(ipv4, ipv6 bool) (*EgressDNS, error)

func (*EgressDNS) Add

func (e *EgressDNS) Add(policy osdnv1.EgressNetworkPolicy)

func (*EgressDNS) Delete

func (e *EgressDNS) Delete(policy osdnv1.EgressNetworkPolicy)

func (*EgressDNS) GetIPs

func (e *EgressDNS) GetIPs(dnsName string) []net.IP

func (*EgressDNS) GetNetCIDRs

func (e *EgressDNS) GetNetCIDRs(dnsName string) []net.IPNet

func (*EgressDNS) Stop

func (e *EgressDNS) Stop()

func (*EgressDNS) Sync

func (e *EgressDNS) Sync()

type EgressDNSUpdate

type EgressDNSUpdate struct {
	UID       ktypes.UID
	Namespace string
}

type EgressDNSUpdates

type EgressDNSUpdates []EgressDNSUpdate

type EgressIPAssignment

type EgressIPAssignment struct {
	NodeIP   string
	EgressIP string
}

type EgressIPTracker

type EgressIPTracker struct {
	sync.Mutex

	CloudEgressIP bool
	// contains filtered or unexported fields
}

func NewEgressIPTracker

func NewEgressIPTracker(watcher EgressIPWatcher, cloudEgressIP bool, localIP string) *EgressIPTracker

func (*EgressIPTracker) DeleteNetNamespaceEgress

func (eit *EgressIPTracker) DeleteNetNamespaceEgress(vnid uint32)

func (*EgressIPTracker) GetNodeCloudEgressIPConfig

func (eit *EgressIPTracker) GetNodeCloudEgressIPConfig(nodeName string) (*nodeCloudEgressIPConfiguration, error)

GetNodeCloudEgressIPConfig returns cloud egress IP config for the specified node

func (*EgressIPTracker) GetNodeNameByNodeIP

func (eit *EgressIPTracker) GetNodeNameByNodeIP(nodeIP string) string

func (*EgressIPTracker) Ping

func (eit *EgressIPTracker) Ping(sdnIP string, timeout time.Duration) bool

Ping a node on its SDN IP and return whether we think it is online. We do this by trying to open a TCP connection to the "discard" service (port 9); if the node is offline, the attempt will either time out with no response, or else return "no route to host" (and we will return false). If the node is online then we presumably will get a "connection refused" error; but the code below assumes that anything other than timeout or "no route" indicates that the node is online. It is required that the IP provided is from SDN, nodes primary IP might drop traffic destined to port 9

func (*EgressIPTracker) ReallocateEgressIPs

func (eit *EgressIPTracker) ReallocateEgressIPs() map[string][]string

ReallocateEgressIPs returns a map from Node name to array-of-Egress-IP for all auto-allocated egress IPs

func (*EgressIPTracker) SetNodeOffline

func (eit *EgressIPTracker) SetNodeOffline(nodeIP string, offline bool)

func (*EgressIPTracker) Start

func (eit *EgressIPTracker) Start(kubeClient kubernetes.Interface, hostSubnetInformer osdninformers.HostSubnetInformer, netNamespaceInformer osdninformers.NetNamespaceInformer, nodeInformer kcoreinformers.NodeInformer)

func (*EgressIPTracker) UpdateHostSubnetEgress

func (eit *EgressIPTracker) UpdateHostSubnetEgress(hs *osdnv1.HostSubnet)

func (*EgressIPTracker) UpdateNetNamespaceEgress

func (eit *EgressIPTracker) UpdateNetNamespaceEgress(netns *osdnv1.NetNamespace)

type EgressIPWatcher

type EgressIPWatcher interface {
	Synced()

	ClaimEgressIP(vnid uint32, egressIP, nodeIP, sdnIP string, nodeOffline bool)
	ReleaseEgressIP(egressIP, nodeIP string)

	SetNamespaceEgressNormal(vnid uint32)
	SetNamespaceEgressDropped(vnid uint32)
	SetNamespaceEgressViaEgressIPs(vnid uint32, activeEgressIPs []EgressIPAssignment)

	UpdateEgressCIDRs()
}

type FakeDNS

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

func NewFakeDNS

func NewFakeDNS(dnsReplies []fakeDNSReply) *FakeDNS

func (*FakeDNS) Add

func (f *FakeDNS) Add(dns string) error

Add: Not implemented

func (*FakeDNS) Delete

func (f *FakeDNS) Delete(dns string)

func (*FakeDNS) Get

func (f *FakeDNS) Get(dns string) dnsValue

func (*FakeDNS) GetNextQueryTime

func (f *FakeDNS) GetNextQueryTime() (time.Time, string, bool)

func (*FakeDNS) SetUpdating

func (f *FakeDNS) SetUpdating(dns string) error

func (*FakeDNS) Size

func (f *FakeDNS) Size() int

func (*FakeDNS) Update

func (f *FakeDNS) Update(dns string) (bool, error)

Update always assumes that if there is a reply the IP list always changes

type InformerAddOrUpdateFunc

type InformerAddOrUpdateFunc func(interface{}, interface{}, watch.EventType)

type InformerDeleteFunc

type InformerDeleteFunc func(interface{})

type ParsedClusterNetwork

type ParsedClusterNetwork struct {
	PluginName      string
	ClusterNetworks []ParsedClusterNetworkEntry
	ServiceNetwork  *net.IPNet
	VXLANPort       uint32
	OverlayMTU      uint32
}

func GetParsedClusterNetwork

func GetParsedClusterNetwork(osdnClient osdnclient.Interface) (*ParsedClusterNetwork, error)

func ParseClusterNetwork

func ParseClusterNetwork(cn *osdnv1.ClusterNetwork) (*ParsedClusterNetwork, error)

func (*ParsedClusterNetwork) CheckClusterObjects

func (pcn *ParsedClusterNetwork) CheckClusterObjects(subnets []*osdnv1.HostSubnet, pods []*corev1.Pod, services []*corev1.Service) error

func (*ParsedClusterNetwork) CheckHostNetworks

func (pcn *ParsedClusterNetwork) CheckHostNetworks(hostIPNets []*net.IPNet) error

func (*ParsedClusterNetwork) PodNetworkContains

func (pcn *ParsedClusterNetwork) PodNetworkContains(ip net.IP) bool

PodNetworkContains determines whether pcn's pod network contains ip

func (*ParsedClusterNetwork) ServiceNetworkContains

func (pcn *ParsedClusterNetwork) ServiceNetworkContains(ip net.IP) bool

ServiceNetworkContains determines whether pcn's service network contains ip

func (*ParsedClusterNetwork) ValidateNodeIP

func (pcn *ParsedClusterNetwork) ValidateNodeIP(nodeIP string) error

type ParsedClusterNetworkEntry

type ParsedClusterNetworkEntry struct {
	ClusterCIDR      *net.IPNet
	HostSubnetLength uint32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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