Documentation ¶
Index ¶
- type Builder
- func (b *Builder) Complete(reconciler Reconciler) (healthz.Checker, error)
- func (b *Builder) Named(name string) *Builder
- func (b *Builder) Options(options Options) *Builder
- func (b *Builder) SetDefaults()
- func (b *Builder) UsingConditions(conditions condition.Conditions) *Builder
- func (b *Builder) UsingConverter(converter Converter) *Builder
- func (b *Builder) UsingDataStore(dataStore cache.Indexer) *Builder
- func (b *Builder) WithClientSet(clientSet *kubernetes.Clientset) *Builder
- func (b *Builder) WithLogger(logger logr.Logger) *Builder
- type Converter
- type CustomController
- type Options
- type Reconciler
- type Request
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 (*Builder) Complete ¶ added in v1.1.0
func (b *Builder) Complete(reconciler Reconciler) (healthz.Checker, error)
Complete adds the controller to manager's Runnable. The Controller runnable will start when the manager starts
func (*Builder) SetDefaults ¶ added in v1.1.0
func (b *Builder) SetDefaults()
SetDefaults sets the default options for controller
func (*Builder) UsingConditions ¶ added in v1.1.5
func (b *Builder) UsingConditions(conditions condition.Conditions) *Builder
func (*Builder) UsingConverter ¶ added in v1.1.0
func (*Builder) UsingDataStore ¶ added in v1.1.0
func (*Builder) WithClientSet ¶ added in v1.1.0
func (b *Builder) WithClientSet(clientSet *kubernetes.Clientset) *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.
- 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
- 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 NewCustomController ¶ added in v1.1.6
func NewCustomController( log logr.Logger, options Options, config *cache.Config, reconciler Reconciler, workQueue workqueue.RateLimitingInterface, conditions condition.Conditions) *CustomController
func (*CustomController) CustomCheck ¶ added in v1.1.6
func (c *CustomController) CustomCheck() healthz.Checker
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 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