Documentation ¶
Index ¶
- func Ports(svc *v1.Service) []corev1.ServicePort
- type Allocator
- func (a *Allocator) AddPrefix(sp epicv1.ServicePrefix) error
- func (a *Allocator) AllocateFromPool(svc string, poolName string, ports []corev1.ServicePort, sharingKey string) (net.IP, error)
- func (a *Allocator) Assign(svc string, ip net.IP, ports []corev1.ServicePort, sharingKey string) (string, error)
- func (a *Allocator) RemovePool(sp epicv1.ServicePrefix) error
- func (a *Allocator) Unassign(svc string) bool
- func (a *Allocator) ValidateDelete(sp *epicv1.ServicePrefix) error
- type IPRange
- type Key
- type LocalPool
- func (p LocalPool) Assign(ip net.IP, ports []corev1.ServicePort, service string, sharingKey *Key) error
- func (p LocalPool) AssignNext(service string, ports []corev1.ServicePort, sharingKey *Key) (net.IP, error)
- func (p LocalPool) Available(ip net.IP, ports []corev1.ServicePort, service string, key *Key) error
- func (p LocalPool) Contains(ip net.IP) bool
- func (p LocalPool) First() net.IP
- func (p LocalPool) InUse() int
- func (p LocalPool) Next(ip net.IP) net.IP
- func (p LocalPool) Overlaps(other Pool) bool
- func (p LocalPool) Release(ip net.IP, service string)
- func (p LocalPool) SharingKey(ip net.IP) *Key
- func (p LocalPool) Size() uint64
- type Pool
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
An Allocator tracks IP address pools and allocates addresses from them.
func NewAllocator ¶
func NewAllocator() *Allocator
NewAllocator returns an Allocator managing no pools.
func (*Allocator) AddPrefix ¶
func (a *Allocator) AddPrefix(sp epicv1.ServicePrefix) error
AddPrefix adds a ServicePrefix's address pool(s) to the allocator. Each SP will have at least one pool, but if that pool is IPV6 then it will also have an alternative pool of IPV4 addresses.
func (*Allocator) AllocateFromPool ¶
func (a *Allocator) AllocateFromPool(svc string, poolName string, ports []corev1.ServicePort, sharingKey string) (net.IP, error)
AllocateFromPool assigns an available IP from pool to service.
func (*Allocator) Assign ¶
func (a *Allocator) Assign(svc string, ip net.IP, ports []corev1.ServicePort, sharingKey string) (string, error)
Assign assigns the requested ip to svc, if the assignment is permissible by sharingKey.
func (*Allocator) RemovePool ¶
func (a *Allocator) RemovePool(sp epicv1.ServicePrefix) error
RemovePool removes an address pool from the allocator.
func (*Allocator) ValidateDelete ¶
func (a *Allocator) ValidateDelete(sp *epicv1.ServicePrefix) error
ValidateDelete checks whether "sp" can be deleted. A nil return value is good; non-nil means that this pool can't be deleted.
type IPRange ¶
type IPRange struct {
// contains filtered or unexported fields
}
IPRange represents a from-to range of IP addresses.
func NewIPRange ¶
NewIPRange parses a string representation of an IP address range and returns the corresponding IPRange. The representation can be in either of two forms: CIDR or from-to. CIDR looks like "192.168.1.0/24" and from-to looks like "192.168.1.0 - 192.168.1.255". The error return value will be non-nil if the representation couldn't be parsed.
func (IPRange) Contains ¶
Contains indicates whether the provided net.IP represents an address within this IPRange. It returns true if so, false otherwise.
func (IPRange) Next ¶
Next returns the next net.IP within this IPRange, or nil if the provided net.IP is the last address in the range.
type Key ¶
type Key struct {
Sharing string
}
Key represents a "sharing key" which is used to have two or more services share an IP address.
type LocalPool ¶
type LocalPool struct {
// contains filtered or unexported fields
}
LocalPool is the configuration of an IP address pool.
func NewLocalPool ¶
NewLocalPool initializes a new LocalPool object.
func (LocalPool) Assign ¶
func (p LocalPool) Assign(ip net.IP, ports []corev1.ServicePort, service string, sharingKey *Key) error
Assign assigns a service to an IP.
func (LocalPool) AssignNext ¶
func (p LocalPool) AssignNext(service string, ports []corev1.ServicePort, sharingKey *Key) (net.IP, error)
AssignNext assigns a service to the next available IP.
func (LocalPool) Available ¶
Available determines whether an address is available. The decision depends on whether another service is using the address, and if so, whether this service can share the address with it. error will be nil if the ip is available, and will contain an explanation if not.
func (LocalPool) Contains ¶
Contains indicates whether the provided net.IP represents an address within this Pool. It returns true if so, false otherwise.
func (LocalPool) First ¶
First returns the first (i.e., lowest-valued) net.IP within this Pool, or nil if the pool has no addresses.
func (LocalPool) InUse ¶
InUse returns the count of addresses that currently have services assigned.
func (LocalPool) Next ¶
Next returns the next net.IP within this Pool, or nil if the provided net.IP is the last address in the range.
func (LocalPool) Overlaps ¶
Overlaps indicates whether the other Pool overlaps with this one (i.e., has any addresses in common). It returns true if there are any common addresses and false if there aren't.
func (LocalPool) SharingKey ¶
SharingKey returns the "sharing key" for the specified address.
type Pool ¶
type Pool interface { Available(net.IP, []corev1.ServicePort, string, *Key) error AssignNext(string, []corev1.ServicePort, *Key) (net.IP, error) Assign(net.IP, []corev1.ServicePort, string, *Key) error Release(net.IP, string) InUse() int SharingKey(net.IP) *Key Overlaps(Pool) bool Contains(net.IP) bool Size() uint64 }
Pool represents a pool of IP addresses.
Notes ¶
Bugs ¶
this is inefficient. Is there a better way to find the last address of a CIDR?