Documentation ¶
Index ¶
- Constants
- type Atomizable
- type Block
- type BlocksCallback
- type CIDR
- type Client
- func (c *Client) AddPolicy(policy api.Policy) error
- func (c *Client) AddRomanaVIP(key string, e api.ExposedIPSpec) error
- func (c *Client) DeletePolicy(id string) (bool, error)
- func (c *Client) DeleteRomanaVIP(key string) error
- func (c *Client) GetPolicy(id string) (api.Policy, error)
- func (c *Client) GetTopology() (interface{}, error)
- func (c *Client) ListHosts() api.HostList
- func (c *Client) ListPolicies() ([]api.Policy, error)
- func (c *Client) ListRomanaVIPs() (map[string]api.ExposedIPSpec, error)
- func (c *Client) ListTenants() []api.Tenant
- func (c *Client) WatchBlocks(stopCh <-chan struct{}) (<-chan api.IPAMBlocksResponse, error)
- func (c *Client) WatchBlocksWithCallback(cb BlocksCallback) error
- func (c *Client) WatchHosts(stopCh <-chan struct{}) (<-chan api.HostList, error)
- func (c *Client) WatchHostsWithCallback(cb HostListCallback) error
- type Group
- type Host
- type HostListCallback
- type IPAM
- func (ipam *IPAM) AddHost(host api.Host) error
- func (ipam *IPAM) AllocateIP(addressName string, host string, tenant string, segment string) (net.IP, error)
- func (ipam *IPAM) BlackOut(cidrStr string) error
- func (ipam *IPAM) DeallocateIP(addressName string) error
- func (ipam *IPAM) GetGroupsForNetwork(netName string) *Group
- func (ipam *IPAM) GetPrevKVPair() *libkvStore.KVPair
- func (ipam *IPAM) ListAllBlocks() *api.IPAMBlocksResponse
- func (ipam *IPAM) ListHosts() api.HostList
- func (ipam *IPAM) ListNetworkBlocks(netName string) *api.IPAMBlocksResponse
- func (ipam *IPAM) RemoveHost(host api.Host) error
- func (ipam *IPAM) SetPrevKVPair(kvp *libkvStore.KVPair)
- func (ipam *IPAM) UnBlackOut(cidrStr string) error
- func (ipam *IPAM) UpdateHostK8SInfo(host api.Host) error
- func (ipam *IPAM) UpdateHostLabels(host api.Host) error
- func (ipam *IPAM) UpdateTopology(req api.TopologyUpdateRequest, lockAndSave bool) error
- type Loader
- type Locker
- type Network
- type Saver
- type Store
- func (s *Store) AtomicPut(key string, value Atomizable) error
- func (s *Store) Delete(key string) (bool, error)
- func (s *Store) Exists(key string) (bool, error)
- func (s *Store) Get(key string) (*libkvStore.KVPair, error)
- func (s *Store) GetBool(key string, defaultValue bool) (bool, error)
- func (s *Store) GetInt(key string, defaultValue int) (int, error)
- func (s *Store) GetObject(key string) (*libkvStore.KVPair, error)
- func (s *Store) GetString(key string, defaultValue string) (string, error)
- func (s *Store) ListObjects(key string) ([]*libkvStore.KVPair, error)
- func (store *Store) NewLocker(name string) (Locker, error)
- func (s *Store) PutObject(key string, value []byte) error
- func (s *Store) ReconnectingWatch(key string, stopCh <-chan struct{}) (<-chan *libkvStore.KVPair, error)
Constants ¶
const ( DefaultEtcdPrefix = "/romana" DefaultEtcdEndpoints = "localhost:2379" PoliciesPrefix = "/policies" RomanaVIPPrefix = "/romanavip" )
const ( DefaultAgentPort = 9604 DefaultBlockMask = 29 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Atomizable ¶
type Atomizable interface { GetPrevKVPair() *libkvStore.KVPair SetPrevKVPair(*libkvStore.KVPair) }
Atomizable defines an interface on which it is possible to execute Atomic operations from the point of view of KVStore.
type Block ¶
type Block struct { CIDR CIDR `json:"cidr"` Pool *idring.IDRing `json:"pool"` Revision int `json:"revision"` }
Block represents a CIDR that is owned by an Owner, and thus can have addresses allocated in it it.
func (Block) ListAllocatedAddresses ¶
ListAllocatedAddresses lists all allocated adresses in the block
func (Block) ListAvailableAddresses ¶
ListAvailableAddresses lists all available adresses in the block
type BlocksCallback ¶
type BlocksCallback func(api.IPAMBlocksResponse)
type CIDR ¶
type CIDR struct { // Represents the IPNet object corresponding to this CIDR. *net.IPNet StartIP net.IP `json:"start_ip"` StartIPInt uint64 `json:"start_ip_int"` EndIP net.IP `json:"end_ip"` EndIPInt uint64 `json:"end_ip_int"` }
CIDR represents a CIDR (net.IPNet, effectively) with some extra functionality for convenience.
func (CIDR) Contains ¶
Contains returns true if this CIDR fully contains (is equivalent to or a superset of) the provided CIDR.
func (CIDR) DebugString ¶
func (CIDR) MarshalText ¶
func (*CIDR) UnmarshalText ¶
type Client ¶
func (*Client) AddPolicy ¶
AddPolicy adds a policy (or modifies it if policy with such ID already exists)
func (*Client) AddRomanaVIP ¶
func (c *Client) AddRomanaVIP(key string, e api.ExposedIPSpec) error
AddRomanaVIP adds romana VIP information for service to the store.
func (*Client) DeletePolicy ¶
DeletePolicy attempts to delete policy. If the policy does not exist, false is returned, instead of an error.
func (*Client) DeleteRomanaVIP ¶
DeleteRomanaVIP deletes romana VIP information for service from store.
func (*Client) GetTopology ¶
GetTopology returns the representation of latest topology in store.
func (*Client) ListRomanaVIPs ¶
func (c *Client) ListRomanaVIPs() (map[string]api.ExposedIPSpec, error)
ListRomanaVIPs lists romana VIP information for services in the store.
func (*Client) ListTenants ¶
ListTenants is a temporary method to satisfy current agent cache.
func (*Client) WatchBlocks ¶
func (c *Client) WatchBlocks(stopCh <-chan struct{}) (<-chan api.IPAMBlocksResponse, error)
WatchBlocks is similar to Watch of libkv store, but specific to watching for blocks.
func (*Client) WatchBlocksWithCallback ¶
func (c *Client) WatchBlocksWithCallback(cb BlocksCallback) error
func (*Client) WatchHosts ¶
WatchHosts is similar to Watch of libkv store, but specific to watching for host list.
func (*Client) WatchHostsWithCallback ¶
func (c *Client) WatchHostsWithCallback(cb HostListCallback) error
type Group ¶
type Group struct { Name string `json:"name"` Hosts []*Host `json:"hosts"` Groups []*Group `json:"groups"` // CIDR which is to be subdivided among hosts or sub-groups of this group. CIDR CIDR `json:"cidr"` BlockToOwner map[int]string `json:"block_to_owner"` OwnerToBlocks map[string][]int `json:"owner_to_block"` BlockToHost map[int]string `json:"block_to_host"` Blocks []*Block `json:"blocks"` ReusableBlocks []int `json:"reusable_blocks"` Assignment map[string]string `json:"assignment"` Routing string `json:"routing"` Dummy bool `json:"dummy"` // contains filtered or unexported fields }
Group holds either a list of hosts at a given level; it cannot be a mix. In other words, the invariant is:
- Either Hosts or Groups field is nil
func (*Group) GetBlocks ¶
func (hg *Group) GetBlocks() []api.IPAMBlockResponse
GetBlocks returns list of blocks for the provided group including extra information about a block (host, tenant/segment, etc.) - corresponding to api.IPAMBlockResponse.
func (*Group) ListBlocks ¶
type Host ¶
type Host struct { Name string `json:"name"` IP net.IP `json:"ip"` AgentPort uint `json:"agent_port"` Tags map[string]string `json:"tags"` K8SInfo map[string]interface{} `json:"k8s_info"` // contains filtered or unexported fields }
Host represents a host in Romana topology.
type HostListCallback ¶
type IPAM ¶
type IPAM struct { Networks map[string]*Network `json:"networks"` // Revision of the state of allocations AllocationRevision int // Revision of topology information (only changes if hosts are added) TopologyRevision int // Map of address name to IP AddressNameToIP map[string]net.IP `json:"address_name_to_ip"` TenantToNetwork map[string][]string `json:"tenant_to_network"` // contains filtered or unexported fields }
func NewIPAM ¶
NewIPAM creates a new IPAM object. If locker is not provided, mutexLocker is used. If an HA deployment is expected, then the locker based on some external resource, e.g., a DB, should be provided.
func (*IPAM) AllocateIP ¶
func (ipam *IPAM) AllocateIP(addressName string, host string, tenant string, segment string) (net.IP, error)
AllocateIP allocates an IP for the provided tenant and segment, and associates the provided name with it. That name can afterwards be used for deallocation. It will first attempt to allocate an IP from an existing block, and if all are exhausted, will try to allocate a new block for this tenant/segment pair. Will return nil as IP if the entire network is exhausted.
func (*IPAM) BlackOut ¶
BlackOut removes a CIDR from consideration. It is an error if CIDR is within any of the exising allocated blocks. Fragmentation may result if CIDRs smaller than ipam. Blocks are blacked out and then un-blacked out.
func (*IPAM) DeallocateIP ¶
DeallocateIP will deallocate the provided IP (returning an error if it never was allocated in the first place).
func (*IPAM) GetGroupsForNetwork ¶
GetGroupsForNetwork retrieves Group for the network with the provided name, or nil if not found.
func (*IPAM) GetPrevKVPair ¶
func (ipam *IPAM) GetPrevKVPair() *libkvStore.KVPair
func (*IPAM) ListAllBlocks ¶
func (ipam *IPAM) ListAllBlocks() *api.IPAMBlocksResponse
func (*IPAM) ListNetworkBlocks ¶
func (ipam *IPAM) ListNetworkBlocks(netName string) *api.IPAMBlocksResponse
func (*IPAM) SetPrevKVPair ¶
func (ipam *IPAM) SetPrevKVPair(kvp *libkvStore.KVPair)
func (*IPAM) UnBlackOut ¶
UnBlackOut adds CIDR backs into the pool for consideration.
func (*IPAM) UpdateHostLabels ¶
UpdateHostLabels updates host's labels. Note that this does not check the new labels against label assignment and whether that breaks anything; that is a TODO
func (*IPAM) UpdateTopology ¶
func (ipam *IPAM) UpdateTopology(req api.TopologyUpdateRequest, lockAndSave bool) error
UpdateTopology updates the entire topology, returning an error if the current topology has IPs that cannot be allocated in the new one.
type Locker ¶
Locker implements an interface for locking and unlocking. sync.Locker was not good for our purpose it does not allow for returning an error on lock. libkv's Locker is too libkv-specific and we do not need a stop channel really; and since the use case is to defer Unlock(), no need for it to return an error
type Network ¶
type Network struct { Name string `json:"name"` // CIDR of the network (likely 10/8). CIDR CIDR `json:"cidr"` // Size of tenant/segment block to allocate, in bits as mask // (specify 32 for size 1, e.g.) BlockMask uint `json:"block_mask"` BlackedOut []CIDR `json:"blacked_out"` Group *Group `json:"host_groups"` Revison int `json:"revision"` // contains filtered or unexported fields }
Network is the main structure managing allocation of IP addresses in the provided CIDR.
type Saver ¶
Saver defines a function that can save the state of the BlockIPAM to a persistent store. Saver is allowed to assume the BlockIPAM can be successfully marshaled to JSON.
type Store ¶
type Store struct { libkvStore.Store // contains filtered or unexported fields }
Store is a structure storing information specific to KV-based implementation of Store.
func (*Store) Delete ¶
Delete wrapes Delete operation, returning: - true if deletion succeede - false and no error if deletion failed because key was not found - false and error if another error occurred
func (*Store) ListObjects ¶
func (s *Store) ListObjects(key string) ([]*libkvStore.KVPair, error)
func (*Store) ReconnectingWatch ¶
func (s *Store) ReconnectingWatch(key string, stopCh <-chan struct{}) (<-chan *libkvStore.KVPair, error)
ReconnectingWatch wraps libkv Watch method, but attempts to re-establish the watch if it drop.