Documentation ¶
Overview ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const ( // Common attributes which may be set on allocations by clients. AttributePod = "pod" AttributeNamespace = "namespace" AttributeNode = "node" AttributeType = "type" AttributeTypeIPIP = "ipipTunnelAddress" )
Variables ¶
var (
ErrBlockLimit = errors.New("cannot allocate new block due to per host block limit")
)
Functions ¶
This section is empty.
Types ¶
type AssignIPArgs ¶
type AssignIPArgs struct { // The IP address to assign. IP cnet.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 pools from which // to assign IPv4 addresses. If not specified, this defaults to all IPv4 pools. IPv4Pools []cnet.IPNet // If specified, the previously configured IPv6 pools from which // to assign IPv6 addresses. If not specified, this defaults to all IPv6 pools. IPv6Pools []cnet.IPNet // If non-zero, limit on the number of affine blocks this host is allowed to claim // (per IP version). MaxBlocksPerHost int }
AutoAssignArgs defines the set of arguments for assigning one or more IP addresses.
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 Interface ¶
type Interface 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(ctx context.Context, 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 in IPNet format. // // In case of error, returns the IPs allocated so far along with the error. AutoAssign(ctx context.Context, args AutoAssignArgs) ([]cnet.IPNet, []cnet.IPNet, 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(ctx context.Context, ips []cnet.IP) ([]cnet.IP, error) // GetAssignmentAttributes returns the attributes stored with the given IP address // upon assignment. GetAssignmentAttributes(ctx context.Context, addr cnet.IP) (map[string]string, error) // IPsByHandle returns a list of all IP addresses that have been // assigned using the provided handle. IPsByHandle(ctx context.Context, handleID string) ([]cnet.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(ctx context.Context, 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(ctx context.Context, cidr cnet.IPNet, host string) ([]cnet.IPNet, []cnet.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. If mustBeEmpty is true, then an error // will be returned if any blocks within the CIDR are not empty - in this case, this // function may release some but not all blocks within the given CIDR. ReleaseAffinity(ctx context.Context, cidr cnet.IPNet, host string, mustBeEmpty bool) 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. If mustBeEmpty is true, then an error // will be returned if any blocks within the CIDR are not empty - in this case, this // function may release some but not all blocks attached to this host. ReleaseHostAffinities(ctx context.Context, host string, mustBeEmpty bool) error // ReleasePoolAffinities releases affinity for all blocks within // the specified pool across all hosts. ReleasePoolAffinities(ctx context.Context, pool cnet.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(ctx context.Context) (*IPAMConfig, error) // SetIPAMConfig sets global IPAM configuration. This can only // be done when there are no allocated blocks and IP addresses. SetIPAMConfig(ctx context.Context, 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(ctx context.Context, host string) error }
ipam.Interface has methods to perform IP address management.
func NewIPAMClient ¶
func NewIPAMClient(client bapi.Client, pools PoolAccessorInterface) Interface
NewIPAMClient returns a new ipamClient, which implements Interface. Consumers of the Calico API should not create this directly, but should access IPAM through the main client IPAM accessor (e.g. clientv3.IPAM())