Skip to content

Commit

Permalink
Update express-app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotxkim authored Nov 17, 2018
1 parent c530511 commit 96c4010
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/server/express-app.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
// require statements
const express = require('express');
const app = require('express')
const app = express();
const bodyParser = require('body-parser');
const path = require('path');

// k8s javascript client require
const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();

/* Core_v1Api docs: https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/CoreV1Api.md */
// core_v1api -- pods, services (may include nodeport, loadbalancer)
// optional: serviceaccount, resourcequota, replication controller if needed
const k8sApi = kc.makeApiClient(k8s.Core_v1Api);

/* Extensions_v1beta1Api docs: https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/ExtensionsV1beta1Api.md */
// extensions_v1beta1api -- ingress, deployment
// optional: daemonset, and network policy as well as replica set if needed
const k8sApi2 = kc.makeApiClient(k8s.Extensions_v1beta1Api);

const path = require('path');
// Other Lists:
// AppsV1beta1Api: https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/AppsV1beta1Api.md
// - statefulset;

// use statements
app.use(bodyParser.json());
Expand Down Expand Up @@ -70,5 +82,12 @@ app.get('/deployment', (req, res) => {
})
});

app.get('/daemonset', (req, res) => {
k8sApi2.listNamespacedDaemonSet('default')
.then((re) => {
res.json(re.body);
});
});


module.exports = app
module.exports = app

0 comments on commit 96c4010

Please sign in to comment.