forked from astefanutti/kubebox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·34 lines (27 loc) · 985 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
'use strict';
const blessed = require('blessed'),
cancellations = require('./lib/task'),
Context = require('./lib/config/context'),
fs = require('fs'),
Kubebox = require('./lib/kubebox');
const screen = blessed.screen({
ignoreLocked: ['C-q'],
});
screen.key(['q', 'C-q'], (ch, key) => {
cancellations.runAll();
process.exit(0);
});
let server;
if (process.env.KUBERNETES_SERVICE_HOST && process.env.KUBERNETES_SERVICE_PORT) {
const host = process.env.KUBERNETES_SERVICE_HOST;
const port = process.env.KUBERNETES_SERVICE_PORT;
const ca = fs.readFileSync('/var/run/secrets/kubernetes.io/serviceaccount/ca.crt');
const token = fs.readFileSync('/var/run/secrets/kubernetes.io/serviceaccount/token');
server = Context.getBaseMasterApi(`https://${host}:${port}`);
server.ca = ca;
server.headers = {
Authorization : `Bearer ${token.toString('ascii')}`,
};
}
new Kubebox(screen, server);