Documentation ¶
Overview ¶
Package controllers is used to provide the core functionalities of hvpa-controller
Index ¶
- func RecheckDeletionTimestamp(getObject func() (metav1.Object, error)) func() error
- type BaseControllerRefManager
- type HvpaControllerRefManager
- func (m *HvpaControllerRefManager) AdoptHpa(hpa *autoscaling.HorizontalPodAutoscaler) error
- func (m *HvpaControllerRefManager) AdoptVpa(vpa *vpa_api.VerticalPodAutoscaler) error
- func (m *HvpaControllerRefManager) ClaimHpas(hpas *autoscaling.HorizontalPodAutoscalerList, ...) ([]*autoscaling.HorizontalPodAutoscaler, error)
- func (m *HvpaControllerRefManager) ClaimVpas(vpas *vpa_api.VerticalPodAutoscalerList, ...) ([]*vpa_api.VerticalPodAutoscaler, error)
- func (m *HvpaControllerRefManager) ReleaseHpa(hpa *autoscaling.HorizontalPodAutoscaler) error
- func (m *HvpaControllerRefManager) ReleaseVpa(vpa *vpa_api.VerticalPodAutoscaler) error
- type HvpaReconciler
- func (r *HvpaReconciler) AddMetrics() error
- func (r *HvpaReconciler) ManageCache(instance *autoscalingv1alpha1.Hvpa, namespacedName types.NamespacedName, ...)
- func (r *HvpaReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
- func (r *HvpaReconciler) SetupWithManager(mgr ctrl.Manager) error
- func (r *HvpaReconciler) UpdateHpaWithRetries(namespace, name string, applyUpdate updateHpaFunc) (*autoscaling.HorizontalPodAutoscaler, error)
- func (r *HvpaReconciler) UpdateVpaWithRetries(namespace, name string, applyUpdate updateVpaFunc) (*vpa_api.VerticalPodAutoscaler, error)
- type OomkillPredicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecheckDeletionTimestamp ¶
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.
Types ¶
type BaseControllerRefManager ¶
type BaseControllerRefManager struct { Controller metav1.Object Selector labels.Selector CanAdoptFunc func() error // contains filtered or unexported fields }
BaseControllerRefManager is the struct is used to identify the base controller of the object
func (*BaseControllerRefManager) CanAdopt ¶
func (m *BaseControllerRefManager) CanAdopt() error
CanAdopt is used to identify if the object can be adopted by the controller
func (*BaseControllerRefManager) ClaimObject ¶
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 HvpaControllerRefManager ¶
type HvpaControllerRefManager struct { BaseControllerRefManager // contains filtered or unexported fields }
HvpaControllerRefManager is the struct used to manage its child objects
func NewHvpaControllerRefManager ¶
func NewHvpaControllerRefManager( reconciler *HvpaReconciler, controller metav1.Object, selector labels.Selector, controllerKind schema.GroupVersionKind, canAdopt func() error, ) *HvpaControllerRefManager
NewHvpaControllerRefManager returns a HvpaControllerRefManager that exposes methods to manage the controllerRef of its child objects.
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
HvpaControllerRefManager HPA/VPA. Create a new HPA/VPA if it makes sense to check CanAdopt() again (e.g. in a different sync pass).
func (*HvpaControllerRefManager) AdoptHpa ¶
func (m *HvpaControllerRefManager) AdoptHpa(hpa *autoscaling.HorizontalPodAutoscaler) error
AdoptHpa sends a patch to take control of the Hpa. It returns the error if the patching fails.
func (*HvpaControllerRefManager) AdoptVpa ¶
func (m *HvpaControllerRefManager) AdoptVpa(vpa *vpa_api.VerticalPodAutoscaler) error
AdoptVpa sends a patch to take control of the Vpa. It returns the error if the patching fails.
func (*HvpaControllerRefManager) ClaimHpas ¶
func (m *HvpaControllerRefManager) ClaimHpas(hpas *autoscaling.HorizontalPodAutoscalerList, filters ...func(*autoscaling.HorizontalPodAutoscaler) bool) ([]*autoscaling.HorizontalPodAutoscaler, error)
ClaimHpas tries to take ownership of a list of Hpas.
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 Hpa 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 Hpas that you now own is returned.
func (*HvpaControllerRefManager) ClaimVpas ¶
func (m *HvpaControllerRefManager) ClaimVpas(vpas *vpa_api.VerticalPodAutoscalerList, filters ...func(*vpa_api.VerticalPodAutoscaler) bool) ([]*vpa_api.VerticalPodAutoscaler, error)
ClaimVpas tries to take ownership of a list of Vpas.
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 Vpa 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 Vpas that you now own is returned.
func (*HvpaControllerRefManager) ReleaseHpa ¶
func (m *HvpaControllerRefManager) ReleaseHpa(hpa *autoscaling.HorizontalPodAutoscaler) error
ReleaseHpa sends a patch to free the Hpa from the control of the controller. It returns the error if the patching fails. 404 and 422 errors are ignored.
func (*HvpaControllerRefManager) ReleaseVpa ¶
func (m *HvpaControllerRefManager) ReleaseVpa(vpa *vpa_api.VerticalPodAutoscaler) error
ReleaseVpa sends a patch to free the Vpa from the control of the controller. It returns the error if the patching fails. 404 and 422 errors are ignored.
type HvpaReconciler ¶
type HvpaReconciler struct { client.Client Scheme *runtime.Scheme EnableDetailedMetrics bool // contains filtered or unexported fields }
HvpaReconciler reconciles a Hvpa object
func (*HvpaReconciler) AddMetrics ¶
func (r *HvpaReconciler) AddMetrics() error
AddMetrics initializes and registers the custom metrics for HVPA controller.
func (*HvpaReconciler) ManageCache ¶
func (r *HvpaReconciler) ManageCache(instance *autoscalingv1alpha1.Hvpa, namespacedName types.NamespacedName, foundHvpa bool)
ManageCache manages the global map of HVPAs
func (*HvpaReconciler) Reconcile ¶
Reconcile reads that state of the cluster for a Hvpa object and makes changes based on the state read and what is in the Hvpa.Spec Automatically generate RBAC rules to allow the Controller to read and write HPAs and VPAs +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=autoscaling.k8s.io,resources=verticalpodautoscalers,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;update;patch +kubebuilder:rbac:groups="",resources=pods;replicationcontrollers,verbs=get;list;watch;update;patch +kubebuilder:rbac:groups=apps,resources=daemonsets;replicasets;statefulsets;deployments,verbs=get;list;watch;update;patch +kubebuilder:rbac:groups=autoscaling.k8s.io,resources=hvpas,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=autoscaling.k8s.io,resources=hvpas/status,verbs=get;update;patch +kubebuilder:rbac:groups="",resources=events,verbs=get;watch;list
func (*HvpaReconciler) SetupWithManager ¶
func (r *HvpaReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up manager with a new controller and r as the reconcile.Reconciler
func (*HvpaReconciler) UpdateHpaWithRetries ¶
func (r *HvpaReconciler) UpdateHpaWithRetries(namespace, name string, applyUpdate updateHpaFunc) (*autoscaling.HorizontalPodAutoscaler, error)
UpdateHpaWithRetries updates a hpa with given applyUpdate function. Note that hpa not found error is ignored.
func (*HvpaReconciler) UpdateVpaWithRetries ¶
func (r *HvpaReconciler) UpdateVpaWithRetries(namespace, name string, applyUpdate updateVpaFunc) (*vpa_api.VerticalPodAutoscaler, error)
UpdateVpaWithRetries updates a vpa with given applyUpdate function. Note that vpa not found error is ignored.
type OomkillPredicate ¶
OomkillPredicate implements a oomkill predicate function