KubernetesInformer
Class: KubernetesInformer<T>
Defined in: kubernetes/src/utils/informer.ts:115
Keep an up-to-date cache of custom resources: list them, then watch their changes
Unlike the informer of @kubernetes/client-node, it restarts by itself after an error (failed list, lost watch, missing permission...) with an exponential backoff, keeping the last known objects meanwhile.
Events:
add,update,delete,change(any of the three): an object changedsynced: a list succeeded, with all the objectsconnect: the informer (re)connectswatching: a watch request is accepted, the cache follows the changes againerror: a list or a watch failed, the informer restarts
Type Parameters
T
T extends k8s.KubernetesObject = k8s.KubernetesObject
Constructors
Constructor
new KubernetesInformer<
T>(params,resource,options?):KubernetesInformer<T>
Defined in: kubernetes/src/utils/informer.ts:144
Parameters
params
the kubernetes parameters, timeout applies to the list requests (not to the watch)
resource
the custom resources to watch
options?
KubernetesInformerOptions = {}
restart policy
Returns
KubernetesInformer<T>
Properties
currentRestartDelay
protectedcurrentRestartDelay:number
Defined in: kubernetes/src/utils/informer.ts:131
informer
protectedinformer:ListWatch<T>
Defined in: kubernetes/src/utils/informer.ts:116
listeners
protectedlisteners:Listeners<T>
Defined in: kubernetes/src/utils/informer.ts:119
maxRestartDelay
protectedmaxRestartDelay:number
Defined in: kubernetes/src/utils/informer.ts:133
pendingSync?
protectedoptionalpendingSync?:T[]
Defined in: kubernetes/src/utils/informer.ts:118
objects of the last successful list, until the cache is updated with them
restartDelay
protectedrestartDelay:number
Defined in: kubernetes/src/utils/informer.ts:132
restartTimer?
protectedoptionalrestartTimer?:Timeout
Defined in: kubernetes/src/utils/informer.ts:130
stopped
protectedstopped:boolean=true
Defined in: kubernetes/src/utils/informer.ts:129
synced
synced:
boolean=false
Defined in: kubernetes/src/utils/informer.ts:137
Whether a list succeeded since the creation of the informer
Methods
emit()
protectedemit(event, ...args):void
Defined in: kubernetes/src/utils/informer.ts:244
Call the listeners of an event
Parameters
event
ObjectEvent | "error" | "connect" | "synced" | "watching"
the event
args
...any[]
the arguments of the listeners
Returns
void
flushSync()
protectedflushSync():void
Defined in: kubernetes/src/utils/informer.ts:253
After a successful list, once the cache is updated: reset the restart backoff and emit synced
Returns
void
get()
get(
name,namespace?):T|undefined
Defined in: kubernetes/src/utils/informer.ts:235
Parameters
name
string
name of the object
namespace?
string
namespace of the object, for namespaced resources
Returns
T | undefined
the object, undefined when unknown
list()
list(
namespace?): readonlyT[]
Defined in: kubernetes/src/utils/informer.ts:226
Parameters
namespace?
string
only the objects of this namespace
Returns
readonly T[]
the known objects
off()
off<
K>(event,listener):this
Defined in: kubernetes/src/utils/informer.ts:198
Stop listening to an event
Type Parameters
K
K extends ObjectEvent | "error" | "connect" | "synced" | "watching"
Parameters
event
K
the event
listener
Listeners<T>[K][number]
the listener given to on
Returns
this
this
on()
on<
K>(event,listener):this
Defined in: kubernetes/src/utils/informer.ts:187
Listen to an event
Type Parameters
K
K extends ObjectEvent | "error" | "connect" | "synced" | "watching"
Parameters
event
K
the event
listener
Listeners<T>[K][number]
called with the object, the error or the objects depending on the event
Returns
this
this
onError()
protectedonError(err):void
Defined in: kubernetes/src/utils/informer.ts:268
A list or a watch failed: emit the error and restart after the backoff delay, unless stopped
Parameters
err
any
the error
Returns
void
start()
start():
Promise<void>
Defined in: kubernetes/src/utils/informer.ts:207
Start listing and watching
Returns
Promise<void>
once the first list is done, successful or not (check synced)
stop()
stop():
Promise<void>
Defined in: kubernetes/src/utils/informer.ts:215
Stop watching, the cache keeps the last known objects
Returns
Promise<void>