kubernetes: k8s.io/kubernetes/pkg/controller Index | Files | Directories

package controller

import "k8s.io/kubernetes/pkg/controller"

Package controller contains code for controllers (like the replication controller).

Index

Package Files

client_builder.go client_builder_dynamic.go controller_ref_manager.go controller_utils.go doc.go informer_factory.go lookup_cache.go

Constants

const (
    // If a watch drops a delete event for a pod, it'll take this long
    // before a dormant controller waiting for those packets is woken up anyway. It is
    // specifically targeted at the case where some problem prevents an update
    // of expectations, without it the controller could stay asleep forever. This should
    // be set based on the expected latency of watch events.
    //
    // Currently a controller can service (create *and* observe the watch events for said
    // creation) about 10 pods a second, so it takes about 1 min to service
    // 500 pods. Just creation is limited to 20qps, and watching happens with ~10-30s
    // latency/pod at the scale of 3000 pods over 100 nodes.
    ExpectationsTimeout = 5 * time.Minute
    // When batching pod creates, SlowStartInitialBatchSize is the size of the
    // initial batch.  The size of each successive batch is twice the size of
    // the previous batch.  For example, for a value of 1, batch sizes would be
    // 1, 2, 4, 8, ...  and for a value of 10, batch sizes would be
    // 10, 20, 40, 80, ...  Setting the value higher means that quota denials
    // will result in more doomed API calls and associated event spam.  Setting
    // the value lower will result in more API call round trip periods for
    // large batches.
    //
    // Given a number of pods to start "N":
    // The number of doomed calls per sync once quota is exceeded is given by:
    //      min(N,SlowStartInitialBatchSize)
    // The number of batches is given by:
    //      1+floor(log_2(ceil(N/SlowStartInitialBatchSize)))
    SlowStartInitialBatchSize = 1
)
const (
    // FailedCreatePodReason is added in an event and in a replica set condition
    // when a pod for a replica set is failed to be created.
    FailedCreatePodReason = "FailedCreate"
    // SuccessfulCreatePodReason is added in an event when a pod for a replica set
    // is successfully created.
    SuccessfulCreatePodReason = "SuccessfulCreate"
    // FailedDeletePodReason is added in an event and in a replica set condition
    // when a pod for a replica set is failed to be deleted.
    FailedDeletePodReason = "FailedDelete"
    // SuccessfulDeletePodReason is added in an event when a pod for a replica set
    // is successfully deleted.
    SuccessfulDeletePodReason = "SuccessfulDelete"
)

Reasons for pod events

Variables

var ExpKeyFunc = func(obj interface{}) (string, error) {
    if e, ok := obj.(*ControlleeExpectations); ok {
        return e.key, nil
    }
    return "", fmt.Errorf("could not find key for obj %#v", obj)
}

ExpKeyFunc to parse out the key from a ControlleeExpectation

var (
    KeyFunc = cache.DeletionHandlingMetaNamespaceKeyFunc
)
var UIDSetKeyFunc = func(obj interface{}) (string, error) {
    if u, ok := obj.(*UIDSet); ok {
        return u.key, nil
    }
    return "", fmt.Errorf("could not find key for obj %#v", obj)
}

UIDSetKeyFunc to parse out the key from a UIDSet.

var UpdateLabelBackoff = wait.Backoff{
    Steps:    5,
    Duration: 100 * time.Millisecond,
    Jitter:   1.0,
}
var UpdateTaintBackoff = wait.Backoff{
    Steps:    5,
    Duration: 100 * time.Millisecond,
    Jitter:   1.0,
}

func AddOrUpdateLabelsOnNode Uses

func AddOrUpdateLabelsOnNode(kubeClient clientset.Interface, nodeName string, labelsToUpdate map[string]string) error

func AddOrUpdateTaintOnNode Uses

func AddOrUpdateTaintOnNode(c clientset.Interface, nodeName string, taints ...*v1.Taint) error

AddOrUpdateTaintOnNode add taints to the node. If taint was added into node, it'll issue API calls to update nodes; otherwise, no API calls. Return error if any.

func ComputeHash Uses

func ComputeHash(template *v1.PodTemplateSpec, collisionCount *int32) string

ComputeHash returns a hash value calculated from pod template and a collisionCount to avoid hash collision. The hash will be safe encoded to avoid bad words.

func FilterActivePods Uses

func FilterActivePods(pods []*v1.Pod) []*v1.Pod

FilterActivePods returns pods that have not terminated.

func FilterActiveReplicaSets Uses

func FilterActiveReplicaSets(replicaSets []*apps.ReplicaSet) []*apps.ReplicaSet

FilterActiveReplicaSets returns replica sets that have (or at least ought to have) pods.

func FilterReplicaSets Uses

func FilterReplicaSets(RSes []*apps.ReplicaSet, filterFn filterRS) []*apps.ReplicaSet

FilterReplicaSets returns replica sets that are filtered by filterFn (all returned ones should match filterFn).

func GetPodFromTemplate Uses

func GetPodFromTemplate(template *v1.PodTemplateSpec, parentObject runtime.Object, controllerRef *metav1.OwnerReference) (*v1.Pod, error)

func IsPodActive Uses

func IsPodActive(p *v1.Pod) bool

func NoResyncPeriodFunc Uses

func NoResyncPeriodFunc() time.Duration

Returns 0 for resyncPeriod in case resyncing is not needed.

func PatchNodeTaints Uses

func PatchNodeTaints(c clientset.Interface, nodeName string, oldNode *v1.Node, newNode *v1.Node) error

PatchNodeTaints patches node's taints.

func PodKey Uses

func PodKey(pod *v1.Pod) string

PodKey returns a key unique to the given pod within a cluster. It's used so we consistently use the same key scheme in this module. It does exactly what cache.MetaNamespaceKeyFunc would have done except there's not possibility for error since we know the exact type.

func RecheckDeletionTimestamp Uses

func RecheckDeletionTimestamp(getObject func() (metav1.Object, error)) func() error

RecheckDeletionTimestamp returns a CanAdopt() function to recheck deletion.

The CanAdopt() function calls getObject() to fetch the latest value, and denies adoption attempts if that object has a non-nil DeletionTimestamp.

func RemoveTaintOffNode Uses

func RemoveTaintOffNode(c clientset.Interface, nodeName string, node *v1.Node, taints ...*v1.Taint) error

RemoveTaintOffNode is for cleaning up taints temporarily added to node, won't fail if target taint doesn't exist or has been removed. If passed a node it'll check if there's anything to be done, if taint is not present it won't issue any API calls.

func WaitForCacheSync Uses

func WaitForCacheSync(controllerName string, stopCh <-chan struct{}, cacheSyncs ...cache.InformerSynced) bool

WaitForCacheSync is a wrapper around cache.WaitForCacheSync that generates log messages indicating that the controller identified by controllerName is waiting for syncs, followed by either a successful or failed sync.

type ActivePods Uses

type ActivePods []*v1.Pod

ActivePods type allows custom sorting of pods so a controller can pick the best ones to delete.

func (ActivePods) Len Uses

func (s ActivePods) Len() int

func (ActivePods) Less Uses

func (s ActivePods) Less(i, j int) bool

func (ActivePods) Swap Uses

func (s ActivePods) Swap(i, j int)

type BaseControllerRefManager Uses

type BaseControllerRefManager struct {
    Controller metav1.Object
    Selector   labels.Selector

    CanAdoptFunc func() error
    // contains filtered or unexported fields
}

func (*BaseControllerRefManager) CanAdopt Uses

func (m *BaseControllerRefManager) CanAdopt() error

func (*BaseControllerRefManager) ClaimObject Uses

func (m *BaseControllerRefManager) ClaimObject(obj metav1.Object, match func(metav1.Object) bool, adopt, release func(metav1.Object) error) (bool, error)

ClaimObject tries to take ownership of an object for this controller.

It will reconcile the following:

* Adopt orphans if the match function returns true.
* Release owned objects if the match function returns false.

A non-nil error is returned if some form of reconciliation was attempted and failed. Usually, controllers should try again later in case reconciliation is still needed.

If the error is nil, either the reconciliation succeeded, or no reconciliation was necessary. The returned boolean indicates whether you now own the object.

No reconciliation will be attempted if the controller is being deleted.

type ByLogging Uses

type ByLogging []*v1.Pod

ByLogging allows custom sorting of pods so the best one can be picked for getting its logs.

func (ByLogging) Len Uses

func (s ByLogging) Len() int

func (ByLogging) Less Uses

func (s ByLogging) Less(i, j int) bool

func (ByLogging) Swap Uses

func (s ByLogging) Swap(i, j int)

type ControlleeExpectations Uses

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

ControlleeExpectations track controllee creates/deletes.

func (*ControlleeExpectations) Add Uses

func (e *ControlleeExpectations) Add(add, del int64)

Add increments the add and del counters.

func (*ControlleeExpectations) Fulfilled Uses

func (e *ControlleeExpectations) Fulfilled() bool

Fulfilled returns true if this expectation has been fulfilled.

func (*ControlleeExpectations) GetExpectations Uses

func (e *ControlleeExpectations) GetExpectations() (int64, int64)

GetExpectations returns the add and del expectations of the controllee.

type ControllerClientBuilder Uses

type ControllerClientBuilder interface {
    Config(name string) (*restclient.Config, error)
    ConfigOrDie(name string) *restclient.Config
    Client(name string) (clientset.Interface, error)
    ClientOrDie(name string) clientset.Interface
}

ControllerClientBuilder allows you to get clients and configs for controllers Please note a copy also exists in staging/src/k8s.io/cloud-provider/cloud.go TODO: Extract this into a separate controller utilities repo (issues/68947)

func NewDynamicClientBuilder Uses

func NewDynamicClientBuilder(clientConfig *restclient.Config, coreClient v1core.CoreV1Interface, ns string) ControllerClientBuilder

func NewTestDynamicClientBuilder Uses

func NewTestDynamicClientBuilder(clientConfig *restclient.Config, coreClient v1core.CoreV1Interface, ns string, expirationSeconds int64, leewayPercent int) ControllerClientBuilder

this function only for test purpose, don't call it

type ControllerExpectations Uses

type ControllerExpectations struct {
    cache.Store
}

ControllerExpectations is a cache mapping controllers to what they expect to see before being woken up for a sync.

func NewControllerExpectations Uses

func NewControllerExpectations() *ControllerExpectations

NewControllerExpectations returns a store for ControllerExpectations.

func (*ControllerExpectations) CreationObserved Uses

func (r *ControllerExpectations) CreationObserved(controllerKey string)

CreationObserved atomically decrements the `add` expectation count of the given controller.

func (*ControllerExpectations) DeleteExpectations Uses

func (r *ControllerExpectations) DeleteExpectations(controllerKey string)

DeleteExpectations deletes the expectations of the given controller from the TTLStore.

func (*ControllerExpectations) DeletionObserved Uses

func (r *ControllerExpectations) DeletionObserved(controllerKey string)

DeletionObserved atomically decrements the `del` expectation count of the given controller.

func (*ControllerExpectations) ExpectCreations Uses

func (r *ControllerExpectations) ExpectCreations(controllerKey string, adds int) error

func (*ControllerExpectations) ExpectDeletions Uses

func (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int) error

func (*ControllerExpectations) GetExpectations Uses

func (r *ControllerExpectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)

GetExpectations returns the ControlleeExpectations of the given controller.

func (*ControllerExpectations) LowerExpectations Uses

func (r *ControllerExpectations) LowerExpectations(controllerKey string, add, del int)

Decrements the expectation counts of the given controller.

func (*ControllerExpectations) RaiseExpectations Uses

func (r *ControllerExpectations) RaiseExpectations(controllerKey string, add, del int)

Increments the expectation counts of the given controller.

func (*ControllerExpectations) SatisfiedExpectations Uses

func (r *ControllerExpectations) SatisfiedExpectations(controllerKey string) bool

SatisfiedExpectations returns true if the required adds/dels for the given controller have been observed. Add/del counts are established by the controller at sync time, and updated as controllees are observed by the controller manager.

func (*ControllerExpectations) SetExpectations Uses

func (r *ControllerExpectations) SetExpectations(controllerKey string, add, del int) error

SetExpectations registers new expectations for the given controller. Forgets existing expectations.

type ControllerExpectationsInterface Uses

type ControllerExpectationsInterface interface {
    GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
    SatisfiedExpectations(controllerKey string) bool
    DeleteExpectations(controllerKey string)
    SetExpectations(controllerKey string, add, del int) error
    ExpectCreations(controllerKey string, adds int) error
    ExpectDeletions(controllerKey string, dels int) error
    CreationObserved(controllerKey string)
    DeletionObserved(controllerKey string)
    RaiseExpectations(controllerKey string, add, del int)
    LowerExpectations(controllerKey string, add, del int)
}

ControllerExpectationsInterface is an interface that allows users to set and wait on expectations. Only abstracted out for testing. Warning: if using KeyFunc it is not safe to use a single ControllerExpectationsInterface with different types of controllers, because the keys might conflict across types.

type ControllerRevisionControlInterface Uses

type ControllerRevisionControlInterface interface {
    PatchControllerRevision(namespace, name string, data []byte) error
}

TODO: merge the controller revision interface in controller_history.go with this one ControllerRevisionControlInterface is an interface that knows how to patch ControllerRevisions, as well as increment or decrement them. It is used by the daemonset controller to ease testing of actions that it takes.

type ControllerRevisionControllerRefManager Uses

type ControllerRevisionControllerRefManager struct {
    BaseControllerRefManager
    // contains filtered or unexported fields
}

ControllerRevisionControllerRefManager is used to manage controllerRef of ControllerRevisions. Three methods are defined on this object 1: Classify 2: AdoptControllerRevision and 3: ReleaseControllerRevision which are used to classify the ControllerRevisions into appropriate categories and accordingly adopt or release them. See comments on these functions for more details.

func NewControllerRevisionControllerRefManager Uses

func NewControllerRevisionControllerRefManager(
    crControl ControllerRevisionControlInterface,
    controller metav1.Object,
    selector labels.Selector,
    controllerKind schema.GroupVersionKind,
    canAdopt func() error,
) *ControllerRevisionControllerRefManager

NewControllerRevisionControllerRefManager returns a ControllerRevisionControllerRefManager that exposes methods to manage the controllerRef of ControllerRevisions.

The canAdopt() function can be used to perform a potentially expensive check (such as a live GET from the API server) prior to the first adoption. It will only be called (at most once) if an adoption is actually attempted. If canAdopt() returns a non-nil error, all adoptions will fail.

NOTE: Once canAdopt() is called, it will not be called again by the same

ControllerRevisionControllerRefManager instance. Create a new instance if it
makes sense to check canAdopt() again (e.g. in a different sync pass).

func (*ControllerRevisionControllerRefManager) AdoptControllerRevision Uses

func (m *ControllerRevisionControllerRefManager) AdoptControllerRevision(history *apps.ControllerRevision) error

AdoptControllerRevision sends a patch to take control of the ControllerRevision. It returns the error if the patching fails.

func (*ControllerRevisionControllerRefManager) ClaimControllerRevisions Uses

func (m *ControllerRevisionControllerRefManager) ClaimControllerRevisions(histories []*apps.ControllerRevision) ([]*apps.ControllerRevision, error)

ClaimControllerRevisions tries to take ownership of a list of ControllerRevisions.

It will reconcile the following:

* Adopt orphans if the selector matches.
* Release owned objects if the selector no longer matches.

A non-nil error is returned if some form of reconciliation was attempted and failed. Usually, controllers should try again later in case reconciliation is still needed.

If the error is nil, either the reconciliation succeeded, or no reconciliation was necessary. The list of ControllerRevisions that you now own is returned.

func (*ControllerRevisionControllerRefManager) ReleaseControllerRevision Uses

func (m *ControllerRevisionControllerRefManager) ReleaseControllerRevision(history *apps.ControllerRevision) error

ReleaseControllerRevision sends a patch to free the ControllerRevision from the control of its controller. It returns the error if the patching fails. 404 and 422 errors are ignored.

type ControllersByCreationTimestamp Uses

type ControllersByCreationTimestamp []*v1.ReplicationController

ControllersByCreationTimestamp sorts a list of ReplicationControllers by creation timestamp, using their names as a tie breaker.

func (ControllersByCreationTimestamp) Len Uses

func (o ControllersByCreationTimestamp) Len() int

func (ControllersByCreationTimestamp) Less Uses

func (o ControllersByCreationTimestamp) Less(i, j int) bool

func (ControllersByCreationTimestamp) Swap Uses

func (o ControllersByCreationTimestamp) Swap(i, j int)

type DynamicControllerClientBuilder Uses

type DynamicControllerClientBuilder struct {
    // ClientConfig is a skeleton config to clone and use as the basis for each controller client
    ClientConfig *restclient.Config

    // CoreClient is used to provision service accounts if needed and watch for their associated tokens
    // to construct a controller client
    CoreClient v1core.CoreV1Interface

    // Namespace is the namespace used to host the service accounts that will back the
    // controllers.  It must be highly privileged namespace which normal users cannot inspect.
    Namespace string
    // contains filtered or unexported fields
}

func (*DynamicControllerClientBuilder) Client Uses

func (t *DynamicControllerClientBuilder) Client(name string) (clientset.Interface, error)

func (*DynamicControllerClientBuilder) ClientOrDie Uses

func (t *DynamicControllerClientBuilder) ClientOrDie(name string) clientset.Interface

func (*DynamicControllerClientBuilder) Config Uses

func (t *DynamicControllerClientBuilder) Config(saName string) (*restclient.Config, error)

func (*DynamicControllerClientBuilder) ConfigOrDie Uses

func (t *DynamicControllerClientBuilder) ConfigOrDie(name string) *restclient.Config

type Expectations Uses

type Expectations interface {
    Fulfilled() bool
}

Expectations are either fulfilled, or expire naturally.

type FakePodControl Uses

type FakePodControl struct {
    sync.Mutex
    Templates       []v1.PodTemplateSpec
    ControllerRefs  []metav1.OwnerReference
    DeletePodName   []string
    Patches         [][]byte
    Err             error
    CreateLimit     int
    CreateCallCount int
}

func (*FakePodControl) Clear Uses

func (f *FakePodControl) Clear()

func (*FakePodControl) CreatePods Uses

func (f *FakePodControl) CreatePods(namespace string, spec *v1.PodTemplateSpec, object runtime.Object) error

func (*FakePodControl) CreatePodsOnNode Uses

func (f *FakePodControl) CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error

func (*FakePodControl) CreatePodsWithControllerRef Uses

func (f *FakePodControl) CreatePodsWithControllerRef(namespace string, spec *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error

func (*FakePodControl) DeletePod Uses

func (f *FakePodControl) DeletePod(namespace string, podID string, object runtime.Object) error

func (*FakePodControl) PatchPod Uses

func (f *FakePodControl) PatchPod(namespace, name string, data []byte) error

type InformerFactory Uses

type InformerFactory interface {
    ForResource(resource schema.GroupVersionResource) (informers.GenericInformer, error)
    Start(stopCh <-chan struct{})
}

InformerFactory creates informers for each group version resource.

func NewInformerFactory Uses

func NewInformerFactory(typedInformerFactory informers.SharedInformerFactory, dynamicInformerFactory dynamicinformer.DynamicSharedInformerFactory) InformerFactory

NewInformerFactory creates a new InformerFactory which works with both typed resources and dynamic resources

type MatchingCache Uses

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

MatchingCache save label and selector matching relationship

func NewMatchingCache Uses

func NewMatchingCache(maxCacheEntries int) *MatchingCache

NewMatchingCache return a NewMatchingCache, which save label and selector matching relationship.

func (*MatchingCache) Add Uses

func (c *MatchingCache) Add(labelObj objectWithMeta, selectorObj objectWithMeta)

Add will add matching information to the cache.

func (*MatchingCache) GetMatchingObject Uses

func (c *MatchingCache) GetMatchingObject(labelObj objectWithMeta) (controller interface{}, exists bool)

GetMatchingObject lookup the matching object for a given object. Note: the cache information may be invalid since the controller may be deleted or updated, we need check in the external request to ensure the cache data is not dirty.

func (*MatchingCache) InvalidateAll Uses

func (c *MatchingCache) InvalidateAll()

InvalidateAll invalidate the whole cache.

func (*MatchingCache) Update Uses

func (c *MatchingCache) Update(labelObj objectWithMeta, selectorObj objectWithMeta)

Update update the cached matching information.

type PodControlInterface Uses

type PodControlInterface interface {
    // CreatePods creates new pods according to the spec.
    CreatePods(namespace string, template *v1.PodTemplateSpec, object runtime.Object) error
    // CreatePodsOnNode creates a new pod according to the spec on the specified node,
    // and sets the ControllerRef.
    CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error
    // CreatePodsWithControllerRef creates new pods according to the spec, and sets object as the pod's controller.
    CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error
    // DeletePod deletes the pod identified by podID.
    DeletePod(namespace string, podID string, object runtime.Object) error
    // PatchPod patches the pod.
    PatchPod(namespace, name string, data []byte) error
}

PodControlInterface is an interface that knows how to add or delete pods created as an interface to allow testing.

type PodControllerRefManager Uses

type PodControllerRefManager struct {
    BaseControllerRefManager
    // contains filtered or unexported fields
}

func NewPodControllerRefManager Uses

func NewPodControllerRefManager(
    podControl PodControlInterface,
    controller metav1.Object,
    selector labels.Selector,
    controllerKind schema.GroupVersionKind,
    canAdopt func() error,
) *PodControllerRefManager

NewPodControllerRefManager returns a PodControllerRefManager that exposes methods to manage the controllerRef of pods.

The CanAdopt() function can be used to perform a potentially expensive check (such as a live GET from the API server) prior to the first adoption. It will only be called (at most once) if an adoption is actually attempted. If CanAdopt() returns a non-nil error, all adoptions will fail.

NOTE: Once CanAdopt() is called, it will not be called again by the same

PodControllerRefManager instance. Create a new instance if it makes
sense to check CanAdopt() again (e.g. in a different sync pass).

func (*PodControllerRefManager) AdoptPod Uses

func (m *PodControllerRefManager) AdoptPod(pod *v1.Pod) error

AdoptPod sends a patch to take control of the pod. It returns the error if the patching fails.

func (*PodControllerRefManager) ClaimPods Uses

func (m *PodControllerRefManager) ClaimPods(pods []*v1.Pod, filters ...func(*v1.Pod) bool) ([]*v1.Pod, error)

ClaimPods tries to take ownership of a list of Pods.

It will reconcile the following:

* Adopt orphans if the selector matches.
* Release owned objects if the selector no longer matches.

Optional: If one or more filters are specified, a Pod will only be claimed if all filters return true.

A non-nil error is returned if some form of reconciliation was attempted and failed. Usually, controllers should try again later in case reconciliation is still needed.

If the error is nil, either the reconciliation succeeded, or no reconciliation was necessary. The list of Pods that you now own is returned.

func (*PodControllerRefManager) ReleasePod Uses

func (m *PodControllerRefManager) ReleasePod(pod *v1.Pod) error

ReleasePod sends a patch to free the pod from the control of the controller. It returns the error if the patching fails. 404 and 422 errors are ignored.

type RSControlInterface Uses

type RSControlInterface interface {
    PatchReplicaSet(namespace, name string, data []byte) error
}

RSControlInterface is an interface that knows how to add or delete ReplicaSets, as well as increment or decrement them. It is used by the deployment controller to ease testing of actions that it takes.

type RealControllerRevisionControl Uses

type RealControllerRevisionControl struct {
    KubeClient clientset.Interface
}

RealControllerRevisionControl is the default implementation of ControllerRevisionControlInterface.

func (RealControllerRevisionControl) PatchControllerRevision Uses

func (r RealControllerRevisionControl) PatchControllerRevision(namespace, name string, data []byte) error

type RealPodControl Uses

type RealPodControl struct {
    KubeClient clientset.Interface
    Recorder   record.EventRecorder
}

RealPodControl is the default implementation of PodControlInterface.

func (RealPodControl) CreatePods Uses

func (r RealPodControl) CreatePods(namespace string, template *v1.PodTemplateSpec, object runtime.Object) error

func (RealPodControl) CreatePodsOnNode Uses

func (r RealPodControl) CreatePodsOnNode(nodeName, namespace string, template *v1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error

func (RealPodControl) CreatePodsWithControllerRef Uses

func (r RealPodControl) CreatePodsWithControllerRef(namespace string, template *v1.PodTemplateSpec, controllerObject runtime.Object, controllerRef *metav1.OwnerReference) error

func (RealPodControl) DeletePod Uses

func (r RealPodControl) DeletePod(namespace string, podID string, object runtime.Object) error

func (RealPodControl) PatchPod Uses

func (r RealPodControl) PatchPod(namespace, name string, data []byte) error

type RealRSControl Uses

type RealRSControl struct {
    KubeClient clientset.Interface
    Recorder   record.EventRecorder
}

RealRSControl is the default implementation of RSControllerInterface.

func (RealRSControl) PatchReplicaSet Uses

func (r RealRSControl) PatchReplicaSet(namespace, name string, data []byte) error

type ReplicaSetControllerRefManager Uses

type ReplicaSetControllerRefManager struct {
    BaseControllerRefManager
    // contains filtered or unexported fields
}

ReplicaSetControllerRefManager is used to manage controllerRef of ReplicaSets. Three methods are defined on this object 1: Classify 2: AdoptReplicaSet and 3: ReleaseReplicaSet which are used to classify the ReplicaSets into appropriate categories and accordingly adopt or release them. See comments on these functions for more details.

func NewReplicaSetControllerRefManager Uses

func NewReplicaSetControllerRefManager(
    rsControl RSControlInterface,
    controller metav1.Object,
    selector labels.Selector,
    controllerKind schema.GroupVersionKind,
    canAdopt func() error,
) *ReplicaSetControllerRefManager

NewReplicaSetControllerRefManager returns a ReplicaSetControllerRefManager that exposes methods to manage the controllerRef of ReplicaSets.

The CanAdopt() function can be used to perform a potentially expensive check (such as a live GET from the API server) prior to the first adoption. It will only be called (at most once) if an adoption is actually attempted. If CanAdopt() returns a non-nil error, all adoptions will fail.

NOTE: Once CanAdopt() is called, it will not be called again by the same

ReplicaSetControllerRefManager instance. Create a new instance if it
makes sense to check CanAdopt() again (e.g. in a different sync pass).

func (*ReplicaSetControllerRefManager) AdoptReplicaSet Uses

func (m *ReplicaSetControllerRefManager) AdoptReplicaSet(rs *apps.ReplicaSet) error

AdoptReplicaSet sends a patch to take control of the ReplicaSet. It returns the error if the patching fails.

func (*ReplicaSetControllerRefManager) ClaimReplicaSets Uses

func (m *ReplicaSetControllerRefManager) ClaimReplicaSets(sets []*apps.ReplicaSet) ([]*apps.ReplicaSet, error)

ClaimReplicaSets tries to take ownership of a list of ReplicaSets.

It will reconcile the following:

* Adopt orphans if the selector matches.
* Release owned objects if the selector no longer matches.

A non-nil error is returned if some form of reconciliation was attempted and failed. Usually, controllers should try again later in case reconciliation is still needed.

If the error is nil, either the reconciliation succeeded, or no reconciliation was necessary. The list of ReplicaSets that you now own is returned.

func (*ReplicaSetControllerRefManager) ReleaseReplicaSet Uses

func (m *ReplicaSetControllerRefManager) ReleaseReplicaSet(replicaSet *apps.ReplicaSet) error

ReleaseReplicaSet sends a patch to free the ReplicaSet from the control of the Deployment controller. It returns the error if the patching fails. 404 and 422 errors are ignored.

type ReplicaSetsByCreationTimestamp Uses

type ReplicaSetsByCreationTimestamp []*apps.ReplicaSet

ReplicaSetsByCreationTimestamp sorts a list of ReplicaSet by creation timestamp, using their names as a tie breaker.

func (ReplicaSetsByCreationTimestamp) Len Uses

func (o ReplicaSetsByCreationTimestamp) Len() int

func (ReplicaSetsByCreationTimestamp) Less Uses

func (o ReplicaSetsByCreationTimestamp) Less(i, j int) bool

func (ReplicaSetsByCreationTimestamp) Swap Uses

func (o ReplicaSetsByCreationTimestamp) Swap(i, j int)

type ReplicaSetsBySizeNewer Uses

type ReplicaSetsBySizeNewer []*apps.ReplicaSet

ReplicaSetsBySizeNewer sorts a list of ReplicaSet by size in descending order, using their creation timestamp or name as a tie breaker. By using the creation timestamp, this sorts from new to old replica sets.

func (ReplicaSetsBySizeNewer) Len Uses

func (o ReplicaSetsBySizeNewer) Len() int

func (ReplicaSetsBySizeNewer) Less Uses

func (o ReplicaSetsBySizeNewer) Less(i, j int) bool

func (ReplicaSetsBySizeNewer) Swap Uses

func (o ReplicaSetsBySizeNewer) Swap(i, j int)

type ReplicaSetsBySizeOlder Uses

type ReplicaSetsBySizeOlder []*apps.ReplicaSet

ReplicaSetsBySizeOlder sorts a list of ReplicaSet by size in descending order, using their creation timestamp or name as a tie breaker. By using the creation timestamp, this sorts from old to new replica sets.

func (ReplicaSetsBySizeOlder) Len Uses

func (o ReplicaSetsBySizeOlder) Len() int

func (ReplicaSetsBySizeOlder) Less Uses

func (o ReplicaSetsBySizeOlder) Less(i, j int) bool

func (ReplicaSetsBySizeOlder) Swap Uses

func (o ReplicaSetsBySizeOlder) Swap(i, j int)

type ResyncPeriodFunc Uses

type ResyncPeriodFunc func() time.Duration

func StaticResyncPeriodFunc Uses

func StaticResyncPeriodFunc(resyncPeriod time.Duration) ResyncPeriodFunc

StaticResyncPeriodFunc returns the resync period specified

type SAControllerClientBuilder Uses

type SAControllerClientBuilder struct {
    // ClientConfig is a skeleton config to clone and use as the basis for each controller client
    ClientConfig *restclient.Config

    // CoreClient is used to provision service accounts if needed and watch for their associated tokens
    // to construct a controller client
    CoreClient v1core.CoreV1Interface

    // AuthenticationClient is used to check API tokens to make sure they are valid before
    // building a controller client from them
    AuthenticationClient v1authentication.AuthenticationV1Interface

    // Namespace is the namespace used to host the service accounts that will back the
    // controllers.  It must be highly privileged namespace which normal users cannot inspect.
    Namespace string
}

SAControllerClientBuilder is a ControllerClientBuilder that returns clients identifying as service accounts

func (SAControllerClientBuilder) Client Uses

func (b SAControllerClientBuilder) Client(name string) (clientset.Interface, error)

func (SAControllerClientBuilder) ClientOrDie Uses

func (b SAControllerClientBuilder) ClientOrDie(name string) clientset.Interface

func (SAControllerClientBuilder) Config Uses

func (b SAControllerClientBuilder) Config(name string) (*restclient.Config, error)

config returns a complete clientConfig for constructing clients. This is separate in anticipation of composition which means that not all clientsets are known here

func (SAControllerClientBuilder) ConfigOrDie Uses

func (b SAControllerClientBuilder) ConfigOrDie(name string) *restclient.Config

type SimpleControllerClientBuilder Uses

type SimpleControllerClientBuilder struct {
    // ClientConfig is a skeleton config to clone and use as the basis for each controller client
    ClientConfig *restclient.Config
}

SimpleControllerClientBuilder returns a fixed client with different user agents

func (SimpleControllerClientBuilder) Client Uses

func (b SimpleControllerClientBuilder) Client(name string) (clientset.Interface, error)

func (SimpleControllerClientBuilder) ClientOrDie Uses

func (b SimpleControllerClientBuilder) ClientOrDie(name string) clientset.Interface

func (SimpleControllerClientBuilder) Config Uses

func (b SimpleControllerClientBuilder) Config(name string) (*restclient.Config, error)

func (SimpleControllerClientBuilder) ConfigOrDie Uses

func (b SimpleControllerClientBuilder) ConfigOrDie(name string) *restclient.Config

type UIDSet Uses

type UIDSet struct {
    sets.String
    // contains filtered or unexported fields
}

UIDSet holds a key and a set of UIDs. Used by the UIDTrackingControllerExpectations to remember which UID it has seen/still waiting for.

type UIDTrackingControllerExpectations Uses

type UIDTrackingControllerExpectations struct {
    ControllerExpectationsInterface
    // contains filtered or unexported fields
}

UIDTrackingControllerExpectations tracks the UID of the pods it deletes. This cache is needed over plain old expectations to safely handle graceful deletion. The desired behavior is to treat an update that sets the DeletionTimestamp on an object as a delete. To do so consistently, one needs to remember the expected deletes so they aren't double counted. TODO: Track creates as well (#22599)

func NewUIDTrackingControllerExpectations Uses

func NewUIDTrackingControllerExpectations(ce ControllerExpectationsInterface) *UIDTrackingControllerExpectations

NewUIDTrackingControllerExpectations returns a wrapper around ControllerExpectations that is aware of deleteKeys.

func (*UIDTrackingControllerExpectations) DeleteExpectations Uses

func (u *UIDTrackingControllerExpectations) DeleteExpectations(rcKey string)

DeleteExpectations deletes the UID set and invokes DeleteExpectations on the underlying ControllerExpectationsInterface.

func (*UIDTrackingControllerExpectations) DeletionObserved Uses

func (u *UIDTrackingControllerExpectations) DeletionObserved(rcKey, deleteKey string)

DeletionObserved records the given deleteKey as a deletion, for the given rc.

func (*UIDTrackingControllerExpectations) ExpectDeletions Uses

func (u *UIDTrackingControllerExpectations) ExpectDeletions(rcKey string, deletedKeys []string) error

ExpectDeletions records expectations for the given deleteKeys, against the given controller.

func (*UIDTrackingControllerExpectations) GetUIDs Uses

func (u *UIDTrackingControllerExpectations) GetUIDs(controllerKey string) sets.String

GetUIDs is a convenience method to avoid exposing the set of expected uids. The returned set is not thread safe, all modifications must be made holding the uidStoreLock.

Directories

PathSynopsis
apis/config
apis/config/fuzzer
apis/config/scheme
apis/config/v1alpha1
bootstrapPackage bootstrap provides automatic processes necessary for bootstraping.
certificatesPackage certificates implements an abstract controller that is useful for building controllers that manage CSRs
certificates/approverPackage approver implements an automated approver for kubelet certificates.
certificates/cleanerPackage cleaner implements an automated cleaner that does garbage collection on CSRs that meet specific criteria.
certificates/rootcacertpublisher
certificates/signerPackage signer implements a CA signer that uses keys stored on local disk.
certificates/signer/config
certificates/signer/config/v1alpha1
cloud
clusterroleaggregation
cronjobPackage cronjob contains the controller for CronJob objects.
daemonPackage daemon contains logic for watching and synchronizing daemons.
daemon/config
daemon/config/v1alpha1
daemon/util
deploymentPackage deployment contains all the logic for handling Kubernetes Deployments.
deployment/config
deployment/config/v1alpha1
deployment/util
disruption
endpointPackage endpoint provides EndpointController implementation to manage and sync service endpoints.
endpoint/config
endpoint/config/v1alpha1
garbagecollector
garbagecollector/config
garbagecollector/config/v1alpha1
garbagecollector/metaonly
history
jobPackage job contains logic for watching and synchronizing jobs.
job/config
job/config/v1alpha1
namespacePackage namespace contains a controller that handles namespace lifecycle
namespace/config
namespace/config/v1alpha1
namespace/deletion
nodeipamPackage nodeipam contains code for syncing cloud instances with node registry
nodeipam/config
nodeipam/config/v1alpha1
nodeipam/ipamPackage ipam provides different allocators for assigning IP ranges to nodes.
nodeipam/ipam/cidrset
nodeipam/ipam/sync
nodeipam/ipam/test
nodelifecycle
nodelifecycle/config
nodelifecycle/config/v1alpha1
nodelifecycle/scheduler
podautoscalerPackage podautoscaler contains logic for autoscaling number of pods based on metrics observed.
podautoscaler/config
podautoscaler/config/v1alpha1
podautoscaler/metrics
podgcPackage podgc contains a very simple pod "garbage collector" implementation, PodGCController, that runs in the controller manager.
podgc/config
podgc/config/v1alpha1
replicasetPackage replicaset contains logic for watching and synchronizing ReplicaSets.
replicaset/config
replicaset/config/v1alpha1
replicationPackage replication contains logic for watching and synchronizing replication controllers.
replication/config
replication/config/v1alpha1
resourcequotaresourcequota contains a controller that makes resource quota usage observations
resourcequota/config
resourcequota/config/v1alpha1
routePackage route contains code for syncing cloud routing rules with the list of registered nodes.
servicePackage service contains code for syncing cloud load balancers with the service registry.
serviceaccountPackage serviceaccount provides implementations to manage service accounts and service account tokens
serviceaccount/config
serviceaccount/config/v1alpha1
service/config
service/config/v1alpha1
statefulset
testutil
ttl
ttlafterfinished
ttlafterfinished/config
ttlafterfinished/config/v1alpha1
util/node
volume/attachdetachPackage attachdetach implements a controller to manage volume attach and detach operations.
volume/attachdetach/cachePackage cache implements data structures used by the attach/detach controller to keep track of volumes, the nodes they are attached to, and the pods that reference them.
volume/attachdetach/config
volume/attachdetach/config/v1alpha1
volume/attachdetach/metrics
volume/attachdetach/populatorPackage populator implements interfaces that monitor and keep the states of the desired_state_of_word in sync with the "ground truth" from informer.
volume/attachdetach/reconcilerPackage reconciler implements interfaces that attempt to reconcile the desired state of the with the actual state of the world by triggering actions.
volume/attachdetach/statusupdaterPackage statusupdater implements interfaces that enable updating the status of API objects.
volume/attachdetach/testing
volume/attachdetach/util
volume/events
volume/expand
volume/expand/cache
volume/persistentvolume
volume/persistentvolume/config
volume/persistentvolume/config/v1alpha1
volume/persistentvolume/metrics
volume/persistentvolume/options
volume/persistentvolume/testing
volume/persistentvolume/util
volume/protectionutil
volume/pvcprotection
volume/pvprotection
volume/scheduling

Package controller imports 53 packages (graph) and is imported by 2003 packages. Updated 2019-06-25. Refresh now. Tools for package owners.