Skip to content

Commit

Permalink
modify ingress.yml on tenant creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabi-02 committed Jan 19, 2024
1 parent c189f8f commit 2bf187c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tenant/ingres-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- path: /()(%tenant%/.*)
pathType: ImplementationSpecific
backend:
service:
name: frontend-%tenant%
port:
number: %port%
11 changes: 11 additions & 0 deletions tenant/tenant-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ function createK8sFrontendYaml(tenant, applicationId, port, backgroundColor) {
fs.writeFileSync(`../deployement/k8s/frontend-${tenant}.yaml`, frontendTenantYaml);
}

function appendTenantToIngress(tenant, port) {
let ingressYaml = fs.readFileSync('../deployement/k8s/ingress.yaml', 'utf8');
let ingresTemplateYaml = fs.readFileSync('./ingres-template.yaml', 'utf8');
const replacements = { "%tenant%": tenant, "%port%": port };
let ingresAppendTenantYaml = ingresTemplateYaml.replace(/%\w+%/g, function(all) {
return replacements[all] || all;
});
fs.writeFileSync('../deployement/k8s/ingress.yaml', ingressYaml + "\n" + ingresAppendTenantYaml);
}

async function main() {
const tenant = prompt("Tenant name (key): ");
const port = prompt("Port: ");
Expand All @@ -91,6 +101,7 @@ async function main() {
console.log(`- Client Secret: ${clientSecret}`);
console.log();
createK8sFrontendYaml(tenant, applicationId, port, backgroundColor);
appendTenantToIngress(tenant, port);
}

main();

0 comments on commit 2bf187c

Please sign in to comment.