kube-watch
kube-watch copied to clipboard
installation instructions are not working
-
npm i kube-watch
- copy
import KubeWatch from 'kube-watch';
const pods = new KubeWatch('pods', {
url: 'http://kube-api-server' // Kubernetes API URL
});
pods
.on('added', event => {
console.log('Pod %s added to namespace %s with IP address %s',
event.metadata.name, event.metadata.namespace, event.status.podIP);
})
.on('modified', event => {
// do something...
})
.on('deleted', event => {
// ..do something else..
})
.on('error', err => {
console.error('Error %d: %s', err.code, err.message);
});
- result:
node index.js
index.js:2
import KubeWatch from 'kube-watch';
^^^^^^
SyntaxError: Unexpected token import
[...]
you need to use babel to precompile it first
@sheerun I'm having the same problem .. How do I precompile with babel?
there are different methods for different environments, please check their docs