Documentation ¶
Overview ¶
TODO: consider moving it to a more generic package.
Index ¶
- Constants
- Variables
- func BuildClusterConfig(c *federation_v1beta1.Cluster) (*restclient.Config, error)
- func ConfigMapEquivalent(s1, s2 *api_v1.ConfigMap) bool
- func DeepCopyApiTypeOrPanic(item interface{}) interface{}
- func DeepCopyDeployment(a *extensions_v1.Deployment) *extensions_v1.Deployment
- func DeepCopyDeploymentObjectMeta(meta metav1.ObjectMeta) metav1.ObjectMeta
- func DeepCopyRelevantObjectMeta(obj metav1.ObjectMeta) metav1.ObjectMeta
- func DeploymentEquivalent(a, b *extensions_v1.Deployment) bool
- func GetClientsetForCluster(cluster *federation_v1beta1.Cluster) (*fedclientset.Clientset, error)
- func NewTriggerOnAllChanges(triggerFunc func(pkgruntime.Object)) *cache.ResourceEventHandlerFuncs
- func NewTriggerOnMetaAndSpecChanges(triggerFunc func(pkgruntime.Object)) *cache.ResourceEventHandlerFuncs
- func ObjectMetaAndSpecEquivalent(a, b runtime.Object) bool
- func ObjectMetaEquivalent(a, b metav1.ObjectMeta) bool
- func SecretEquivalent(s1, s2 api_v1.Secret) bool
- func StartBackoffGC(backoff *flowcontrol.Backoff, stopCh <-chan struct{})
- type ClusterLifecycleHandlerFuncs
- type DelayingDeliverer
- func (d *DelayingDeliverer) DeliverAfter(key string, value interface{}, delay time.Duration)
- func (d *DelayingDeliverer) DeliverAt(key string, value interface{}, deliveryTime time.Time)
- func (d *DelayingDeliverer) GetTargetChannel() chan *DelayingDelivererItem
- func (d *DelayingDeliverer) Start()
- func (d *DelayingDeliverer) StartWithHandler(handler func(*DelayingDelivererItem))
- func (d *DelayingDeliverer) Stop()
- type DelayingDelivererItem
- type FederatedInformer
- type FederatedInformerForTestOnly
- type FederatedObject
- type FederatedOperation
- type FederatedOperationHandler
- type FederatedOperationType
- type FederatedReadOnlyStore
- type FederatedUpdater
- type FederationView
- type TargetInformerFactory
Constants ¶
const ( KubeAPIQPS = 20.0 KubeAPIBurst = 30 KubeconfigSecretDataKey = "kubeconfig" )
const ( OperationTypeAdd = "add" OperationTypeUpdate = "update" OperationTypeDelete = "delete" )
Variables ¶
var KubeconfigGetterForCluster = func(c *federation_v1beta1.Cluster) clientcmd.KubeconfigGetter { return func() (*clientcmdapi.Config, error) { secretRefName := "" if c.Spec.SecretRef != nil { secretRefName = c.Spec.SecretRef.Name } else { glog.Infof("didn't find secretRef for cluster %s. Trying insecure access", c.Name) } return KubeconfigGetterForSecret(secretRefName)() } }
This is to inject a different kubeconfigGetter in tests. We don't use the standard one which calls NewInCluster in tests to avoid having to setup service accounts and mount files with secret tokens.
var KubeconfigGetterForSecret = func(secretName string) clientcmd.KubeconfigGetter { return func() (*clientcmdapi.Config, error) { var data []byte if secretName != "" { namespace := os.Getenv("POD_NAMESPACE") if namespace == "" { return nil, fmt.Errorf("unexpected: POD_NAMESPACE env var returned empty string") } cc, err := restclient.InClusterConfig() if err != nil { return nil, fmt.Errorf("error in creating in-cluster client: %s", err) } client, err := clientset.NewForConfig(cc) if err != nil { return nil, fmt.Errorf("error in creating in-cluster client: %s", err) } data = []byte{} var secret *api.Secret err = wait.PollImmediate(1*time.Second, getSecretTimeout, func() (bool, error) { secret, err = client.Core().Secrets(namespace).Get(secretName, metav1.GetOptions{}) if err == nil { return true, nil } glog.Warningf("error in fetching secret: %s", err) return false, nil }) if err != nil { return nil, fmt.Errorf("timed out waiting for secret: %s", err) } if secret == nil { return nil, fmt.Errorf("unexpected: received null secret %s", secretName) } ok := false data, ok = secret.Data[KubeconfigSecretDataKey] if !ok { return nil, fmt.Errorf("secret does not have data with key: %s", KubeconfigSecretDataKey) } } return clientcmd.Load(data) } }
KubeconfigGetterForSecret is used to get the kubeconfig from the given secret.
Functions ¶
func BuildClusterConfig ¶
func BuildClusterConfig(c *federation_v1beta1.Cluster) (*restclient.Config, error)
func ConfigMapEquivalent ¶
Checks if cluster-independent, user provided data in two given ConfigMaps are equal. If in the future the ConfigMap structure is expanded then any field that is not populated. by the api server should be included here.
func DeepCopyApiTypeOrPanic ¶
func DeepCopyApiTypeOrPanic(item interface{}) interface{}
func DeepCopyDeployment ¶
func DeepCopyDeployment(a *extensions_v1.Deployment) *extensions_v1.Deployment
Copies object meta for Deployment, skipping revision information.
func DeepCopyDeploymentObjectMeta ¶
func DeepCopyDeploymentObjectMeta(meta metav1.ObjectMeta) metav1.ObjectMeta
Copies object meta for Deployment, skipping revision information.
func DeepCopyRelevantObjectMeta ¶
func DeepCopyRelevantObjectMeta(obj metav1.ObjectMeta) metav1.ObjectMeta
Deep copies cluster-independent, user provided data from the given ObjectMeta struct. If in the future the ObjectMeta structure is expanded then any field that is not populated by the api server should be included here.
func DeploymentEquivalent ¶
func DeploymentEquivalent(a, b *extensions_v1.Deployment) bool
Checks if cluster-independent, user provided data in two given Deployment are equal. This function assumes that revisions are not kept in sync across the clusters.
func GetClientsetForCluster ¶
func GetClientsetForCluster(cluster *federation_v1beta1.Cluster) (*fedclientset.Clientset, error)
Returns Clientset for the given cluster.
func NewTriggerOnAllChanges ¶
func NewTriggerOnAllChanges(triggerFunc func(pkgruntime.Object)) *cache.ResourceEventHandlerFuncs
Returns cache.ResourceEventHandlerFuncs that trigger the given function on all object changes.
func NewTriggerOnMetaAndSpecChanges ¶
func NewTriggerOnMetaAndSpecChanges(triggerFunc func(pkgruntime.Object)) *cache.ResourceEventHandlerFuncs
Returns cache.ResourceEventHandlerFuncs that trigger the given function on object add and delete as well as spec/object meta on update.
func ObjectMetaAndSpecEquivalent ¶
Checks if cluster-independent, user provided data in ObjectMeta and Spec in two given top level api objects are equivalent.
func ObjectMetaEquivalent ¶
func ObjectMetaEquivalent(a, b metav1.ObjectMeta) bool
Checks if cluster-independent, user provided data in two given ObjectMeta are equal. If in the future the ObjectMeta structure is expanded then any field that is not populated by the api server should be included here.
func SecretEquivalent ¶
Checks if cluster-independent, user provided data in two given Secrets are equal. If in the future the Secret structure is expanded then any field that is not populated. by the api server should be included here.
func StartBackoffGC ¶
func StartBackoffGC(backoff *flowcontrol.Backoff, stopCh <-chan struct{})
Types ¶
type ClusterLifecycleHandlerFuncs ¶
type ClusterLifecycleHandlerFuncs struct { // Fired when the cluster becomes available. ClusterAvailable func(*federationapi.Cluster) // in the cluster before deletion. ClusterUnavailable func(*federationapi.Cluster, []interface{}) }
A structure with cluster lifecycle handler functions. Cluster is available (and ClusterAvailable is fired) when it is created in federated etcd and ready. Cluster becomes unavailable (and ClusterUnavailable is fired) when it is either deleted or becomes not ready. When cluster spec (IP)is modified both ClusterAvailable and ClusterUnavailable are fired.
type DelayingDeliverer ¶
type DelayingDeliverer struct {
// contains filtered or unexported fields
}
A structure that pushes the items to the target channel at a given time.
func NewDelayingDeliverer ¶
func NewDelayingDeliverer() *DelayingDeliverer
func NewDelayingDelivererWithChannel ¶
func NewDelayingDelivererWithChannel(targetChannel chan *DelayingDelivererItem) *DelayingDeliverer
func (*DelayingDeliverer) DeliverAfter ¶
func (d *DelayingDeliverer) DeliverAfter(key string, value interface{}, delay time.Duration)
Delivers value after the given delay.
func (*DelayingDeliverer) DeliverAt ¶
func (d *DelayingDeliverer) DeliverAt(key string, value interface{}, deliveryTime time.Time)
Delivers value at the given time.
func (*DelayingDeliverer) GetTargetChannel ¶
func (d *DelayingDeliverer) GetTargetChannel() chan *DelayingDelivererItem
Gets target channel of the deliverer.
func (*DelayingDeliverer) StartWithHandler ¶
func (d *DelayingDeliverer) StartWithHandler(handler func(*DelayingDelivererItem))
Starts Delaying deliverer with a handler listening on the target channel.
func (*DelayingDeliverer) Stop ¶
func (d *DelayingDeliverer) Stop()
Stops the DelayingDeliverer. Undelivered items are discarded.
type DelayingDelivererItem ¶
type DelayingDelivererItem struct { // Key under which the value was added to deliverer. Key string // Value of the item. Value interface{} // When the item should be delivered. DeliveryTime time.Time }
DelayingDelivererItem is structure delivered by DelayingDeliverer to the target channel.
type FederatedInformer ¶
type FederatedInformer interface { FederationView // Returns a store created over all stores from target informers. GetTargetStore() FederatedReadOnlyStore // Starts all the processes. Start() // Stops all the processes inside the informer. Stop() }
A structure that combines an informer running against federated api server and listening for cluster updates with multiple Kubernetes API informers (called target informers) running against federation members. Whenever a new cluster is added to the federation an informer is created for it using TargetInformerFactory. Informers are stopped when a cluster is either put offline of deleted. It is assumed that some controller keeps an eye on the cluster list and thus the clusters in ETCD are up to date.
func NewFederatedInformer ¶
func NewFederatedInformer( federationClient federationclientset.Interface, targetInformerFactory TargetInformerFactory, clusterLifecycle *ClusterLifecycleHandlerFuncs) FederatedInformer
Builds a FederatedInformer for the given federation client and factory.
type FederatedInformerForTestOnly ¶
type FederatedInformerForTestOnly interface { FederatedInformer SetClientFactory(func(*federationapi.Cluster) (kubeclientset.Interface, error)) }
FederatedInformer with extra method for setting fake clients.
type FederatedObject ¶
type FederatedObject struct { Object interface{} ClusterName string }
An object with an origin information.
type FederatedOperation ¶
type FederatedOperation struct { Type FederatedOperationType ClusterName string Obj pkgruntime.Object }
FederatedOperation definition contains type (add/update/delete) and the object itself.
type FederatedOperationHandler ¶
type FederatedOperationHandler func(kubeclientset.Interface, pkgruntime.Object) error
A function that executes some operation using the passed client and object.
type FederatedOperationType ¶
type FederatedOperationType string
Type of the operation that can be executed in Federated.
type FederatedReadOnlyStore ¶
type FederatedReadOnlyStore interface { // Returns all items in the store. List() ([]FederatedObject, error) // Returns all items from a cluster. ListFromCluster(clusterName string) ([]interface{}, error) // GetKeyFor returns the key under which the item would be put in the store. GetKeyFor(item interface{}) string // GetByKey returns the item stored under the given key in the specified cluster (if exist). GetByKey(clusterName string, key string) (interface{}, bool, error) // Returns the items stored under the given key in all clusters. GetFromAllClusters(key string) ([]FederatedObject, error) // Checks whether stores for all clusters form the lists (and only these) are there and // are synced. This is only a basic check whether the data inside of the store is usable. // It is not a full synchronization/locking mechanism it only tries to ensure that out-of-sync // issues occur less often. All users of the interface should assume // that there may be significant delays in content updates of all kinds and write their // code that it doesn't break if something is slightly out-of-sync. ClustersSynced(clusters []*federationapi.Cluster) bool }
FederatedReadOnlyStore is an overlay over multiple stores created in federated clusters.
type FederatedUpdater ¶
type FederatedUpdater interface { // Executes the given set of operations within the specified timeout. // Timeout is best-effort. There is no guarantee that the underlying operations are // stopped when it is reached. However the function will return after the timeout // with a non-nil error. Update([]FederatedOperation, time.Duration) error UpdateWithOnError([]FederatedOperation, time.Duration, func(FederatedOperation, error)) error }
A helper that executes the given set of updates on federation, in parallel.
func NewFederatedUpdater ¶
func NewFederatedUpdater(federation FederationView, add, update, del FederatedOperationHandler) FederatedUpdater
type FederationView ¶
type FederationView interface { // GetClientsetForCluster returns a clientset for the cluster, if present. GetClientsetForCluster(clusterName string) (kubeclientset.Interface, error) // GetUnreadyClusters returns a list of all clusters that are not ready yet. GetUnreadyClusters() ([]*federationapi.Cluster, error) // GetReadyClusters returns all clusters for which the sub-informers are run. GetReadyClusters() ([]*federationapi.Cluster, error) // GetReadyCluster returns the cluster with the given name, if found. GetReadyCluster(name string) (*federationapi.Cluster, bool, error) // ClustersSynced returns true if the view is synced (for the first time). ClustersSynced() bool }
An interface to access federation members and clients.
type TargetInformerFactory ¶
type TargetInformerFactory func(*federationapi.Cluster, kubeclientset.Interface) (cache.Store, cache.Controller)
A function that should be used to create an informer on the target object. Store should use cache.DeletionHandlingMetaNamespaceKeyFunc as a keying function.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package to help federation controllers to delete federated resources from underlying clusters when the resource is deleted from federation control plane.
|
Package to help federation controllers to delete federated resources from underlying clusters when the resource is deleted from federation control plane. |