Documentation ¶
Index ¶
- Constants
- Variables
- func AddOrUpdateLabelsOnNode(kubeClient clientset.Interface, nodeName string, ...) error
- func AddOrUpdateTaintOnNode(ctx context.Context, c clientset.Interface, nodeName string, ...) error
- func CalculateForPodPlacement(pInfo *PodInfo) (v1.PodSpec, error)
- func ComputeHash(template *api.PodTemplateSpec, collisionCount *int32) string
- func CountTerminatingPods(pods []*v1.Pod) int32
- func FilterActivePods(logger klog.Logger, pods []*v1.Pod) []*v1.Pod
- func FilterActiveReplicaSets(replicaSets []*apps.ReplicaSet) []*apps.ReplicaSet
- func FilterReplicaSets(RSes []*apps.ReplicaSet, filterFn filterRS) []*apps.ReplicaSet
- func FilterTerminatingPods(pods []*v1.Pod) []*v1.Pod
- func GenerateDeleteOwnerRefStrategicMergeBytes(dependentUID types.UID, ownerUIDs []types.UID, finalizers ...string) ([]byte, error)
- func GetPodFromTemplate(pInfo PodInfo, parentObject runtime.Object, ...) (*v1.Pod, error)
- func IsPodActive(p *v1.Pod) bool
- func IsPodTerminating(p *v1.Pod) bool
- func NoResyncPeriodFunc() time.Duration
- func PatchNodeTaints(ctx context.Context, c clientset.Interface, nodeName string, oldNode *v1.Node, ...) error
- func PodKey(pod *v1.Pod) string
- func RecheckDeletionTimestamp(getObject func(context.Context) (metav1.Object, error)) func(context.Context) error
- func RemoveTaintOffNode(ctx context.Context, c clientset.Interface, nodeName string, node *v1.Node, ...) error
- func UpsertNodeSelectorRequirements(reqList []v1.NodeSelectorRequirement, req v1.NodeSelectorRequirement) []v1.NodeSelectorRequirement
- func UpsertPodAffinityTerm(lst []v1.PodAffinityTerm, term v1.PodAffinityTerm) []v1.PodAffinityTerm
- func UpsertTopologySpreadConstraint(lst []v1.TopologySpreadConstraint, tsc v1.TopologySpreadConstraint) []v1.TopologySpreadConstraint
- type ActivePods
- type ActivePodsWithRanks
- type BaseControllerRefManager
- type ByLogging
- type ControlleeExpectations
- type ControllerExpectations
- func (r *ControllerExpectations) CreationObserved(logger klog.Logger, controllerKey string)
- func (r *ControllerExpectations) DeleteExpectations(logger klog.Logger, controllerKey string)
- func (r *ControllerExpectations) DeletionObserved(logger klog.Logger, controllerKey string)
- func (r *ControllerExpectations) ExpectCreations(logger klog.Logger, controllerKey string, adds int) error
- func (r *ControllerExpectations) ExpectDeletions(logger klog.Logger, controllerKey string, dels int) error
- func (r *ControllerExpectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
- func (r *ControllerExpectations) LowerExpectations(logger klog.Logger, controllerKey string, add, del int)
- func (r *ControllerExpectations) RaiseExpectations(logger klog.Logger, controllerKey string, add, del int)
- func (r *ControllerExpectations) SatisfiedExpectations(logger klog.Logger, controllerKey string) bool
- func (r *ControllerExpectations) SetExpectations(logger klog.Logger, controllerKey string, add, del int) error
- type ControllerExpectationsInterface
- type ControllerRevisionControlInterface
- type ControllerRevisionControllerRefManager
- func (m *ControllerRevisionControllerRefManager) AdoptControllerRevision(ctx context.Context, history *apps.ControllerRevision) error
- func (m *ControllerRevisionControllerRefManager) ClaimControllerRevisions(ctx context.Context, histories []*apps.ControllerRevision) ([]*apps.ControllerRevision, error)
- func (m *ControllerRevisionControllerRefManager) ReleaseControllerRevision(ctx context.Context, history *apps.ControllerRevision) error
- type ControllersByCreationTimestamp
- type FakePodControl
- func (f *FakePodControl) Clear()
- func (f *FakePodControl) CreatePods(ctx context.Context, namespace string, pInfo PodInfo, object runtime.Object, ...) error
- func (f *FakePodControl) CreatePodsWithGenerateName(ctx context.Context, namespace string, pInfo PodInfo, object runtime.Object, ...) error
- func (f *FakePodControl) DeletePod(ctx context.Context, namespace string, podID string, object runtime.Object) error
- func (f *FakePodControl) PatchPod(ctx context.Context, namespace, name string, data []byte) error
- type OperatorConfig
- type PodControlInterface
- type PodControllerRefManager
- type PodInfo
- type RSControlInterface
- type RealControllerRevisionControl
- type RealPodControl
- func (r RealPodControl) CreatePods(ctx context.Context, namespace string, pInfo PodInfo, ...) error
- func (r RealPodControl) CreatePodsWithGenerateName(ctx context.Context, namespace string, pInfo PodInfo, ...) error
- func (r RealPodControl) DeletePod(ctx context.Context, namespace string, podID string, object runtime.Object) error
- func (r RealPodControl) PatchPod(ctx context.Context, namespace, name string, data []byte) error
- type RealRSControl
- type ReplicaSetControllerRefManager
- func (m *ReplicaSetControllerRefManager) AdoptReplicaSet(ctx context.Context, rs *apps.ReplicaSet) error
- func (m *ReplicaSetControllerRefManager) ClaimReplicaSets(ctx context.Context, sets []*apps.ReplicaSet) ([]*apps.ReplicaSet, error)
- func (m *ReplicaSetControllerRefManager) ReleaseReplicaSet(ctx context.Context, replicaSet *apps.ReplicaSet) error
- type ReplicaSetsByCreationTimestamp
- type ReplicaSetsBySizeNewer
- type ReplicaSetsBySizeOlder
- type ResyncPeriodFunc
- type UIDSet
- type UIDTrackingControllerExpectations
- func (u *UIDTrackingControllerExpectations) DeleteExpectations(logger klog.Logger, rcKey string)
- func (u *UIDTrackingControllerExpectations) DeletionObserved(logger klog.Logger, rcKey, deleteKey string)
- func (u *UIDTrackingControllerExpectations) ExpectDeletions(logger klog.Logger, rcKey string, deletedKeys []string) error
- func (u *UIDTrackingControllerExpectations) GetUIDs(controllerKey string) sets.Set[string]
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, }
var ValidatePodName = apimachineryvalidation.NameIsDNSSubdomain
ValidatePodName can be used to check whether the given pod name is valid. Prefix indicates this name will be used as part of generation, in which case trailing dashes are allowed.
Functions ¶
func AddOrUpdateLabelsOnNode ¶
func AddOrUpdateTaintOnNode ¶
func AddOrUpdateTaintOnNode(ctx context.Context, 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 CalculateForPodPlacement ¶ added in v0.0.2
func ComputeHash ¶
func ComputeHash(template *api.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 CountTerminatingPods ¶
func FilterActivePods ¶
FilterActivePods returns pods that have not terminated.
func FilterActiveReplicaSets ¶
func FilterActiveReplicaSets(replicaSets []*apps.ReplicaSet) []*apps.ReplicaSet
FilterActiveReplicaSets returns replica sets that have (or at least ought to have) pods.
func FilterReplicaSets ¶
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 ¶
func IsPodActive ¶
func IsPodTerminating ¶
func NoResyncPeriodFunc ¶
Returns 0 for resyncPeriod in case resyncing is not needed.
func PatchNodeTaints ¶
func PatchNodeTaints(ctx context.Context, c clientset.Interface, nodeName string, oldNode *v1.Node, newNode *v1.Node) error
PatchNodeTaints patches node's taints.
func PodKey ¶
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 ¶
func RecheckDeletionTimestamp(getObject func(context.Context) (metav1.Object, error)) func(context.Context) 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 ¶
func RemoveTaintOffNode(ctx context.Context, 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 UpsertNodeSelectorRequirements ¶ added in v0.0.2
func UpsertNodeSelectorRequirements(reqList []v1.NodeSelectorRequirement, req v1.NodeSelectorRequirement) []v1.NodeSelectorRequirement
func UpsertPodAffinityTerm ¶ added in v0.0.2
func UpsertPodAffinityTerm(lst []v1.PodAffinityTerm, term v1.PodAffinityTerm) []v1.PodAffinityTerm
func UpsertTopologySpreadConstraint ¶ added in v0.0.2
func UpsertTopologySpreadConstraint(lst []v1.TopologySpreadConstraint, tsc v1.TopologySpreadConstraint) []v1.TopologySpreadConstraint
Types ¶
type ActivePods ¶
ActivePods type allows custom sorting of pods so a controller can pick the best ones to delete.
func (ActivePods) Len ¶
func (s ActivePods) Len() int
func (ActivePods) Less ¶
func (s ActivePods) Less(i, j int) bool
func (ActivePods) Swap ¶
func (s ActivePods) Swap(i, j int)
type ActivePodsWithRanks ¶
type ActivePodsWithRanks struct { // Pods is a list of pods. Pods []*v1.Pod // Rank is a ranking of pods. This ranking is used during sorting when // comparing two pods that are both scheduled, in the same phase, and // having the same ready status. Rank []int // Now is a reference timestamp for doing logarithmic timestamp comparisons. // If zero, comparison happens without scaling. Now metav1.Time }
ActivePodsWithRanks is a sortable list of pods and a list of corresponding ranks which will be considered during sorting. The two lists must have equal length. After sorting, the pods will be ordered as follows, applying each rule in turn until one matches:
- If only one of the pods is assigned to a node, the pod that is not assigned comes before the pod that is.
- If the pods' phases differ, a pending pod comes before a pod whose phase is unknown, and a pod whose phase is unknown comes before a running pod.
- If exactly one of the pods is ready, the pod that is not ready comes before the ready pod.
- If controller.kubernetes.io/pod-deletion-cost annotation is set, then the pod with the lower value will come first.
- If the pods' ranks differ, the pod with greater rank comes before the pod with lower rank.
- If both pods are ready but have not been ready for the same amount of time, the pod that has been ready for a shorter amount of time comes before the pod that has been ready for longer.
- If one pod has a container that has restarted more than any container in the other pod, the pod with the container with more restarts comes before the other pod.
- If the pods' creation times differ, the pod that was created more recently comes before the older pod.
In 6 and 8, times are compared in a logarithmic scale. This allows a level of randomness among equivalent Pods when sorting. If two pods have the same logarithmic rank, they are sorted by UUID to provide a pseudorandom order.
If none of these rules matches, the second pod comes before the first pod.
The intention of this ordering is to put pods that should be preferred for deletion first in the list.
func (ActivePodsWithRanks) Len ¶
func (s ActivePodsWithRanks) Len() int
func (ActivePodsWithRanks) Less ¶
func (s ActivePodsWithRanks) Less(i, j int) bool
Less compares two pods with corresponding ranks and returns true if the first one should be preferred for deletion.
func (ActivePodsWithRanks) Swap ¶
func (s ActivePodsWithRanks) Swap(i, j int)
type BaseControllerRefManager ¶
type BaseControllerRefManager struct { Controller metav1.Object Selector labels.Selector CanAdoptFunc func(ctx context.Context) error // contains filtered or unexported fields }
func (*BaseControllerRefManager) CanAdopt ¶
func (m *BaseControllerRefManager) CanAdopt(ctx context.Context) error
func (*BaseControllerRefManager) ClaimObject ¶
func (m *BaseControllerRefManager) ClaimObject(ctx context.Context, obj metav1.Object, match func(metav1.Object) bool, adopt, release func(context.Context, 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 ¶
ByLogging allows custom sorting of pods so the best one can be picked for getting its logs.
type ControlleeExpectations ¶
type ControlleeExpectations struct {
// contains filtered or unexported fields
}
ControlleeExpectations track controllee creates/deletes.
func (*ControlleeExpectations) Add ¶
func (e *ControlleeExpectations) Add(add, del int64)
Add increments the add and del counters.
func (*ControlleeExpectations) Fulfilled ¶
func (e *ControlleeExpectations) Fulfilled() bool
Fulfilled returns true if this expectation has been fulfilled.
func (*ControlleeExpectations) GetExpectations ¶
func (e *ControlleeExpectations) GetExpectations() (int64, int64)
GetExpectations returns the add and del expectations of the controllee.
func (*ControlleeExpectations) MarshalLog ¶
func (e *ControlleeExpectations) MarshalLog() interface{}
MarshalLog makes a thread-safe copy of the values of the expectations that can be used for logging.
type ControllerExpectations ¶
ControllerExpectations is a cache mapping controllers to what they expect to see before being woken up for a sync.
func NewControllerExpectations ¶
func NewControllerExpectations() *ControllerExpectations
NewControllerExpectations returns a store for ControllerExpectations.
func (*ControllerExpectations) CreationObserved ¶
func (r *ControllerExpectations) CreationObserved(logger klog.Logger, controllerKey string)
CreationObserved atomically decrements the `add` expectation count of the given controller.
func (*ControllerExpectations) DeleteExpectations ¶
func (r *ControllerExpectations) DeleteExpectations(logger klog.Logger, controllerKey string)
DeleteExpectations deletes the expectations of the given controller from the TTLStore.
func (*ControllerExpectations) DeletionObserved ¶
func (r *ControllerExpectations) DeletionObserved(logger klog.Logger, controllerKey string)
DeletionObserved atomically decrements the `del` expectation count of the given controller.
func (*ControllerExpectations) ExpectCreations ¶
func (r *ControllerExpectations) ExpectCreations(logger klog.Logger, controllerKey string, adds int) error
func (*ControllerExpectations) ExpectDeletions ¶
func (r *ControllerExpectations) ExpectDeletions(logger klog.Logger, controllerKey string, dels int) error
func (*ControllerExpectations) GetExpectations ¶
func (r *ControllerExpectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
GetExpectations returns the ControlleeExpectations of the given controller.
func (*ControllerExpectations) LowerExpectations ¶
func (r *ControllerExpectations) LowerExpectations(logger klog.Logger, controllerKey string, add, del int)
Decrements the expectation counts of the given controller.
func (*ControllerExpectations) RaiseExpectations ¶
func (r *ControllerExpectations) RaiseExpectations(logger klog.Logger, controllerKey string, add, del int)
Increments the expectation counts of the given controller.
func (*ControllerExpectations) SatisfiedExpectations ¶
func (r *ControllerExpectations) SatisfiedExpectations(logger klog.Logger, 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 ¶
func (r *ControllerExpectations) SetExpectations(logger klog.Logger, controllerKey string, add, del int) error
SetExpectations registers new expectations for the given controller. Forgets existing expectations.
type ControllerExpectationsInterface ¶
type ControllerExpectationsInterface interface { GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error) SatisfiedExpectations(logger klog.Logger, controllerKey string) bool DeleteExpectations(logger klog.Logger, controllerKey string) SetExpectations(logger klog.Logger, controllerKey string, add, del int) error ExpectCreations(logger klog.Logger, controllerKey string, adds int) error ExpectDeletions(logger klog.Logger, controllerKey string, dels int) error CreationObserved(logger klog.Logger, controllerKey string) DeletionObserved(logger klog.Logger, controllerKey string) RaiseExpectations(logger klog.Logger, controllerKey string, add, del int) LowerExpectations(logger klog.Logger, 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 ¶
type ControllerRevisionControlInterface interface {
PatchControllerRevision(ctx context.Context, 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 ¶
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 ¶
func NewControllerRevisionControllerRefManager( crControl ControllerRevisionControlInterface, controller metav1.Object, selector labels.Selector, controllerKind schema.GroupVersionKind, canAdopt func(ctx context.Context) 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 ¶
func (m *ControllerRevisionControllerRefManager) AdoptControllerRevision(ctx context.Context, 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 ¶
func (m *ControllerRevisionControllerRefManager) ClaimControllerRevisions(ctx context.Context, 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 ¶
func (m *ControllerRevisionControllerRefManager) ReleaseControllerRevision(ctx context.Context, 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 ¶
type ControllersByCreationTimestamp []*v1.ReplicationController
ControllersByCreationTimestamp sorts a list of ReplicationControllers by creation timestamp, using their names as a tie breaker.
func (ControllersByCreationTimestamp) Len ¶
func (o ControllersByCreationTimestamp) Len() int
func (ControllersByCreationTimestamp) Less ¶
func (o ControllersByCreationTimestamp) Less(i, j int) bool
func (ControllersByCreationTimestamp) Swap ¶
func (o ControllersByCreationTimestamp) Swap(i, j int)
type FakePodControl ¶
type FakePodControl struct { sync.Mutex Templates []api.PodTemplateSpec ControllerRefs []metav1.OwnerReference DeletePodName []string Patches [][]byte Err error CreateLimit int CreateCallCount int }
func (*FakePodControl) Clear ¶
func (f *FakePodControl) Clear()
func (*FakePodControl) CreatePods ¶
func (f *FakePodControl) CreatePods(ctx context.Context, namespace string, pInfo PodInfo, object runtime.Object, controllerRef *metav1.OwnerReference) error
func (*FakePodControl) CreatePodsWithGenerateName ¶
type OperatorConfig ¶
type OperatorConfig struct { KubeInformerFactory informers.SharedInformerFactory InformerFactory apiinformers.SharedInformerFactory ResyncPeriod time.Duration MaxNumRequeues int NumThreads int ClientConfig *rest.Config KubeClient kubernetes.Interface Client versioned.Interface }
func NewOperatorConfig ¶
func NewOperatorConfig(clientConfig *rest.Config) *OperatorConfig
type PodControlInterface ¶
type PodControlInterface interface { // CreatePods creates new pods according to the spec, and sets object as the pod's controller. CreatePods(ctx context.Context, namespace string, pInfo PodInfo, object runtime.Object, controllerRef *metav1.OwnerReference) error // CreatePodsWithGenerateName creates new pods according to the spec, sets object as the pod's controller and sets pod's generateName. CreatePodsWithGenerateName(ctx context.Context, namespace string, pInfo PodInfo, object runtime.Object, controllerRef *metav1.OwnerReference, generateName string) error // DeletePod deletes the pod identified by podID. DeletePod(ctx context.Context, namespace string, podID string, object runtime.Object) error // PatchPod patches the pod. PatchPod(ctx context.Context, 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 ¶
type PodControllerRefManager struct { BaseControllerRefManager // contains filtered or unexported fields }
func NewPodControllerRefManager ¶
func NewPodControllerRefManager( podControl PodControlInterface, controller metav1.Object, selector labels.Selector, controllerKind schema.GroupVersionKind, canAdopt func(ctx context.Context) error, finalizers ...string, ) *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 ¶
AdoptPod sends a patch to take control of the pod. It returns the error if the patching fails.
func (*PodControllerRefManager) ClaimPods ¶
func (m *PodControllerRefManager) ClaimPods(ctx context.Context, 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 ¶
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 PodInfo ¶ added in v0.0.2
type PodInfo struct { PetSet *api.PetSet Template *api.PodTemplateSpec PlacementPolicy *api.PlacementPolicy PodIndex int PodList *v1.PodList Obj map[string]interface{} Env *cel.Env }
func NewPodInfo ¶ added in v0.0.2
func NewPodInfo(set *api.PetSet, template *api.PodTemplateSpec, place *api.PlacementPolicy, podIndex int, podList *v1.PodList) PodInfo
type RSControlInterface ¶
type RSControlInterface interface {
PatchReplicaSet(ctx context.Context, 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 ¶
RealControllerRevisionControl is the default implementation of ControllerRevisionControlInterface.
func (RealControllerRevisionControl) PatchControllerRevision ¶
type RealPodControl ¶
type RealPodControl struct { KubeClient clientset.Interface Recorder record.EventRecorder }
RealPodControl is the default implementation of PodControlInterface.
func (RealPodControl) CreatePods ¶
func (r RealPodControl) CreatePods(ctx context.Context, namespace string, pInfo PodInfo, controllerObject runtime.Object, controllerRef *metav1.OwnerReference) error
func (RealPodControl) CreatePodsWithGenerateName ¶
type RealRSControl ¶
type RealRSControl struct { KubeClient clientset.Interface Recorder record.EventRecorder }
RealRSControl is the default implementation of RSControllerInterface.
func (RealRSControl) PatchReplicaSet ¶
type ReplicaSetControllerRefManager ¶
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 ¶
func NewReplicaSetControllerRefManager( rsControl RSControlInterface, controller metav1.Object, selector labels.Selector, controllerKind schema.GroupVersionKind, canAdopt func(ctx context.Context) 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 ¶
func (m *ReplicaSetControllerRefManager) AdoptReplicaSet(ctx context.Context, 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 ¶
func (m *ReplicaSetControllerRefManager) ClaimReplicaSets(ctx context.Context, 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 ¶
func (m *ReplicaSetControllerRefManager) ReleaseReplicaSet(ctx context.Context, 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 ¶
type ReplicaSetsByCreationTimestamp []*apps.ReplicaSet
ReplicaSetsByCreationTimestamp sorts a list of ReplicaSet by creation timestamp, using their names as a tie breaker.
func (ReplicaSetsByCreationTimestamp) Len ¶
func (o ReplicaSetsByCreationTimestamp) Len() int
func (ReplicaSetsByCreationTimestamp) Less ¶
func (o ReplicaSetsByCreationTimestamp) Less(i, j int) bool
func (ReplicaSetsByCreationTimestamp) Swap ¶
func (o ReplicaSetsByCreationTimestamp) Swap(i, j int)
type ReplicaSetsBySizeNewer ¶
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 ¶
func (o ReplicaSetsBySizeNewer) Len() int
func (ReplicaSetsBySizeNewer) Less ¶
func (o ReplicaSetsBySizeNewer) Less(i, j int) bool
func (ReplicaSetsBySizeNewer) Swap ¶
func (o ReplicaSetsBySizeNewer) Swap(i, j int)
type ReplicaSetsBySizeOlder ¶
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 ¶
func (o ReplicaSetsBySizeOlder) Len() int
func (ReplicaSetsBySizeOlder) Less ¶
func (o ReplicaSetsBySizeOlder) Less(i, j int) bool
func (ReplicaSetsBySizeOlder) Swap ¶
func (o ReplicaSetsBySizeOlder) Swap(i, j int)
type ResyncPeriodFunc ¶
func StaticResyncPeriodFunc ¶
func StaticResyncPeriodFunc(resyncPeriod time.Duration) ResyncPeriodFunc
StaticResyncPeriodFunc returns the resync period specified
type UIDSet ¶
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 ¶
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 ¶
func NewUIDTrackingControllerExpectations(ce ControllerExpectationsInterface) *UIDTrackingControllerExpectations
NewUIDTrackingControllerExpectations returns a wrapper around ControllerExpectations that is aware of deleteKeys.
func (*UIDTrackingControllerExpectations) DeleteExpectations ¶
func (u *UIDTrackingControllerExpectations) DeleteExpectations(logger klog.Logger, rcKey string)
DeleteExpectations deletes the UID set and invokes DeleteExpectations on the underlying ControllerExpectationsInterface.
func (*UIDTrackingControllerExpectations) DeletionObserved ¶
func (u *UIDTrackingControllerExpectations) DeletionObserved(logger klog.Logger, rcKey, deleteKey string)
DeletionObserved records the given deleteKey as a deletion, for the given rc.
func (*UIDTrackingControllerExpectations) ExpectDeletions ¶
func (u *UIDTrackingControllerExpectations) ExpectDeletions(logger klog.Logger, rcKey string, deletedKeys []string) error
ExpectDeletions records expectations for the given deleteKeys, against the given controller.
func (*UIDTrackingControllerExpectations) GetUIDs ¶
func (u *UIDTrackingControllerExpectations) GetUIDs(controllerKey string) sets.Set[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.