Operator Library
About
While working on many Kubernetes operators, I realised that a lot of code is repetative across operators. Generating, creating, updating, deleting objects is a common thing and yet the code is being repeated in every operator. I decided to work on project which removes the the repeatative code from all Kubernetes Operators. The benefits of this approach are that common well tested and stable functions can be used by all operators. Also, this kind of tries to reduce the complexity of dealing with Kubernetes objects which (hopefully!) will lead to more and more vendors building there own operators. This project also attempts to reduce the overall work required to build the operator which means operators for small projects can be build quickly.
Usage
The Kubernetes interactions are abstracted away so you do not have to
care about the Client for the simple usage. For instance, if you want
to create a ConfigMap
object using Operatorlib, import configmap
package and add the following lines of code whereever it seems fit.
import "github.com/ankitrgadiya/operatorlib/pkg/configmap
...
result, err := configmap.CreateOrUpdate(configmap.Conf{
Name: "test",
Namespace: "default",
})
if err != nil {
return result, err
}
...
This however will create an empty Configmap
. To see all the options
check the Conf
section
in the documentation. Check the list of supported objects
below. Operatorlib also provides low-level package operation
which
can be used to create all non-supported objects (including custom
objects) as long as they implement
Object
interface defines in interface
package.