Documentation
¶
Overview ¶
Package controller contains code for controllers (like the replication controller).
Index ¶
- Constants
- Variables
- func FilterActivePods(pods []api.Pod) []*api.Pod
- type ActivePods
- type ControllerExpectations
- func (r *ControllerExpectations) CreationObserved(controllerKey string)
- func (r *ControllerExpectations) DeleteExpectations(controllerKey string)
- func (r *ControllerExpectations) DeletionObserved(controllerKey string)
- func (r *ControllerExpectations) ExpectCreations(controllerKey string, adds int) error
- func (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int) error
- func (r *ControllerExpectations) GetExpectations(controllerKey string) (*PodExpectations, bool, error)
- func (r *ControllerExpectations) SatisfiedExpectations(controllerKey string) bool
- func (r *ControllerExpectations) SetExpectations(controllerKey string, add, del int) error
- type ControllerExpectationsInterface
- type Expectations
- type PodControlInterface
- type PodExpectations
- type RealPodControl
Constants ¶
const (
CreatedByAnnotation = "kubernetes.io/created-by"
// 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 an controller can service (create *and* observe the watch events for said
// creation) about 10-20 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 = 3 * time.Minute
)
Variables ¶
var ExpKeyFunc = func(obj interface{}) (string, error) {
if e, ok := obj.(*PodExpectations); ok {
return e.key, nil
}
return "", fmt.Errorf("Could not find key for obj %#v", obj)
}
ExpKeyFunc to parse out the key from a PodExpectation
var (
KeyFunc = framework.DeletionHandlingMetaNamespaceKeyFunc
)
Functions ¶
func FilterActivePods ¶ added in v0.7.0
func FilterActivePods(pods []api.Pod) []*api.Pod
FilterActivePods returns pods that have not terminated.
Types ¶
type ActivePods ¶ added in v1.1.0
type ActivePods []*api.Pod
ActivePods type allows custom sorting of pods so a controller can pick the best ones to delete.
type ControllerExpectations ¶ added in v1.1.0
type ControllerExpectations struct {
cache.Store
}
ControllerExpectations is a ttl cache mapping controllers to what they expect to see before being woken up for a sync.
func NewControllerExpectations ¶ added in v1.1.0
func NewControllerExpectations() *ControllerExpectations
NewControllerExpectations returns a store for PodExpectations.
func (*ControllerExpectations) CreationObserved ¶ added in v1.1.0
func (r *ControllerExpectations) CreationObserved(controllerKey string)
CreationObserved atomically decrements the `add` expecation count of the given controller.
func (*ControllerExpectations) DeleteExpectations ¶ added in v1.1.0
func (r *ControllerExpectations) DeleteExpectations(controllerKey string)
DeleteExpectations deletes the expectations of the given controller from the TTLStore.
func (*ControllerExpectations) DeletionObserved ¶ added in v1.1.0
func (r *ControllerExpectations) DeletionObserved(controllerKey string)
DeletionObserved atomically decrements the `del` expectation count of the given controller.
func (*ControllerExpectations) ExpectCreations ¶ added in v1.1.0
func (r *ControllerExpectations) ExpectCreations(controllerKey string, adds int) error
func (*ControllerExpectations) ExpectDeletions ¶ added in v1.1.0
func (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int) error
func (*ControllerExpectations) GetExpectations ¶ added in v1.1.0
func (r *ControllerExpectations) GetExpectations(controllerKey string) (*PodExpectations, bool, error)
GetExpectations returns the PodExpectations of the given controller.
func (*ControllerExpectations) SatisfiedExpectations ¶ added in v1.1.0
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 pods are observed by the controller manager.
func (*ControllerExpectations) SetExpectations ¶ added in v1.1.0
func (r *ControllerExpectations) SetExpectations(controllerKey string, add, del int) error
SetExpectations registers new expectations for the given controller. Forgets existing expectations.
type ControllerExpectationsInterface ¶ added in v1.1.0
type ControllerExpectationsInterface interface {
GetExpectations(controllerKey string) (*PodExpectations, 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)
}
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 Expectations ¶ added in v0.17.0
type Expectations interface {
Fulfilled() bool
}
Expectations are either fulfilled, or expire naturally.
type PodControlInterface ¶
type PodControlInterface interface {
// CreateReplica creates new replicated pods according to the spec.
CreateReplica(namespace string, controller *api.ReplicationController) error
// DeletePod deletes the pod identified by podID.
DeletePod(namespace string, podID string) error
}
PodControlInterface is an interface that knows how to add or delete pods created as an interface to allow testing.
type PodExpectations ¶ added in v0.17.0
type PodExpectations struct {
// contains filtered or unexported fields
}
PodExpectations track pod creates/deletes.
func (*PodExpectations) Fulfilled ¶ added in v0.17.0
func (e *PodExpectations) Fulfilled() bool
Fulfilled returns true if this expectation has been fulfilled.
func (*PodExpectations) GetExpectations ¶ added in v1.1.0
func (e *PodExpectations) GetExpectations() (int64, int64)
GetExpectations returns the add and del expectations of the pod.
type RealPodControl ¶
type RealPodControl struct {
KubeClient client.Interface
Recorder record.EventRecorder
}
RealPodControl is the default implementation of PodControllerInterface.
func (RealPodControl) CreateReplica ¶
func (r RealPodControl) CreateReplica(namespace string, controller *api.ReplicationController) error
Directories
¶
Path | Synopsis |
---|---|
Package service provides EndpointController implementation to manage and sync service endpoints.
|
Package service provides EndpointController implementation to manage and sync service endpoints. |
Package framework implements all the grunt work involved in running a simple controller.
|
Package framework implements all the grunt work involved in running a simple controller. |
namespace contains a controller that handles namespace lifecycle
|
namespace contains a controller that handles namespace lifecycle |
Package nodecontroller contains code for syncing cloud instances with minion registry
|
Package nodecontroller contains code for syncing cloud instances with minion registry |
Package replication contains logic for watching and synchronizing replication controllers.
|
Package replication contains logic for watching and synchronizing replication controllers. |
resourcequota contains a controller that makes resource quota usage observations
|
resourcequota contains a controller that makes resource quota usage observations |
Package routecontroller contains code for syncing cloud routing rules with the list of registered nodes.
|
Package routecontroller contains code for syncing cloud routing rules with the list of registered nodes. |
Package servicecontroller contains code for syncing cloud load balancers with the service registry.
|
Package servicecontroller contains code for syncing cloud load balancers with the service registry. |
Package serviceaccount provides implementations to manage service accounts and service account tokens
|
Package serviceaccount provides implementations to manage service accounts and service account tokens |