Created
November 16, 2016 23:23
-
-
Save thenayr/27e69700268277824c54e9281a784dae to your computer and use it in GitHub Desktop.
Different event streams that come from the k8s watch API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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