Documentation
¶
Overview ¶
Package ipamutil implements various utility functions to assist with CAPI IPAM implementation.
Index ¶
Constants ¶
const ( // ReleaseAddressFinalizer is used to release an IP address before cleaning up the claim. ReleaseAddressFinalizer = "ipam.cluster.x-k8s.io/ReleaseAddress" // ProtectAddressFinalizer is used to prevent deletion of an IPAddress object while its claim is not deleted. ProtectAddressFinalizer = "ipam.cluster.x-k8s.io/ProtectAddress" )
Variables ¶
This section is empty.
Functions ¶
func NewIPAddress ¶
NewIPAddress creates a new ipamv1.IPAddress with references to a pool and claim.
Types ¶
type ClaimHandler ¶
type ClaimHandler interface { // FetchPool is called to fetch the pool referenced by the claim. The pool needs to be stored by the handler. FetchPool(ctx context.Context) (client.Object, *ctrl.Result, error) // EnsureAddress is called to make sure that the IPAddress.Spec is correct and the address is allocated. EnsureAddress(ctx context.Context, address *ipamv1.IPAddress) (*ctrl.Result, error) // ReleaseAddress is called to release the ip address that was allocated for the claim. ReleaseAddress(ctx context.Context) (*ctrl.Result, error) }
ClaimHandler knows how to allocate and release IP addresses for a specific provider.
type ClaimReconciler ¶
type ClaimReconciler struct { client.Client Scheme *runtime.Scheme WatchFilterValue string Adapter ProviderAdapter }
ClaimReconciler reconciles a IPAddressClaim object using a ProviderAdapter. It can be used to implement custom IPAM providers without worrying about the basic lifecycle, pausing and owner references, which should be the same or very similar for any provider. The custom implementation for a specific provider is provided by implementing the ProviderAdapter interface. The ClaimReconciler can then be used as follows, with controllers.InClusterProviderAdapter serving as the provider implementation.
(&ipamutil.ClaimReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), WatchFilterValue: watchFilter, Adapter: &controllers.InClusterProviderAdapter{}, }).SetupWithManager(ctx, mgr)
func (*ClaimReconciler) Reconcile ¶
func (r *ClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)
Reconcile is called by the controller to reconcile a claim.
func (*ClaimReconciler) SetupWithManager ¶
SetupWithManager sets up the controller with the Manager.
type ProviderAdapter ¶
type ProviderAdapter interface { // SetupWithManager will be called during the setup of the controller for the ClaimReconciler to allow the provider // implementation to extend the controller configuration. SetupWithManager(context.Context, *ctrl.Builder) error // ClaimHandlerFor is called during reconciliation to get a ClaimHandler for the reconciled [ipamv1.IPAddressClaim]. ClaimHandlerFor(client.Client, *ipamv1.IPAddressClaim) ClaimHandler }
ProviderAdapter is an interface that must be implemented by the IPAM provider.