custom

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder added in v1.1.0

type Builder struct {
	// contains filtered or unexported fields
}

func NewControllerManagedBy added in v1.1.0

func NewControllerManagedBy(ctx context.Context, mgr manager.Manager) *Builder

func (*Builder) Complete added in v1.1.0

func (b *Builder) Complete(reconciler Reconciler) error

Complete adds the controller to manager's Runnable. The Controller runnable will start when the manager starts

func (*Builder) DataStoreSyncFlag added in v1.1.0

func (b *Builder) DataStoreSyncFlag(flag *bool) *Builder

func (*Builder) Named added in v1.1.0

func (b *Builder) Named(name string) *Builder

func (*Builder) Options added in v1.1.0

func (b *Builder) Options(options Options) *Builder

func (*Builder) SetDefaults added in v1.1.0

func (b *Builder) SetDefaults()

SetDefaults sets the default options for controller

func (*Builder) UsingConverter added in v1.1.0

func (b *Builder) UsingConverter(converter Converter) *Builder

func (*Builder) UsingDataStore added in v1.1.0

func (b *Builder) UsingDataStore(dataStore cache.Indexer) *Builder

func (*Builder) WithClientSet added in v1.1.0

func (b *Builder) WithClientSet(clientSet *kubernetes.Clientset) *Builder

func (*Builder) WithLogger added in v1.1.0

func (b *Builder) WithLogger(logger logr.Logger) *Builder

type Converter

type Converter interface {
	// ConvertObject takes an object and returns the modified object which will be
	// stored in the data store
	ConvertObject(originalObj interface{}) (convertedObj interface{}, err error)
	// ConvertList takes an object and returns the modified list of objects which
	// will be returned to the Simple Pager function to aggregate the list pagination
	// response
	ConvertList(originalList interface{}) (convertedList interface{}, err error)
	// Resource returns the K8s resource name to list/watch
	Resource() string
	// ResourceType returns the k8s object to list/watch
	ResourceType() runtime.Object
	// Indexer returns the key for indexing custom converted object
	Indexer(obj interface{}) (string, error)
}

Converter for converting k8s object and object list used in watches and list operation to the desired format.

type CustomController

type CustomController struct {

	// Reconciler will be called on all the K8s object events
	Do Reconciler
	// contains filtered or unexported fields
}

This Controller can be used for any type of K8s object, but is used for Pod Objects in this repository. There are two reasons why we are using a wrapper over the low level controllers instead of using controllers from controller-runtime.

  1. We don't want to cache the entire Pod Object because of Memory constraints. We need specific details from metadata and Pod Spec. To do this we intercept the request at List; and watch, optimize it before it's stored in cache. Long term plan is to use MetaData only cache or disable Pod caching altogether
  2. We want the Deleted Object when Pod is Terminating. Pod Networking should only be deleted once the Pod has deleted or all containers have exited. Long term plan is to consider migrating to using finalizers and delete only when all containers have exited.

In future, we may be able to switch to upstream controller for reconciling Pods if the long term solutions are in place

func (*CustomController) Start added in v1.1.0

func (c *CustomController) Start(ctx context.Context) error

Starts the low level controller

func (*CustomController) WaitForCacheSync added in v1.1.0

func (c *CustomController) WaitForCacheSync(controller cache.Controller)

WaitForCacheSync tills the cache has synced, this must be done under mutex lock to prevent other controllers from starting at same time

type Options added in v1.1.0

type Options struct {
	// Name of the controller used for creating named work queues
	Name string
	// PageLimit is the number of objects returned per page on a list operation
	PageLimit int
	// Namespace to list and watch for
	Namespace string
	// ResyncPeriod how often to sync using list with the API Server
	ResyncPeriod time.Duration
	// MaxConcurrentReconciles to parallelize processing of worker queue
	MaxConcurrentReconciles int
}

Options contains the configurable parameters of the Custom Controller

type Reconciler added in v1.1.0

type Reconciler interface {
	Reconcile(request Request) (ctrl.Result, error)
}

type Request added in v1.1.0

type Request struct {
	// Add/Update Request will contain the Namespaced Name only. The
	// item can be retrieved from the indexer for add/update events
	NamespacedName types.NamespacedName
	// Delete Event will contain the DeletedObject only.
	DeletedObject interface{}
}

Request for Add/Update only contains the Namespace/Name Request for Delete contains the Pod Object as by the time Delete Request is reconciled the cache will not have it

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL