Object pruning utility for Go-based Operators
Objects, such as jobs or pods, are created as a normal part of the Operator life cycle. If the cluster administrator or the Operator does not remove these object, they can stay in the cluster and consume resources.
Previously, the following options were available for pruning unnecessary objects:
Operator authors had to create a unique pruning solution for their Operators.
The operator-lib
removes objects from a Kubernetes cluster for a given namespace. The library was added in version 0.9.0
of the operator-lib library as part of the Operator Framework.
Pruning utility configuration
The operator-lib
pruning utility is written in Go and includes common pruning strategies for Go-based Operators.
Example configuration
The pruning utility configuration file defines pruning actions by using the following fields:
Pruning execution
err := cfg.Execute(ctx)
You can also call a pruning action by using a cron package or by calling the pruning utility with a triggering event.