-
Notifications
You must be signed in to change notification settings - Fork 58
Add monitoring of container image deployments #13
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ node_modules | |
package-lock.json | ||
yarn.lock | ||
config/local*.yaml | ||
*.idea | ||
*.iml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module.exports = [ | ||
require('./waitingpods'), | ||
require('./longnotready'), | ||
require('./newdeployment'), | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const EventEmitter = require('events'); | ||
const config = require('config'); | ||
const kube = require('../kube'); | ||
|
||
class DeploymentStatus extends EventEmitter{ | ||
constructor(){ | ||
super(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you have nothing but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually from below, we'll need the constructor to initialize the state store. |
||
} | ||
|
||
start(){ | ||
setInterval(() => { | ||
this.check(); | ||
}, config.get('interval')); | ||
|
||
return this; | ||
} | ||
|
||
async check(){ | ||
let containers = await kube.getContainerStatuses(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think rather than checking for newly deployed containers, we should check for newly deployed pods. This is available in |
||
|
||
for(let item of containers){ | ||
if(!item.image === global.image){ | ||
continue; | ||
} | ||
|
||
if(!item.ready){ | ||
continue; | ||
} | ||
|
||
this.emit('message', { | ||
fallback: `Container ${item.pod.metadata.namespace}/${item.pod.metadata.name}/${item.name} has deployed image ${item.image}`, | ||
color: 'good', | ||
title: `${item.pod.metadata.namespace}/${item.pod.metadata.name}/${item.name}`, | ||
text: `Container deployed image *${item.image}*`, | ||
mrkdwn_in: ['text'], | ||
_key: `${item.pod.metadata.name}/${item.name}`, | ||
}); | ||
|
||
global.image = item.image; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is stateful then the state should be stored as instance attribute, rather than as a global variable. |
||
} | ||
} | ||
} | ||
|
||
module.exports = () => new DeploymentStatus().start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using one tab indentation. Please reindent this line and the monitor file.