import * as k8s from '@kubernetes/client-node' ; const kc = new k8s . KubeConfig ( ) ; kc . loadFromDefault ( ) ; const watch = new k8s . Watch ( kc ) ; watch . watch ( '/api/v1/namespaces' , { allowWatchBookmarks : true , } , ( type , apiObj , watchObj ) => { if ( type === 'ADDED' ) { console . log ( 'new object:' ) ; } else if ( type === 'MODIFIED' ) { console . log ( 'changed object:' ) ; } else if ( type === 'DELETED' ) { console . log ( 'deleted object:' ) ; } else if ( type === 'BOOKMARK' ) { console . log ( `bookmark: ${ watchObj . metadata . resourceVersion }` ) ; } else { console . log ( 'unknown type: ' + type ) ; } console . log ( apiObj ) ; } , ( err ) => { console . log ( err ) ; } ) . then ( ( req ) => { setTimeout ( ( ) => { req . abort ( ) ; } , 10 * 1000 ) ; } ) ;