Documentation ¶
Overview ¶
Package crdreplicator implements the logic for the replication of CustomResourceDefinitions between the peered clusters.
Index ¶
- Constants
- Variables
- func SetLabelsForLocalResources(options *metav1.ListOptions)
- type Controller
- func (c *Controller) AddFunc(newObj interface{})
- func (c *Controller) AddedHandler(obj *unstructured.Unstructured, gvr schema.GroupVersionResource)
- func (c *Controller) CreateResource(dynClient dynamic.Interface, gvr schema.GroupVersionResource, ...) error
- func (c *Controller) DeleteFunc(newObj interface{})
- func (c *Controller) DeleteResource(cl dynamic.Interface, gvr schema.GroupVersionResource, ...) error
- func (c *Controller) DeletedHandler(obj *unstructured.Unstructured, gvr schema.GroupVersionResource)
- func (c *Controller) GetResource(client dynamic.Interface, gvr schema.GroupVersionResource, ...) (*unstructured.Unstructured, bool, error)
- func (c *Controller) ModifiedHandler(obj *unstructured.Unstructured, gvr schema.GroupVersionResource)
- func (c *Controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (c *Controller) RemoteResourceModifiedHandler(remDynClient dynamic.Interface, obj *unstructured.Unstructured, ...)
- func (c *Controller) SetLabelsForRemoteResources(options *metav1.ListOptions)
- func (c *Controller) SetupWithManager(mgr ctrl.Manager) error
- func (c *Controller) StartWatchers()
- func (c *Controller) StopWatchers()
- func (c *Controller) UpdateConfig(cfg *configv1alpha1.ClusterConfig)
- func (c *Controller) UpdateFunc(oldObj, newObj interface{})
- func (c *Controller) UpdateLabels(labels map[string]string) map[string]string
- func (c *Controller) UpdateResource(dynClient dynamic.Interface, gvr schema.GroupVersionResource, ...) error
- func (c *Controller) UpdateSpec(client dynamic.Interface, gvr schema.GroupVersionResource, ...) error
- func (c *Controller) UpdateStatus(client dynamic.Interface, gvr schema.GroupVersionResource, ...) error
- func (c *Controller) WatchConfiguration(config *rest.Config, gv *schema.GroupVersion) error
Constants ¶
const ( LocalLabelSelector = "liqo.io/replication" RemoteLabelSelector = "liqo.io/originID" DestinationLabel = "liqo.io/remoteID" ReplicationStatuslabel = "liqo.io/replicated" )
Variables ¶
var ReplicatedResourcesLabelSelector = metav1.LabelSelector{ MatchExpressions: []metav1.LabelSelectorRequirement{ { Key: RemoteLabelSelector, Operator: metav1.LabelSelectorOpExists, }, { Key: ReplicationStatuslabel, Operator: metav1.LabelSelectorOpExists, }, }, }
ReplicatedResourcesLabelSelector is an helper label selector to list all the replicated resources.
var (
ResyncPeriod = 30 * time.Second
)
Functions ¶
func SetLabelsForLocalResources ¶
func SetLabelsForLocalResources(options *metav1.ListOptions)
Types ¶
type Controller ¶
type Controller struct { Scheme *runtime.Scheme client.Client ClientSet *kubernetes.Clientset ClusterID string RemoteDynClients map[string]dynamic.Interface // for each remote cluster we save dynamic client connected to its API server LocalDynClient dynamic.Interface // dynamic client pointing to the local API server // RegisteredResources is a list of GVRs of resources to be replicated, with the associated peering phase when the replication has to occur. RegisteredResources []configv1alpha1.Resource // UnregisteredResources, each time a resource is removed from the configuration it is saved in this list, // it stays here until the associated watcher, if running, is stopped. UnregisteredResources []metav1.GroupVersionResource // LocalWatchers, we save all the running watchers monitoring the local resources:(registeredResource, chan)). LocalWatchers map[string]chan struct{} // RemoteWatchers, for each peering cluster we save all the running watchers monitoring the replicated resources: // (clusterID, (registeredResource, chan)). RemoteWatchers map[string]map[string]chan struct{} // NamespaceManager is an interface to manage the tenant namespaces. NamespaceManager tenantnamespace.Manager // IdentityReader is an interface to manage remote identities, and to get the rest config. IdentityReader identitymanager.IdentityReader // LocalToRemoteNamespaceMapper maps local namespaces to remote ones. LocalToRemoteNamespaceMapper map[string]string // RemoteToLocalNamespaceMapper maps remote namespaces to local ones. RemoteToLocalNamespaceMapper map[string]string // ClusterIDToLocalNamespaceMapper maps clusterIDs to local namespaces. ClusterIDToLocalNamespaceMapper map[string]string // ClusterIDToRemoteNamespaceMapper maps clusterIDs to remote namespaces. ClusterIDToRemoteNamespaceMapper map[string]string // contains filtered or unexported fields }
func (*Controller) AddFunc ¶
func (c *Controller) AddFunc(newObj interface{})
func (*Controller) AddedHandler ¶
func (c *Controller) AddedHandler(obj *unstructured.Unstructured, gvr schema.GroupVersionResource)
func (*Controller) CreateResource ¶
func (c *Controller) CreateResource(dynClient dynamic.Interface, gvr schema.GroupVersionResource, obj *unstructured.Unstructured, clusterID string, ownership consts.OwnershipType) error
CreateResource creates the object with the provided dynamicClient.
func (*Controller) DeleteFunc ¶
func (c *Controller) DeleteFunc(newObj interface{})
func (*Controller) DeleteResource ¶
func (c *Controller) DeleteResource(cl dynamic.Interface, gvr schema.GroupVersionResource, obj *unstructured.Unstructured, clusterID string) error
DeleteResource deletes the given resource with the specified client.
func (*Controller) DeletedHandler ¶
func (c *Controller) DeletedHandler(obj *unstructured.Unstructured, gvr schema.GroupVersionResource)
func (*Controller) GetResource ¶
func (c *Controller) GetResource(client dynamic.Interface, gvr schema.GroupVersionResource, name, namespace, clusterID string) (*unstructured.Unstructured, bool, error)
func (*Controller) ModifiedHandler ¶
func (c *Controller) ModifiedHandler(obj *unstructured.Unstructured, gvr schema.GroupVersionResource)
func (*Controller) RemoteResourceModifiedHandler ¶
func (c *Controller) RemoteResourceModifiedHandler(remDynClient dynamic.Interface, obj *unstructured.Unstructured, gvr schema.GroupVersionResource, remoteClusterID string, ownership consts.OwnershipType)
RemoteResourceModifiedHandler handles updates on a remote resource, updating the local status if it is in a shared ownership or forcing the remote status if the resource is only owned by the local cluster.
func (*Controller) SetLabelsForRemoteResources ¶
func (c *Controller) SetLabelsForRemoteResources(options *metav1.ListOptions)
func (*Controller) SetupWithManager ¶
func (c *Controller) SetupWithManager(mgr ctrl.Manager) error
func (*Controller) StartWatchers ¶
func (c *Controller) StartWatchers()
func (*Controller) StopWatchers ¶
func (c *Controller) StopWatchers()
StopWatchers stops all the watchers for the resources that have been unregistered.
func (*Controller) UpdateConfig ¶
func (c *Controller) UpdateConfig(cfg *configv1alpha1.ClusterConfig)
func (*Controller) UpdateFunc ¶
func (c *Controller) UpdateFunc(oldObj, newObj interface{})
func (*Controller) UpdateLabels ¶
func (c *Controller) UpdateLabels(labels map[string]string) map[string]string
func (*Controller) UpdateResource ¶
func (c *Controller) UpdateResource(dynClient dynamic.Interface, gvr schema.GroupVersionResource, obj *unstructured.Unstructured, clusterID string, ownership consts.OwnershipType) error
UpdateResource updates the object with the provided client. If the ownership is shared the status is ignored, if the owner is the local cluster is the owner, the local status is forced on the remote resource.
func (*Controller) UpdateSpec ¶
func (c *Controller) UpdateSpec(client dynamic.Interface, gvr schema.GroupVersionResource, obj *unstructured.Unstructured, clusterID string, spec map[string]interface{}) error
updates the spec field of a resource.
func (*Controller) UpdateStatus ¶
func (c *Controller) UpdateStatus(client dynamic.Interface, gvr schema.GroupVersionResource, obj *unstructured.Unstructured, clusterID string, status map[string]interface{}) error
updates the status field of a resource.
func (*Controller) WatchConfiguration ¶
func (c *Controller) WatchConfiguration(config *rest.Config, gv *schema.GroupVersion) error