orchestrator changes

This commit is contained in:
Ishaan Dey
2024-05-13 14:32:15 -07:00
parent aef8105bb0
commit eb629835d2
7 changed files with 879 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@google-cloud/container": "^5.12.0",
"@kubernetes/client-node": "^0.21.0",
"cors": "^2.8.5",
"dotenv": "^16.4.5",

View File

@ -76,7 +76,7 @@ spec:
name: <SANDBOX>
port:
number: 4000
- host: <SANDBOX>.s.ishaand.com
- host: <SANDBOX>.sandbox.ishaand.com
http:
paths:
- path: /

View File

@ -12,12 +12,14 @@ import {
NetworkingV1Api,
} from "@kubernetes/client-node"
import { z } from "zod"
import container from '@google-cloud/container';
const app = express()
const port = process.env.PORT || 4001
app.use(express.json())
dotenv.config()
// const corsOptions = {
// origin: ['http://localhost:3000', 'https://s.ishaand.com', 'http://localhost:4000', /\.ws\.ishaand\.com$/],
// }
@ -105,6 +107,26 @@ app.post("/test", async (req, res) => {
app.post("/start", async (req, res) => {
const { sandboxId } = dataSchema.parse(req.body)
async function main() {
const client = new container.v1.ClusterManagerClient();
async function quickstart() {
const zone = 'us-central1-a';
const projectId = await client.getProjectId();
const request = {
projectId: projectId,
zone: zone,
};
const [response] = await client.listClusters(request);
console.log('Clusters: ', response);
}
quickstart();
}
main().catch(console.error);
try {
console.log("Creating resources for sandbox", sandboxId)