util

package
v1.8.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

TODO: consider moving it to a more generic package.

Index

Constants

View Source
const (
	KubeAPIQPS              = 20.0
	KubeAPIBurst            = 30
	KubeconfigSecretDataKey = "kubeconfig"
)
View Source
const (
	OperationTypeAdd    = "add"
	OperationTypeUpdate = "update"
	OperationTypeDelete = "delete"
)

Variables

View Source
var KubeconfigGetterForSecret = func(secret *api.Secret) clientcmd.KubeconfigGetter {
	return func() (*clientcmdapi.Config, error) {
		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 gets the kubeconfig from the given secret. 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 set up service accounts and mount files with secret tokens.

Functions

func BuildClusterConfig

func BuildClusterConfig(c *federation_v1beta1.Cluster) (*restclient.Config, error)

func ConfigMapEquivalent added in v1.5.0

func ConfigMapEquivalent(s1, s2 *api_v1.ConfigMap) bool

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 added in v1.5.0

func DeepCopyApiTypeOrPanic(item interface{}) interface{}

func DeepCopyDeployment added in v1.5.0

func DeepCopyDeployment(a *extensions_v1.Deployment) *extensions_v1.Deployment

Copies object meta for Deployment, skipping revision information.

func DeepCopyDeploymentObjectMeta added in v1.5.0

func DeepCopyDeploymentObjectMeta(meta metav1.ObjectMeta) metav1.ObjectMeta

Copies object meta for Deployment, skipping revision information.

func DeepCopyRelevantObjectMeta added in v1.5.0

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 added in v1.5.0

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 NewTriggerOnAllChanges added in v1.4.0

func NewTriggerOnAllChanges(triggerFunc func(pkgruntime.Object)) *cache.ResourceEventHandlerFuncs

Returns cache.ResourceEventHandlerFuncs that trigger the given function on all object changes.

func NewTriggerOnMetaAndFieldChanges added in v1.7.0

func NewTriggerOnMetaAndFieldChanges(field string, triggerFunc func(pkgruntime.Object)) *cache.ResourceEventHandlerFuncs

Returns cache.ResourceEventHandlerFuncs that trigger the given function on object add/delete or ObjectMeta or given field is updated.

func NewTriggerOnMetaAndSpecChanges added in v1.4.0

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 added in v1.5.0

func ObjectMetaAndSpecEquivalent(a, b runtime.Object) bool

Checks if cluster-independent, user provided data in ObjectMeta and Spec in two given top level api objects are equivalent.

func ObjectMetaEquivalent added in v1.4.0

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 added in v1.4.0

func SecretEquivalent(s1, s2 api_v1.Secret) bool

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 added in v1.5.0

func StartBackoffGC(backoff *flowcontrol.Backoff, stopCh <-chan struct{})

Types

type ClusterLifecycleHandlerFuncs added in v1.4.0

type ClusterLifecycleHandlerFuncs struct {
	// Fired when the cluster becomes available.
	ClusterAvailable func(*federationapi.Cluster)
	// Fired when the cluster becomes unavailable. The second arg contains data that was present
	// 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 added in v1.4.0

type DelayingDeliverer struct {
	// contains filtered or unexported fields
}

A structure that pushes the items to the target channel at a given time.

func NewDelayingDeliverer added in v1.4.0

func NewDelayingDeliverer() *DelayingDeliverer

func NewDelayingDelivererWithChannel added in v1.4.0

func NewDelayingDelivererWithChannel(targetChannel chan *DelayingDelivererItem) *DelayingDeliverer

func (*DelayingDeliverer) DeliverAfter added in v1.4.0

func (d *DelayingDeliverer) DeliverAfter(key string, value interface{}, delay time.Duration)

Delivers value after the given delay.

func (*DelayingDeliverer) DeliverAt added in v1.4.0

func (d *DelayingDeliverer) DeliverAt(key string, value interface{}, deliveryTime time.Time)

Delivers value at the given time.

func (*DelayingDeliverer) GetTargetChannel added in v1.4.0

func (d *DelayingDeliverer) GetTargetChannel() chan *DelayingDelivererItem

Gets target channel of the deliverer.

func (*DelayingDeliverer) Start added in v1.4.0

func (d *DelayingDeliverer) Start()

Starts the DelayingDeliverer.

func (*DelayingDeliverer) StartWithHandler added in v1.4.0

func (d *DelayingDeliverer) StartWithHandler(handler func(*DelayingDelivererItem))

Starts Delaying deliverer with a handler listening on the target channel.

func (*DelayingDeliverer) Stop added in v1.4.0

func (d *DelayingDeliverer) Stop()

Stops the DelayingDeliverer. Undelivered items are discarded.

type DelayingDelivererItem added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

func NewFederatedInformer(
	federationClient federationclientset.Interface,
	targetInformerFactory TargetInformerFactory,
	clusterLifecycle *ClusterLifecycleHandlerFuncs) FederatedInformer

Builds a FederatedInformer for the given federation client and factory.

type FederatedInformerForTestOnly added in v1.4.0

type FederatedInformerForTestOnly interface {
	FederatedInformer

	SetClientFactory(func(*federationapi.Cluster) (kubeclientset.Interface, error))
}

FederatedInformer with extra method for setting fake clients.

type FederatedObject added in v1.4.0

type FederatedObject struct {
	Object      interface{}
	ClusterName string
}

An object with an origin information.

type FederatedOperation added in v1.4.0

type FederatedOperation struct {
	Type        FederatedOperationType
	ClusterName string
	Obj         pkgruntime.Object
	Key         string
}

FederatedOperation definition contains type (add/update/delete) and the object itself.

type FederatedOperationHandler added in v1.4.0

type FederatedOperationHandler func(kubeclientset.Interface, pkgruntime.Object) error

A function that executes some operation using the passed client and object.

type FederatedOperationType added in v1.4.0

type FederatedOperationType string

Type of the operation that can be executed in Federated.

type FederatedReadOnlyStore added in v1.4.0

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 added in v1.4.0

type FederatedUpdater interface {
	// Executes the given set of operations.
	Update([]FederatedOperation) error
}

A helper that executes the given set of updates on federation, in parallel.

func NewFederatedUpdater added in v1.4.0

func NewFederatedUpdater(federation FederationView, kind string, timeout time.Duration, recorder record.EventRecorder, add, update, del FederatedOperationHandler) FederatedUpdater

type FederationView added in v1.4.0

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 added in v1.4.0

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.

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.
Helper functions for manipulating finalizers.
Helper functions for manipulating finalizers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL