31 lines
794 B
JavaScript
31 lines
794 B
JavaScript
const exec = require('await-exec')
|
|
const express = require('express')
|
|
const app = express()
|
|
const port = 2344
|
|
|
|
const name = "cscclassprofilestaging"
|
|
const image = "registry.cloud.csclub.uwaterloo.ca/snedadah/csc-class-profile-staging"
|
|
|
|
app.get('/cscclassprofilestaging', async (req, res) => {
|
|
await call(`kubectl delete deployment ${name}`);
|
|
|
|
await call(`kubectl create deployment ${name} --image ${image} --port=80`);
|
|
await call(`kubectl expose deployment ${name}`);
|
|
await call(`kubectl create ingress ${name} --rule='${name}-snedadah.k8s.csclub.cloud/*=${name}:80'`);
|
|
|
|
res.send('Hello World!')
|
|
})
|
|
|
|
async function call(cmd){
|
|
let out
|
|
try{
|
|
out = await exec(cmd);
|
|
}catch(e)
|
|
{
|
|
console.log(e, out)
|
|
}
|
|
}
|
|
app.listen(port, () => {
|
|
console.log(`Example app listening on port ${port}`)
|
|
})
|