Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package client implements the northbound client used to manage Calico configuration.
Index ¶
- func LoadClientConfig(filename string) (*api.ClientConfig, error)
 - func TierOrDefault(tier string) string
 - type AssignIPArgs
 - type AutoAssignArgs
 - type BGPPeerInterface
 - type Client
 - func (c *Client) BGPPeers() BGPPeerInterface
 - func (c *Client) HostEndpoints() HostEndpointInterface
 - func (c *Client) IPAM() IPAMInterface
 - func (c *Client) Policies() PolicyInterface
 - func (c *Client) Pools() PoolInterface
 - func (c *Client) Profiles() ProfileInterface
 - func (c *Client) Tiers() TierInterface
 - func (c *Client) WorkloadEndpoints() WorkloadEndpointInterface
 
- type HostEndpointInterface
 - type IPAMConfig
 - type IPAMInterface
 - type PolicyInterface
 - type PoolInterface
 - type ProfileInterface
 - type WorkloadEndpointInterface
 
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadClientConfig ¶
func LoadClientConfig(filename string) (*api.ClientConfig, error)
LoadClientConfig loads the ClientConfig from the specified file (if specified) or from environment variables (if the file is not specified).
Types ¶
type AssignIPArgs ¶
type AssignIPArgs struct {
	// The IP address to assign.
	IP net.IP
	// If specified, a handle which can be used to retrieve / release
	// the allocated IP addresses in the future.
	HandleID *string
	// A key/value mapping of metadata to store with the allocations.
	Attrs map[string]string
	// If specified, the hostname of the host on which IP addresses
	// will be allocated.  If not specified, this will default
	// to the value provided by os.Hostname.
	Hostname string
}
    AssignIPArgs defines the set of arguments for assigning a specific IP address.
type AutoAssignArgs ¶
type AutoAssignArgs struct {
	// The number of IPv4 addresses to automatically assign.
	Num4 int
	// The number of IPv6 addresses to automatically assign.
	Num6 int
	// If specified, a handle which can be used to retrieve / release
	// the allocated IP addresses in the future.
	HandleID *string
	// A key/value mapping of metadata to store with the allocations.
	Attrs map[string]string
	// If specified, the hostname of the host on which IP addresses
	// will be allocated.  If not specified, this will default
	// to the value provided by os.Hostname.
	Hostname string
	// If specified, the previously configured IPv4 pool from which
	// to assign IPv4 addresses.  If not specified, this defaults to all IPv4 pools.
	IPv4Pool *net.IPNet
	// If specified, the previously configured IPv6 pool from which
	// to assign IPv6 addresses.  If not specified, this defaults to all IPv6 pools.
	IPv6Pool *net.IPNet
}
    AutoAssignArgs defines the set of arguments for assigning one or more IP addresses.
type BGPPeerInterface ¶
type BGPPeerInterface interface {
	List(api.BGPPeerMetadata) (*api.BGPPeerList, error)
	Get(api.BGPPeerMetadata) (*api.BGPPeer, error)
	Create(*api.BGPPeer) (*api.BGPPeer, error)
	Update(*api.BGPPeer) (*api.BGPPeer, error)
	Apply(*api.BGPPeer) (*api.BGPPeer, error)
	Delete(api.BGPPeerMetadata) error
}
    BGPPeerInterface has methods to work with BGPPeer resources.
type Client ¶
type Client struct {
	// contains filtered or unexported fields
}
    Client contains
func New ¶
func New(config api.ClientConfig) (*Client, error)
New returns a connected Client. This is the only mechanism by which to create a Client. The ClientConfig can either be created explicitly, or can be loaded from a config file or environment variables using the LoadClientConfig() function.
func (*Client) BGPPeers ¶
func (c *Client) BGPPeers() BGPPeerInterface
BGPPeers returns an interface for managing BGP peer resources.
func (*Client) HostEndpoints ¶
func (c *Client) HostEndpoints() HostEndpointInterface
HostEndpoints returns an interface for managing host endpoint resources.
func (*Client) IPAM ¶
func (c *Client) IPAM() IPAMInterface
IPAM returns an interface for managing IP address assignment and releasing.
func (*Client) Policies ¶
func (c *Client) Policies() PolicyInterface
Policies returns an interface for managing policy resources.
func (*Client) Pools ¶
func (c *Client) Pools() PoolInterface
Pools returns an interface for managing pool resources.
func (*Client) Profiles ¶
func (c *Client) Profiles() ProfileInterface
Profiles returns an interface for managing profile resources.
func (*Client) Tiers ¶
func (c *Client) Tiers() TierInterface
Tiers returns an interface for managing tier resources.
func (*Client) WorkloadEndpoints ¶
func (c *Client) WorkloadEndpoints() WorkloadEndpointInterface
WorkloadEndpoints returns an interface for managing workload endpoint resources.
type HostEndpointInterface ¶
type HostEndpointInterface interface {
	// List enumerates host endpoint resources matching the supplied metadata and
	// wildcarding missing identifiers.
	List(api.HostEndpointMetadata) (*api.HostEndpointList, error)
	// Get returns the host endpoint resource matching the supplied metadata.  The metadata
	// should contain all identifiers to uniquely identify a single resource.  If the
	// resource does not exist, a errors.ErrorResourceNotFound error is returned.
	Get(api.HostEndpointMetadata) (*api.HostEndpoint, error)
	// Create will create a new host endpoint resource.  If the resource already exists,
	// a errors.ErrorResourceAlreadyExists error is returned.
	Create(*api.HostEndpoint) (*api.HostEndpoint, error)
	// Update will update an existing host endpoint resource.  If the resource does not exist,
	// a errors.ErrorResourceDoesNotExist error is returned.
	Update(*api.HostEndpoint) (*api.HostEndpoint, error)
	// Apply with update an existing host endpoint resource, or create a new one if it does
	// not exist.
	Apply(*api.HostEndpoint) (*api.HostEndpoint, error)
	// Delete will delete a host endpoint resource.  The metadata should contain all identifiers
	// to uniquely identify a single resource.  If the resource does not exist, a
	// errors.ErrorResourceDoesNotExist error is returned.
	Delete(api.HostEndpointMetadata) error
}
    HostEndpointInterface has methods to work with host endpoint resources.
type IPAMConfig ¶
type IPAMConfig struct {
	// When StrictAffinity is true, addresses from a given block can only be
	// assigned by hosts with the blocks affinity.  If false, then AutoAllocateBlocks
	// must be true.  The default value is false.
	StrictAffinity bool
	// When AutoAllocateBlocks is true, Calico will automatically
	// allocate blocks of IP address to hosts as needed to assign addresses.
	// If false, then StrictAffinity must be true.  The default value is true.
	AutoAllocateBlocks bool
}
    IPAMConfig contains global configuration options for Calico IPAM. This IPAM configuration is stored in the datastore and configures the behavior of Calico IPAM across an entire Calico cluster.
type IPAMInterface ¶
type IPAMInterface interface {
	// AssignIP assigns the provided IP address to the provided host.  The IP address
	// must fall within a configured pool.  AssignIP will claim block affinity as needed
	// in order to satisfy the assignment.  An error will be returned if the IP address
	// is already assigned, or if StrictAffinity is enabled and the address is within
	// a block that does not have affinity for the given host.
	AssignIP(args AssignIPArgs) error
	// AutoAssign automatically assigns one or more IP addresses as specified by the
	// provided AutoAssignArgs.  AutoAssign returns the list of the assigned IPv4 addresses,
	// and the list of the assigned IPv6 addresses.
	AutoAssign(args AutoAssignArgs) ([]net.IP, []net.IP, error)
	// ReleaseIPs releases any of the given IP addresses that are currently assigned,
	// so that they are available to be used in another assignment.
	ReleaseIPs(ips []net.IP) ([]net.IP, error)
	// GetAssignmentAttributes returns the attributes stored with the given IP address
	// upon assignment.
	GetAssignmentAttributes(addr net.IP) (map[string]string, error)
	// IpsByHandle returns a list of all IP addresses that have been
	// assigned using the provided handle.
	IPsByHandle(handleID string) ([]net.IP, error)
	// ReleaseByHandle releases all IP addresses that have been assigned
	// using the provided handle.  Returns an error if no addresses
	// are assigned with the given handle.
	ReleaseByHandle(handleID string) error
	// ClaimAffinity claims affinity to the given host for all blocks
	// within the given CIDR.  The given CIDR must fall within a configured
	// pool. If an empty string is passed as the host, then the value returned by os.Hostname is used.
	ClaimAffinity(cidr net.IPNet, host string) ([]net.IPNet, []net.IPNet, error)
	// ReleaseAffinity releases affinity for all blocks within the given CIDR
	// on the given host.  If an empty string is passed as the host, then the
	// value returned by os.Hostname will be used.
	ReleaseAffinity(cidr net.IPNet, host string) error
	// ReleaseHostAffinities releases affinity for all blocks that are affine
	// to the given host.  If an empty string is passed as the host, the value returned by
	// os.Hostname will be used.
	ReleaseHostAffinities(host string) error
	// ReleasePoolAffinities releases affinity for all blocks within
	// the specified pool across all hosts.
	ReleasePoolAffinities(pool net.IPNet) error
	// GetIPAMConfig returns the global IPAM configuration.  If no IPAM configuration
	// has been set, returns a default configuration with StrictAffinity disabled
	// and AutoAllocateBlocks enabled.
	GetIPAMConfig() (*IPAMConfig, error)
	// SetIPAMConfig sets global IPAM configuration.  This can only
	// be done when there are no allocated blocks and IP addresses.
	SetIPAMConfig(cfg IPAMConfig) error
	// RemoveIPAMHost releases affinity for all blocks on the given host,
	// and removes all host-specific IPAM data from the datastore.
	// RemoveIPAMHost does not release any IP addresses claimed on the given host.
	// If an empty string is passed as the host then the value returned by os.Hostname is used.
	RemoveIPAMHost(host string) error
}
    IPAMInterface has methods to perform IP address management.
type PolicyInterface ¶
type PolicyInterface interface {
	List(api.PolicyMetadata) (*api.PolicyList, error)
	Get(api.PolicyMetadata) (*api.Policy, error)
	Create(*api.Policy) (*api.Policy, error)
	Update(*api.Policy) (*api.Policy, error)
	Apply(*api.Policy) (*api.Policy, error)
	Delete(api.PolicyMetadata) error
}
    PolicyInterface has methods to work with Policy resources.
type PoolInterface ¶
type PoolInterface interface {
	List(api.PoolMetadata) (*api.PoolList, error)
	Get(api.PoolMetadata) (*api.Pool, error)
	Create(*api.Pool) (*api.Pool, error)
	Update(*api.Pool) (*api.Pool, error)
	Apply(*api.Pool) (*api.Pool, error)
	Delete(api.PoolMetadata) error
}
    PoolInterface has methods to work with Pool resources.
type ProfileInterface ¶
type ProfileInterface interface {
	List(api.ProfileMetadata) (*api.ProfileList, error)
	Get(api.ProfileMetadata) (*api.Profile, error)
	Create(*api.Profile) (*api.Profile, error)
	Update(*api.Profile) (*api.Profile, error)
	Apply(*api.Profile) (*api.Profile, error)
	Delete(api.ProfileMetadata) error
}
    ProfileInterface has methods to work with Profile resources.
type WorkloadEndpointInterface ¶
type WorkloadEndpointInterface interface {
	List(api.WorkloadEndpointMetadata) (*api.WorkloadEndpointList, error)
	Get(api.WorkloadEndpointMetadata) (*api.WorkloadEndpoint, error)
	Create(*api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)
	Update(*api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)
	Apply(*api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)
	Delete(api.WorkloadEndpointMetadata) error
}
    WorkloadEndpointInterface has methods to work with WorkloadEndpoint resources.
      
      Source Files
      ¶
    
- bgppeer.go
 - client.go
 - doc.go
 - hostendpoint.go
 - ipam.go
 - ipam_block.go
 - ipam_block_reader_writer.go
 - ipam_errors.go
 - ipam_handle.go
 - ipam_types.go
 - policy.go
 - pool.go
 - profile.go
 - rule.go
 - workloadendpoint.go