Documentation ¶
Overview ¶
Package ipam contains the IPAM module. It is in charge of: 1. Keep track of used networks/IP addresses 2. Assign networks (ex. remap a remote cluster network to a new network) 3. Assign IP addresses (ex. to service endpoints) 4. Notify GW about endpoint IP remapping
Index ¶
- Variables
- func RegisterIpamServer(s grpc.ServiceRegistrar, srv IpamServer)
- type BelongsRequest
- type BelongsResponse
- type GetHomePodIPRequest
- func (*GetHomePodIPRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetHomePodIPRequest) GetClusterID() string
- func (x *GetHomePodIPRequest) GetIp() string
- func (*GetHomePodIPRequest) ProtoMessage()
- func (x *GetHomePodIPRequest) ProtoReflect() protoreflect.Message
- func (x *GetHomePodIPRequest) Reset()
- func (x *GetHomePodIPRequest) String() string
- type GetHomePodIPResponse
- func (*GetHomePodIPResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetHomePodIPResponse) GetHomeIP() string
- func (*GetHomePodIPResponse) ProtoMessage()
- func (x *GetHomePodIPResponse) ProtoReflect() protoreflect.Message
- func (x *GetHomePodIPResponse) Reset()
- func (x *GetHomePodIPResponse) String() string
- type IPAM
- func (liqoIPAM *IPAM) AcquireReservedSubnet(reservedNetwork string) error
- func (liqoIPAM *IPAM) AddLocalSubnetsPerCluster(podCIDR, externalCIDR, clusterID string) error
- func (liqoIPAM *IPAM) AddNetworkPool(network string) error
- func (liqoIPAM *IPAM) BelongsToPodCIDR(ctx context.Context, belongsRequest *BelongsRequest) (*BelongsResponse, error)
- func (liqoIPAM *IPAM) FreeReservedSubnet(network string) error
- func (liqoIPAM *IPAM) GetExternalCIDR(mask uint8) (string, error)
- func (liqoIPAM *IPAM) GetHomePodIP(ctx context.Context, request *GetHomePodIPRequest) (*GetHomePodIPResponse, error)
- func (liqoIPAM *IPAM) GetSubnetsPerCluster(podCidr, externalCIDR, clusterID string) (mappedPodCIDR, mappedExternalCIDR string, err error)
- func (liqoIPAM *IPAM) Init(pools []string, dynClient dynamic.Interface, listeningPort int) error
- func (liqoIPAM *IPAM) MapEndpointIP(ctx context.Context, mapRequest *MapRequest) (*MapResponse, error)
- func (liqoIPAM *IPAM) MarkAsAcquiredReservedSubnet(reservedNetwork string) error
- func (liqoIPAM *IPAM) RemoveClusterConfig(clusterID string) error
- func (liqoIPAM *IPAM) RemoveLocalSubnetsPerCluster(clusterID string) error
- func (liqoIPAM *IPAM) RemoveNetworkPool(network string) error
- func (liqoIPAM *IPAM) SetPodCIDR(podCIDR string) error
- func (liqoIPAM *IPAM) SetReservedSubnets(subnets []string) error
- func (liqoIPAM *IPAM) SetServiceCIDR(serviceCIDR string) error
- func (liqoIPAM *IPAM) Terminate()
- func (liqoIPAM *IPAM) UnmapEndpointIP(ctx context.Context, unmapRequest *UnmapRequest) (*UnmapResponse, error)
- type IPAMStorage
- func (ipamStorage *IPAMStorage) CreatePrefix(prefix goipam.Prefix) (goipam.Prefix, error)
- func (ipamStorage *IPAMStorage) DeletePrefix(prefix goipam.Prefix) (goipam.Prefix, error)
- func (ipamStorage *IPAMStorage) ReadAllPrefixCidrs() ([]string, error)
- func (ipamStorage *IPAMStorage) ReadAllPrefixes() ([]goipam.Prefix, error)
- func (ipamStorage *IPAMStorage) ReadPrefix(prefix string) (goipam.Prefix, error)
- func (ipamStorage *IPAMStorage) UpdatePrefix(prefix goipam.Prefix) (goipam.Prefix, error)
- type Ipam
- type IpamClient
- type IpamServer
- type IpamStorage
- type MapRequest
- type MapResponse
- type UnimplementedIpamServer
- func (UnimplementedIpamServer) BelongsToPodCIDR(context.Context, *BelongsRequest) (*BelongsResponse, error)
- func (UnimplementedIpamServer) GetHomePodIP(context.Context, *GetHomePodIPRequest) (*GetHomePodIPResponse, error)
- func (UnimplementedIpamServer) MapEndpointIP(context.Context, *MapRequest) (*MapResponse, error)
- func (UnimplementedIpamServer) UnmapEndpointIP(context.Context, *UnmapRequest) (*UnmapResponse, error)
- type UnmapRequest
- func (*UnmapRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UnmapRequest) GetClusterID() string
- func (x *UnmapRequest) GetIp() string
- func (*UnmapRequest) ProtoMessage()
- func (x *UnmapRequest) ProtoReflect() protoreflect.Message
- func (x *UnmapRequest) Reset()
- func (x *UnmapRequest) String() string
- type UnmapResponse
- type UnsafeIpamServer
Constants ¶
This section is empty.
Variables ¶
var File_pkg_liqonet_ipam_ipam_proto protoreflect.FileDescriptor
var Ipam_ServiceDesc = grpc.ServiceDesc{ ServiceName: "ipam", HandlerType: (*IpamServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "MapEndpointIP", Handler: _Ipam_MapEndpointIP_Handler, }, { MethodName: "UnmapEndpointIP", Handler: _Ipam_UnmapEndpointIP_Handler, }, { MethodName: "GetHomePodIP", Handler: _Ipam_GetHomePodIP_Handler, }, { MethodName: "BelongsToPodCIDR", Handler: _Ipam_BelongsToPodCIDR_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "pkg/liqonet/ipam/ipam.proto", }
Ipam_ServiceDesc is the grpc.ServiceDesc for Ipam service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var Pools = []string{
"10.0.0.0/8",
"192.168.0.0/16",
"172.16.0.0/12",
}
Pools is a constant slice containing private IPv4 networks.
Functions ¶
func RegisterIpamServer ¶
func RegisterIpamServer(s grpc.ServiceRegistrar, srv IpamServer)
Types ¶
type BelongsRequest ¶ added in v0.3.2
type BelongsRequest struct { Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` // contains filtered or unexported fields }
func (*BelongsRequest) Descriptor
deprecated
added in
v0.3.2
func (*BelongsRequest) Descriptor() ([]byte, []int)
Deprecated: Use BelongsRequest.ProtoReflect.Descriptor instead.
func (*BelongsRequest) GetIp ¶ added in v0.3.2
func (x *BelongsRequest) GetIp() string
func (*BelongsRequest) ProtoMessage ¶ added in v0.3.2
func (*BelongsRequest) ProtoMessage()
func (*BelongsRequest) ProtoReflect ¶ added in v0.3.2
func (x *BelongsRequest) ProtoReflect() protoreflect.Message
func (*BelongsRequest) Reset ¶ added in v0.3.2
func (x *BelongsRequest) Reset()
func (*BelongsRequest) String ¶ added in v0.3.2
func (x *BelongsRequest) String() string
type BelongsResponse ¶ added in v0.3.2
type BelongsResponse struct { Belongs bool `protobuf:"varint,1,opt,name=belongs,proto3" json:"belongs,omitempty"` // contains filtered or unexported fields }
func (*BelongsResponse) Descriptor
deprecated
added in
v0.3.2
func (*BelongsResponse) Descriptor() ([]byte, []int)
Deprecated: Use BelongsResponse.ProtoReflect.Descriptor instead.
func (*BelongsResponse) GetBelongs ¶ added in v0.3.2
func (x *BelongsResponse) GetBelongs() bool
func (*BelongsResponse) ProtoMessage ¶ added in v0.3.2
func (*BelongsResponse) ProtoMessage()
func (*BelongsResponse) ProtoReflect ¶ added in v0.3.2
func (x *BelongsResponse) ProtoReflect() protoreflect.Message
func (*BelongsResponse) Reset ¶ added in v0.3.2
func (x *BelongsResponse) Reset()
func (*BelongsResponse) String ¶ added in v0.3.2
func (x *BelongsResponse) String() string
type GetHomePodIPRequest ¶
type GetHomePodIPRequest struct { ClusterID string `protobuf:"bytes,1,opt,name=clusterID,proto3" json:"clusterID,omitempty"` Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` // contains filtered or unexported fields }
func (*GetHomePodIPRequest) Descriptor
deprecated
func (*GetHomePodIPRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetHomePodIPRequest.ProtoReflect.Descriptor instead.
func (*GetHomePodIPRequest) GetClusterID ¶
func (x *GetHomePodIPRequest) GetClusterID() string
func (*GetHomePodIPRequest) GetIp ¶
func (x *GetHomePodIPRequest) GetIp() string
func (*GetHomePodIPRequest) ProtoMessage ¶
func (*GetHomePodIPRequest) ProtoMessage()
func (*GetHomePodIPRequest) ProtoReflect ¶
func (x *GetHomePodIPRequest) ProtoReflect() protoreflect.Message
func (*GetHomePodIPRequest) Reset ¶
func (x *GetHomePodIPRequest) Reset()
func (*GetHomePodIPRequest) String ¶
func (x *GetHomePodIPRequest) String() string
type GetHomePodIPResponse ¶
type GetHomePodIPResponse struct { HomeIP string `protobuf:"bytes,1,opt,name=homeIP,proto3" json:"homeIP,omitempty"` // contains filtered or unexported fields }
func (*GetHomePodIPResponse) Descriptor
deprecated
func (*GetHomePodIPResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetHomePodIPResponse.ProtoReflect.Descriptor instead.
func (*GetHomePodIPResponse) GetHomeIP ¶
func (x *GetHomePodIPResponse) GetHomeIP() string
func (*GetHomePodIPResponse) ProtoMessage ¶
func (*GetHomePodIPResponse) ProtoMessage()
func (*GetHomePodIPResponse) ProtoReflect ¶
func (x *GetHomePodIPResponse) ProtoReflect() protoreflect.Message
func (*GetHomePodIPResponse) Reset ¶
func (x *GetHomePodIPResponse) Reset()
func (*GetHomePodIPResponse) String ¶
func (x *GetHomePodIPResponse) String() string
type IPAM ¶
type IPAM struct { UnimplementedIpamServer // contains filtered or unexported fields }
IPAM implementation.
func (*IPAM) AcquireReservedSubnet ¶
AcquireReservedSubnet marks as used the network received as parameter.
func (*IPAM) AddLocalSubnetsPerCluster ¶
AddLocalSubnetsPerCluster stores how the PodCIDR and the ExternalCIDR of local cluster has been remapped in a remote cluster. If no remapping happened, then the CIDR value should be equal to "None".
func (*IPAM) AddNetworkPool ¶
AddNetworkPool adds a network to the set of network pools.
func (*IPAM) BelongsToPodCIDR ¶ added in v0.3.2
func (liqoIPAM *IPAM) BelongsToPodCIDR(ctx context.Context, belongsRequest *BelongsRequest) (*BelongsResponse, error)
BelongsToPodCIDR tells if the given IP belongs to the remote pod CIDR for the given cluster.
func (*IPAM) FreeReservedSubnet ¶
FreeReservedSubnet marks as free a reserved subnet.
func (*IPAM) GetExternalCIDR ¶
GetExternalCIDR chooses and returns the local cluster's ExternalCIDR.
func (*IPAM) GetHomePodIP ¶
func (liqoIPAM *IPAM) GetHomePodIP(ctx context.Context, request *GetHomePodIPRequest) (*GetHomePodIPResponse, error)
GetHomePodIP receives a Pod IP valid in the remote cluster and returns the corresponding home Pod IP (i.e. with validity in home cluster).
func (*IPAM) GetSubnetsPerCluster ¶
func (liqoIPAM *IPAM) GetSubnetsPerCluster( podCidr, externalCIDR, clusterID string) (mappedPodCIDR, mappedExternalCIDR string, err error)
GetSubnetsPerCluster receives a PodCIDR, and a Cluster ID and returns a PodCIDR and an ExternalCIDR. The PodCIDR can be either the received one or a new one, if conflicts have been found. The same happens for ExternalCIDR.
func (*IPAM) MapEndpointIP ¶
func (liqoIPAM *IPAM) MapEndpointIP(ctx context.Context, mapRequest *MapRequest) (*MapResponse, error)
MapEndpointIP receives a service endpoint IP and a cluster identifier and, if the endpoint IP does not belong to cluster PodCIDR, maps the endpoint IP to a new IP taken from the remote ExternalCIDR of the remote cluster.
func (*IPAM) MarkAsAcquiredReservedSubnet ¶ added in v0.3.1
MarkAsAcquiredReservedSubnet marks as used the network received as parameter.
func (*IPAM) RemoveClusterConfig ¶
RemoveClusterConfig frees remote PodCIDR and ExternalCIDR and deletes local subnets for the remote cluster.
func (*IPAM) RemoveLocalSubnetsPerCluster ¶
RemoveLocalSubnetsPerCluster deletes networks related to a cluster.
func (*IPAM) RemoveNetworkPool ¶
RemoveNetworkPool removes a network from the set of network pools.
func (*IPAM) SetPodCIDR ¶
SetPodCIDR sets the PodCIDR.
func (*IPAM) SetReservedSubnets ¶ added in v0.3.1
SetReservedSubnets acquires and/or frees the reserved networks.
func (*IPAM) SetServiceCIDR ¶
SetServiceCIDR sets the ServiceCIDR.
func (*IPAM) Terminate ¶
func (liqoIPAM *IPAM) Terminate()
Terminate function stops the gRPC server.
func (*IPAM) UnmapEndpointIP ¶
func (liqoIPAM *IPAM) UnmapEndpointIP(ctx context.Context, unmapRequest *UnmapRequest) (*UnmapResponse, error)
UnmapEndpointIP set the endpoint as unused for a specific cluster.
type IPAMStorage ¶
IPAMStorage is an implementation of IpamStorage that takes advantage of the CRD IpamStorage.
func NewIPAMStorage ¶
func NewIPAMStorage(dynClient dynamic.Interface) (*IPAMStorage, error)
NewIPAMStorage inits the storage of the IPAM module, retrieving an existing ipamStorage resource or creating a new one.
func (*IPAMStorage) CreatePrefix ¶
CreatePrefix creates a new Prefix in ipamStorage resource.
func (*IPAMStorage) DeletePrefix ¶
DeletePrefix deletes a Prefix from ipamStorage resource.
func (*IPAMStorage) ReadAllPrefixCidrs ¶
func (ipamStorage *IPAMStorage) ReadAllPrefixCidrs() ([]string, error)
ReadAllPrefixCidrs retrieves all prefix CIDR from ipamStorage resource.
func (*IPAMStorage) ReadAllPrefixes ¶
func (ipamStorage *IPAMStorage) ReadAllPrefixes() ([]goipam.Prefix, error)
ReadAllPrefixes retrieves all prefixes from ipamStorage resource.
func (*IPAMStorage) ReadPrefix ¶
func (ipamStorage *IPAMStorage) ReadPrefix(prefix string) (goipam.Prefix, error)
ReadPrefix retrieves a specific Prefix from ipamStorage resource.
func (*IPAMStorage) UpdatePrefix ¶
UpdatePrefix updates a Prefix in ipamStorage resource.
type Ipam ¶
type Ipam interface { /* GetSubnetsPerCluster receives PodCIDR and ExternalCIDR of a remote cluster and checks if those networks generate conflicts with other networks(reserved ones or even PodCIDR and ExternalCIDR of other clusters). If no conflicts are found, networks are reserved so that they cannot be used by any other cluster. In this way IPAM guarrantees that traffic toward these networks is directed to only one remote cluster. If conflicts are found, received networks are ignored and they are substituted with a new network chosen by the IPAM. These new network are reserved as well. The remapping mechanism can be applied on: - PodCIDR - ExternalCIDR - Both. */ GetSubnetsPerCluster(podCidr, externalCIDR, clusterID string) (string, string, error) // RemoveClusterConfig deletes the IPAM configuration of a remote cluster, // by freeing networks and removing data structures related to that cluster. RemoveClusterConfig(clusterID string) error // AcquireReservedSubnet reserves a network. AcquireReservedSubnet(network string) error // FreeReservedSubnet frees a network. FreeReservedSubnet(network string) error // AddNetworkPool adds a network to the set of default network pools. AddNetworkPool(network string) error // RemoveNetworkPool removes a network from the set of network pools. RemoveNetworkPool(network string) error /* AddLocalSubnetsPerCluster stores the PodCIDR and the ExternalCIDR used in the remote cluster to map the local cluster subnets. Since those networks are used in the remote cluster this function must not reserve it. If the remote cluster has not remapped a local subnet, then CIDR value should be equal to "None". */ AddLocalSubnetsPerCluster(podCIDR, externalCIDR, clusterID string) error GetExternalCIDR(mask uint8) (string, error) // SetPodCIDR sets the cluster PodCIDR. SetPodCIDR(podCIDR string) error // SetServiceCIDR sets the cluster ServiceCIDR. SetServiceCIDR(serviceCIDR string) error // Terminate function enforces a graceful termination of the IPAM module. Terminate() IpamServer }
Ipam Interface.
type IpamClient ¶
type IpamClient interface { MapEndpointIP(ctx context.Context, in *MapRequest, opts ...grpc.CallOption) (*MapResponse, error) UnmapEndpointIP(ctx context.Context, in *UnmapRequest, opts ...grpc.CallOption) (*UnmapResponse, error) GetHomePodIP(ctx context.Context, in *GetHomePodIPRequest, opts ...grpc.CallOption) (*GetHomePodIPResponse, error) BelongsToPodCIDR(ctx context.Context, in *BelongsRequest, opts ...grpc.CallOption) (*BelongsResponse, error) }
IpamClient is the client API for Ipam service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewIpamClient ¶
func NewIpamClient(cc grpc.ClientConnInterface) IpamClient
type IpamServer ¶
type IpamServer interface { MapEndpointIP(context.Context, *MapRequest) (*MapResponse, error) UnmapEndpointIP(context.Context, *UnmapRequest) (*UnmapResponse, error) GetHomePodIP(context.Context, *GetHomePodIPRequest) (*GetHomePodIPResponse, error) BelongsToPodCIDR(context.Context, *BelongsRequest) (*BelongsResponse, error) // contains filtered or unexported methods }
IpamServer is the server API for Ipam service. All implementations must embed UnimplementedIpamServer for forward compatibility
type IpamStorage ¶
IpamStorage is the interface to be implemented to enforce persistency in IPAM.
type MapRequest ¶
type MapRequest struct { ClusterID string `protobuf:"bytes,1,opt,name=clusterID,proto3" json:"clusterID,omitempty"` Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` // contains filtered or unexported fields }
func (*MapRequest) Descriptor
deprecated
func (*MapRequest) Descriptor() ([]byte, []int)
Deprecated: Use MapRequest.ProtoReflect.Descriptor instead.
func (*MapRequest) GetClusterID ¶
func (x *MapRequest) GetClusterID() string
func (*MapRequest) GetIp ¶
func (x *MapRequest) GetIp() string
func (*MapRequest) ProtoMessage ¶
func (*MapRequest) ProtoMessage()
func (*MapRequest) ProtoReflect ¶
func (x *MapRequest) ProtoReflect() protoreflect.Message
func (*MapRequest) Reset ¶
func (x *MapRequest) Reset()
func (*MapRequest) String ¶
func (x *MapRequest) String() string
type MapResponse ¶
type MapResponse struct { Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` // contains filtered or unexported fields }
func (*MapResponse) Descriptor
deprecated
func (*MapResponse) Descriptor() ([]byte, []int)
Deprecated: Use MapResponse.ProtoReflect.Descriptor instead.
func (*MapResponse) GetIp ¶
func (x *MapResponse) GetIp() string
func (*MapResponse) ProtoMessage ¶
func (*MapResponse) ProtoMessage()
func (*MapResponse) ProtoReflect ¶
func (x *MapResponse) ProtoReflect() protoreflect.Message
func (*MapResponse) Reset ¶
func (x *MapResponse) Reset()
func (*MapResponse) String ¶
func (x *MapResponse) String() string
type UnimplementedIpamServer ¶
type UnimplementedIpamServer struct { }
UnimplementedIpamServer must be embedded to have forward compatible implementations.
func (UnimplementedIpamServer) BelongsToPodCIDR ¶ added in v0.3.2
func (UnimplementedIpamServer) BelongsToPodCIDR(context.Context, *BelongsRequest) (*BelongsResponse, error)
func (UnimplementedIpamServer) GetHomePodIP ¶
func (UnimplementedIpamServer) GetHomePodIP(context.Context, *GetHomePodIPRequest) (*GetHomePodIPResponse, error)
func (UnimplementedIpamServer) MapEndpointIP ¶
func (UnimplementedIpamServer) MapEndpointIP(context.Context, *MapRequest) (*MapResponse, error)
func (UnimplementedIpamServer) UnmapEndpointIP ¶
func (UnimplementedIpamServer) UnmapEndpointIP(context.Context, *UnmapRequest) (*UnmapResponse, error)
type UnmapRequest ¶
type UnmapRequest struct { ClusterID string `protobuf:"bytes,1,opt,name=clusterID,proto3" json:"clusterID,omitempty"` Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` // contains filtered or unexported fields }
func (*UnmapRequest) Descriptor
deprecated
func (*UnmapRequest) Descriptor() ([]byte, []int)
Deprecated: Use UnmapRequest.ProtoReflect.Descriptor instead.
func (*UnmapRequest) GetClusterID ¶
func (x *UnmapRequest) GetClusterID() string
func (*UnmapRequest) GetIp ¶
func (x *UnmapRequest) GetIp() string
func (*UnmapRequest) ProtoMessage ¶
func (*UnmapRequest) ProtoMessage()
func (*UnmapRequest) ProtoReflect ¶
func (x *UnmapRequest) ProtoReflect() protoreflect.Message
func (*UnmapRequest) Reset ¶
func (x *UnmapRequest) Reset()
func (*UnmapRequest) String ¶
func (x *UnmapRequest) String() string
type UnmapResponse ¶
type UnmapResponse struct {
// contains filtered or unexported fields
}
func (*UnmapResponse) Descriptor
deprecated
func (*UnmapResponse) Descriptor() ([]byte, []int)
Deprecated: Use UnmapResponse.ProtoReflect.Descriptor instead.
func (*UnmapResponse) ProtoMessage ¶
func (*UnmapResponse) ProtoMessage()
func (*UnmapResponse) ProtoReflect ¶
func (x *UnmapResponse) ProtoReflect() protoreflect.Message
func (*UnmapResponse) Reset ¶
func (x *UnmapResponse) Reset()
func (*UnmapResponse) String ¶
func (x *UnmapResponse) String() string
type UnsafeIpamServer ¶
type UnsafeIpamServer interface {
// contains filtered or unexported methods
}
UnsafeIpamServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to IpamServer will result in compilation errors.