Skip to main content

ModelController

@webda/kubernetes


Class: ModelController

Defined in: kubernetes/src/operator/controller.ts:100

Reconcile the objects of one model stored in a KubernetesStore

It watches the resources of the model, queues the objects whose spec changed (metadata.generation), runs their reconcile and writes status.observedGeneration and a Ready condition. Status-only changes, its own status writes included, are not reconciled again.

Constructors​

Constructor​

new ModelController(model, store, options): ModelController

Defined in: kubernetes/src/operator/controller.ts:115

Parameters​

model​

ModelClass

the model

store​

KubernetesStore

the store of the model

options​

ControllerOptions

queue, resync and finalizer

Returns​

ModelController

Properties​

attempted​

protected attempted: Map<string, number>

Defined in: kubernetes/src/operator/controller.ts:108

generation of each object last reconciled, successfully or not


filter​

protected filter: KubernetesRepository<any>

Defined in: kubernetes/src/operator/controller.ts:103


informer?​

protected optional informer?: KubernetesInformer<CustomResource>

Defined in: kubernetes/src/operator/controller.ts:104


model​

readonly model: ModelClass

Defined in: kubernetes/src/operator/controller.ts:116

the model


options​

protected options: ControllerOptions

Defined in: kubernetes/src/operator/controller.ts:118

queue, resync and finalizer


queue?​

protected optional queue?: WorkQueue

Defined in: kubernetes/src/operator/controller.ts:105


repository​

protected repository: Repository<any>

Defined in: kubernetes/src/operator/controller.ts:102


resources​

protected resources: CustomResources

Defined in: kubernetes/src/operator/controller.ts:101


resyncTimer?​

protected optional resyncTimer?: Timeout

Defined in: kubernetes/src/operator/controller.ts:106


store​

protected store: KubernetesStore

Defined in: kubernetes/src/operator/controller.ts:117

the store of the model

Methods​

accepts()​

protected accepts(resource): boolean

Defined in: kubernetes/src/operator/controller.ts:168

Whether a resource holds an object of the model (subclasses share the resources of their root model)

Parameters​

resource​

CustomResource

the resource

Returns​

boolean

true if it does


enqueue()​

protected enqueue(name): void

Defined in: kubernetes/src/operator/controller.ts:185

Queue an object

Parameters​

name​

string

the resource name

Returns​

void


finalize()​

protected finalize(resource): Promise<void>

Defined in: kubernetes/src/operator/controller.ts:258

Call finalize of an object being deleted, then remove the finalizer

Parameters​

resource​

CustomResource

the resource

Returns​

Promise<void>


onChange()​

protected onChange(resource): void

Defined in: kubernetes/src/operator/controller.ts:194

Queue a changed object, unless its spec is already reconciled

Parameters​

resource​

CustomResource

the resource

Returns​

void


process()​

protected process(name): Promise<WorkResult>

Defined in: kubernetes/src/operator/controller.ts:212

Reconcile or finalize an object

Parameters​

name​

string

the resource name

Returns​

Promise<WorkResult>

the reconcile result


resync()​

resync(): void

Defined in: kubernetes/src/operator/controller.ts:175

Queue every object of the model

Returns​

void


start()​

start(): Promise<void>

Defined in: kubernetes/src/operator/controller.ts:129

Start watching and reconciling

Returns​

Promise<void>

once the resources are listed


stop()​

stop(): Promise<void>

Defined in: kubernetes/src/operator/controller.ts:155

Stop watching and reconciling

Returns​

Promise<void>

once the reconciliations in progress are done


update()​

protected update(name, change, status?): Promise<void>

Defined in: kubernetes/src/operator/controller.ts:276

Read, change and replace a resource, again on conflict

Parameters​

name​

string

the resource name

change​

(resource) => boolean

change the resource, false when there is nothing to write

status?​

boolean = false

write the status subresource instead of the resource

Returns​

Promise<void>


writeStatus()​

protected writeStatus(name, generation, condition): Promise<void>

Defined in: kubernetes/src/operator/controller.ts:307

Write the observed generation and a condition in the status

Parameters​

name​

string

the resource name

generation​

number

the generation reconciled

condition​

Omit<ResourceCondition, "lastTransitionTime" | "observedGeneration">

the condition

Returns​

Promise<void>