Skip to content

Instantly share code, notes, and snippets.

@thenayr
Created November 16, 2016 23:23
Show Gist options
  • Save thenayr/27e69700268277824c54e9281a784dae to your computer and use it in GitHub Desktop.
Save thenayr/27e69700268277824c54e9281a784dae to your computer and use it in GitHub Desktop.
Different event streams that come from the k8s watch API
const stream = k8Stream.ns.po.get({ qs: { watch: true } });
stream.pipe(jsonStream);
jsonStream.on('data', object => {
switch(object.type) {
case 'ADDED':
console.log("Do something when a pod is added");
break;
case 'MODIFIED':
console.log("Do something when a pod is modified");
break;
case 'DELETED':
console.log("Do something when a pod is deleted");
break;
default:
console.log("Some other pod event")
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment