README ¶
Yacht
Light-weighted Kubernetes controller-runtime Framework with Minimal Dependencies
Why Building Yacht
Well, there are quite a few controller/operator frameworks out there, such as kubebuilder, operator-sdk, controller-runtime. But they are not quite handy.
First of all, building a scaffold project may not be what we really need. Most of the time, we are not trying to build a project from scratch, but rather adding new controllers on an existing project. Moreover, the structure of the scaffold project does not suit all. It is not easy to customize the scaffolds according to our own preferences.
Secondly, backwards compatibility. Most frameworks DO NOT guarantee any particular compatibility matrix between kubernetes library dependencies (client-go, apimachinery, etc). This is painful when we want to pin Kubernetes library dependencies to any specific lower versions. It has always been a headache to upgrade/downgrade the versions of frameworks and Kubernetes library dependencies.
Last but not least, we DO want a light-weighted framework with minimal dependencies.
That's why I build yacht, which brings pleasure user experiences on writing Kubernetes controllers. It is built with minimal dependencies, which makes it easier to downgrade/upgrade module versions.
To Start Using Yacht
- Add
github.com/dixudx/yacht
to yourgo.mod
file. - Follow yacht examples and learn how to use.
Documentation ¶
Index ¶
- func DefaultEnqueueFunc(obj interface{}) (interface{}, error)
- type Controller
- func (c *Controller) DefaultResourceEventHandlerFuncs() cache.ResourceEventHandlerFuncs
- func (c *Controller) Enqueue(obj interface{})
- func (c *Controller) Run(ctx context.Context)
- func (c *Controller) WithCacheSynced(informersSynced ...cache.InformerSynced) *Controller
- func (c *Controller) WithEnqueueFilterFunc(enqueueFilterFunc EnqueueFilterFunc) *Controller
- func (c *Controller) WithEnqueueFunc(enqueueFunc EnqueueFunc) *Controller
- func (c *Controller) WithHandlerContextFunc(handlerContextFunc HandlerContextFunc) *Controller
- func (c *Controller) WithHandlerFunc(handlerFunc HandlerFunc) *Controller
- func (c *Controller) WithLeaderElection(leaseLock rl.Interface, ...) *Controller
- func (c *Controller) WithQueue(queue workqueue.RateLimitingInterface) *Controller
- func (c *Controller) WithWorkers(workers int) *Controller
- type EnqueueFilterFunc
- type EnqueueFunc
- type HandlerContextFunc
- type HandlerFuncdeprecated
- type Interface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultEnqueueFunc ¶
func DefaultEnqueueFunc(obj interface{}) (interface{}, error)
DefaultEnqueueFunc uses a default namespacedKey as its KeyFunc. The key uses the format <namespace>/<name> unless <namespace> is empty, then it's just <name>.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(name string) *Controller
NewController creates a new Controller
func (*Controller) DefaultResourceEventHandlerFuncs ¶ added in v0.2.0
func (c *Controller) DefaultResourceEventHandlerFuncs() cache.ResourceEventHandlerFuncs
func (*Controller) Enqueue ¶
func (c *Controller) Enqueue(obj interface{})
Enqueue takes an object and converts it into a key (could be a string, or a struct) which is then put onto the work queue.
func (*Controller) Run ¶
func (c *Controller) Run(ctx context.Context)
Run will start multiple workers to process work items from work queue. It will block until ctx is closed.
func (*Controller) WithCacheSynced ¶
func (c *Controller) WithCacheSynced(informersSynced ...cache.InformerSynced) *Controller
WithCacheSynced sets all the resource cacheSynced
func (*Controller) WithEnqueueFilterFunc ¶ added in v0.2.0
func (c *Controller) WithEnqueueFilterFunc(enqueueFilterFunc EnqueueFilterFunc) *Controller
WithEnqueueFilterFunc sets customize enqueueFilterFunc
func (*Controller) WithEnqueueFunc ¶
func (c *Controller) WithEnqueueFunc(enqueueFunc EnqueueFunc) *Controller
WithEnqueueFunc sets customize enqueueFunc
func (*Controller) WithHandlerContextFunc ¶ added in v0.8.0
func (c *Controller) WithHandlerContextFunc(handlerContextFunc HandlerContextFunc) *Controller
WithHandlerContextFunc sets a handler function to process the work item off the work queue
func (*Controller) WithHandlerFunc ¶
func (c *Controller) WithHandlerFunc(handlerFunc HandlerFunc) *Controller
WithHandlerFunc sets a handler function to process the work item off the work queue Deprecated: Use WithHandlerContextFunc instead.
func (*Controller) WithLeaderElection ¶
func (c *Controller) WithLeaderElection(leaseLock rl.Interface, leaseDuration, renewDeadline, retryPeriod time.Duration) *Controller
WithLeaderElection uses leader election to get the lock
func (*Controller) WithQueue ¶ added in v0.7.0
func (c *Controller) WithQueue(queue workqueue.RateLimitingInterface) *Controller
WithQueue replaces the default queue with the desired one to store work items.
func (*Controller) WithWorkers ¶
func (c *Controller) WithWorkers(workers int) *Controller
WithWorkers sets the number of workers to process work items off work queue
type EnqueueFilterFunc ¶ added in v0.2.0
type EnqueueFunc ¶
type EnqueueFunc func(obj interface{}) (interface{}, error)
type HandlerContextFunc ¶ added in v0.8.0
type HandlerFunc
deprecated
type Interface ¶
type Interface interface { Enqueue(obj interface{}) WithEnqueueFunc(EnqueueFunc) *Controller // Deprecated: Use WithHandlerContextFunc instead. WithHandlerFunc(HandlerFunc) *Controller WithHandlerContextFunc(HandlerContextFunc) *Controller WithLeaderElection(leaseLock rl.Interface, leaseDuration, renewDeadline, retryPeriod time.Duration) *Controller WithCacheSynced(...cache.InformerSynced) *Controller }
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
downgrading-dependencies
Module
|
|
enqueue-filter-informer
Module
|
|
sample-informer
Module
|
|
use-leader-election
Module
|
|