-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deployment scripts for Gitea, Jenkins, Jitsi, and Nostr
- Loading branch information
1 parent
4e2fc0b
commit 0f4bdb4
Showing
4 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { FilterOptions, GatewayNameModel, MachinesModel } from "../../src"; | ||
import { config, getClient } from "../client_loader"; | ||
import { log, pingNodes } from "../utils"; | ||
|
||
async function deploy(client, vms, subdomain, gatewayNode) { | ||
const resultVM = await client.machines.deploy(vms); | ||
log("================= Deploying VM ================="); | ||
log(resultVM); | ||
log("================= Deploying VM ================="); | ||
|
||
const vmPlanetary = (await client.machines.getObj(vms.name))[0].planetary; | ||
// Name Gateway Model | ||
const gw: GatewayNameModel = { | ||
name: subdomain, | ||
node_id: gatewayNode.nodeId, | ||
tls_passthrough: false, | ||
backends: ["http://[" + vmPlanetary + "]:3000"], | ||
}; | ||
|
||
const resultGateway = await client.gateway.deploy_name(gw); | ||
log("================= Deploying name gateway ================="); | ||
log(resultGateway); | ||
log("================= Deploying name gateway ================="); | ||
} | ||
|
||
async function getDeployment(client, vms, gw) { | ||
const resultVM = await client.machines.getObj(vms.name); | ||
const resultGateway = await client.gateway.getObj(gw); | ||
log("================= Getting deployment information ================="); | ||
log(resultVM); | ||
log(resultGateway); | ||
log("https://" + resultGateway[0].domain); | ||
log("================= Getting deployment information ================="); | ||
} | ||
|
||
async function cancel(client, vms, gw) { | ||
const resultVM = await client.machines.delete(vms); | ||
const resultGateway = await client.gateway.delete_name(gw); | ||
log("================= Canceling the deployment ================="); | ||
log(resultVM); | ||
log(resultGateway); | ||
log("================= Canceling the deployment ================="); | ||
} | ||
|
||
async function main() { | ||
const name = "newgitea"; | ||
const grid3 = await getClient(`gitea/${name}`); | ||
const subdomain = "gt" + grid3.twinId + name; | ||
const instanceCapacity = { cru: 2, mru: 4, sru: 50 }; | ||
|
||
// VMNode Selection | ||
const vmQueryOptions: FilterOptions = { | ||
cru: instanceCapacity.cru, | ||
mru: instanceCapacity.mru, | ||
sru: instanceCapacity.sru, | ||
availableFor: grid3.twinId, | ||
farmId: 1, | ||
}; | ||
// GatewayNode Selection | ||
const gatewayQueryOptions: FilterOptions = { | ||
gateway: true, | ||
availableFor: grid3.twinId, | ||
}; | ||
const gatewayNode = (await grid3.capacity.filterNodes(gatewayQueryOptions))[0]; | ||
const nodes = await grid3.capacity.filterNodes(vmQueryOptions); | ||
const vmNode = await pingNodes(grid3, nodes); | ||
const domain = subdomain + "." + gatewayNode.publicConfig.domain; | ||
|
||
const vms: MachinesModel = { | ||
name, | ||
network: { | ||
name: "gitnet1", | ||
ip_range: "10.253.0.0/16", | ||
}, | ||
machines: [ | ||
{ | ||
name: "gitea1", | ||
node_id: vmNode, | ||
disks: [ | ||
{ | ||
name: "gitDisk", | ||
size: instanceCapacity.sru, | ||
mountpoint: "/mnt/data", | ||
}, | ||
], | ||
planetary: true, | ||
public_ip: false, | ||
public_ip6: false, | ||
mycelium: true, | ||
cpu: instanceCapacity.cru, | ||
memory: 1024 * instanceCapacity.mru, | ||
rootfs_size: 0, | ||
flist: "https://hub.grid.tf/tf-official-apps/gitea-mycelium.flist", | ||
entrypoint: "/sbin/zinit init", | ||
env: { | ||
SSH_KEY: config.ssh_key, | ||
GITEA__HOSTNAME: domain, | ||
GITEA__mailer__PROTOCOL: "smtp", | ||
GITEA__mailer__ENABLED: "true", | ||
GITEA__mailer__HOST: "smtp.example.com", | ||
GITEA__mailer__FROM: "[email protected]", | ||
GITEA__mailer__PORT: "587", | ||
GITEA__mailer__USER: "admin", | ||
GITEA__mailer__PASSWD: "123456", | ||
}, | ||
}, | ||
], | ||
metadata: "", | ||
description: "test deploying Gitea via ts grid3 client", | ||
}; | ||
|
||
// Deploy VMs | ||
await deploy(grid3, vms, subdomain, gatewayNode); | ||
|
||
// Get the deployment | ||
await getDeployment(grid3, vms, subdomain); | ||
|
||
// Uncomment the line below to cancel the deployment | ||
// await cancel(grid3, { name }, { name: subdomain }); | ||
|
||
await grid3.disconnect(); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { FilterOptions, GatewayNameModel, MachinesModel } from "../../src"; | ||
import { config, getClient } from "../client_loader"; | ||
import { log, pingNodes } from "../utils"; | ||
|
||
async function deploy(client, vms, subdomain, gatewayNode) { | ||
const resultVM = await client.machines.deploy(vms); | ||
log("================= Deploying VM ================="); | ||
log(resultVM); | ||
log("================= Deploying VM ================="); | ||
|
||
const vmPlanetary = (await client.machines.getObj(vms.name))[0].planetary; | ||
// Name Gateway Model | ||
const gw: GatewayNameModel = { | ||
name: subdomain, | ||
node_id: gatewayNode.nodeId, | ||
tls_passthrough: false, | ||
backends: ["http://[" + vmPlanetary + "]:80"], | ||
}; | ||
|
||
const resultGateway = await client.gateway.deploy_name(gw); | ||
log("================= Deploying name gateway ================="); | ||
log(resultGateway); | ||
log("================= Deploying name gateway ================="); | ||
} | ||
|
||
async function getDeployment(client, vms, gw) { | ||
const resultVM = await client.machines.getObj(vms.name); | ||
const resultGateway = await client.gateway.getObj(gw); | ||
log("================= Getting deployment information ================="); | ||
log(resultVM); | ||
log(resultGateway); | ||
log("https://" + resultGateway[0].domain); | ||
log("================= Getting deployment information ================="); | ||
} | ||
|
||
async function cancel(client, vms, gw) { | ||
const resultVM = await client.machines.delete(vms); | ||
const resultGateway = await client.gateway.delete_name(gw); | ||
log("================= Canceling the deployment ================="); | ||
log(resultVM); | ||
log(resultGateway); | ||
log("================= Canceling the deployment ================="); | ||
} | ||
|
||
async function main() { | ||
const name = "newjenkins"; | ||
const grid3 = await getClient(`jenkins/${name}`); | ||
const subdomain = "jk" + grid3.twinId + name; | ||
const instanceCapacity = { cru: 2, mru: 4, sru: 50 }; // Medium flavor as an example | ||
|
||
// VMNode Selection | ||
const vmQueryOptions: FilterOptions = { | ||
cru: instanceCapacity.cru, | ||
mru: instanceCapacity.mru, | ||
sru: instanceCapacity.sru, | ||
availableFor: grid3.twinId, | ||
farmId: 1, | ||
}; | ||
// GatewayNode Selection | ||
const gatewayQueryOptions: FilterOptions = { | ||
gateway: true, | ||
availableFor: grid3.twinId, | ||
}; | ||
const gatewayNode = (await grid3.capacity.filterNodes(gatewayQueryOptions))[0]; | ||
const nodes = await grid3.capacity.filterNodes(vmQueryOptions); | ||
const vmNode = await pingNodes(grid3, nodes); | ||
const domain = subdomain + "." + gatewayNode.publicConfig.domain; | ||
|
||
const vms: MachinesModel = { | ||
name, | ||
network: { | ||
name: "jknet", | ||
ip_range: "10.254.0.0/16", | ||
}, | ||
machines: [ | ||
{ | ||
name: "jenkins", | ||
node_id: vmNode, | ||
disks: [ | ||
{ | ||
name: "jkDisk", | ||
size: instanceCapacity.sru, | ||
mountpoint: "/mnt/data", | ||
}, | ||
], | ||
planetary: true, | ||
public_ip: false, | ||
public_ip6: false, | ||
mycelium: true, | ||
cpu: instanceCapacity.cru, | ||
memory: 1024 * instanceCapacity.mru, | ||
rootfs_size: 0, | ||
flist: "https://hub.grid.tf/tf-official-apps/jenkins-latest.flist", | ||
entrypoint: "/sbin/zinit init", | ||
env: { | ||
SSH_KEY: config.ssh_key, | ||
JENKINS_HOSTNAME: domain, | ||
JENKINS_ADMIN_USERNAME: "admin", // Default username | ||
JENKINS_ADMIN_PASSWORD: "12345678", // Default password | ||
}, | ||
}, | ||
], | ||
metadata: "", | ||
description: "test deploying Jenkins via ts grid3 client", | ||
}; | ||
|
||
// Deploy VMs | ||
await deploy(grid3, vms, subdomain, gatewayNode); | ||
|
||
// Get the deployment | ||
await getDeployment(grid3, vms, subdomain); | ||
|
||
// Uncomment the line below to cancel the deployment | ||
// await cancel(grid3, { name }, { name: subdomain }); | ||
|
||
await grid3.disconnect(); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { FilterOptions, GatewayNameModel, MachinesModel } from "../../src"; | ||
import { config, getClient } from "../client_loader"; | ||
import { log, pingNodes } from "../utils"; | ||
|
||
async function deploy(client, vms, subdomain, gatewayNode) { | ||
const resultVM = await client.machines.deploy(vms); | ||
log("================= Deploying VM ================="); | ||
log(resultVM); | ||
log("================= Deploying VM ================="); | ||
|
||
const vmPlanetary = (await client.machines.getObj(vms.name))[0].planetary; | ||
// Name Gateway Model | ||
const gw: GatewayNameModel = { | ||
name: subdomain, | ||
node_id: gatewayNode.nodeId, | ||
tls_passthrough: false, | ||
backends: ["http://[" + vmPlanetary + "]:80"], | ||
}; | ||
|
||
const resultGateway = await client.gateway.deploy_name(gw); | ||
log("================= Deploying name gateway ================="); | ||
log(resultGateway); | ||
log("================= Deploying name gateway ================="); | ||
} | ||
|
||
async function getDeployment(client, vms, gw) { | ||
const resultVM = await client.machines.getObj(vms.name); | ||
const resultGateway = await client.gateway.getObj(gw); | ||
log("================= Getting deployment information ================="); | ||
log(resultVM); | ||
log(resultGateway); | ||
log("https://" + resultGateway[0].domain); | ||
log("================= Getting deployment information ================="); | ||
} | ||
|
||
async function cancel(client, vms, gw) { | ||
const resultVM = await client.machines.delete(vms); | ||
const resultGateway = await client.gateway.delete_name(gw); | ||
log("================= Canceling the deployment ================="); | ||
log(resultVM); | ||
log(resultGateway); | ||
log("================= Canceling the deployment ================="); | ||
} | ||
|
||
async function main() { | ||
const name = "newjitsi"; | ||
const grid3 = await getClient(`jitsi/${name}`); | ||
const subdomain = "jt" + grid3.twinId + name; | ||
const instanceCapacity = { cru: 2, mru: 4, sru: 50 }; // Update the instance capacity values according to your requirements. | ||
|
||
// VMNode Selection | ||
const vmQueryOptions: FilterOptions = { | ||
cru: instanceCapacity.cru, | ||
mru: instanceCapacity.mru, | ||
sru: instanceCapacity.sru, | ||
availableFor: grid3.twinId, | ||
farmId: 1, | ||
}; | ||
// GatewayNode Selection | ||
const gatewayQueryOptions: FilterOptions = { | ||
gateway: true, | ||
availableFor: grid3.twinId, | ||
}; | ||
const gatewayNode = (await grid3.capacity.filterNodes(gatewayQueryOptions))[0]; | ||
const nodes = await grid3.capacity.filterNodes(vmQueryOptions); | ||
const vmNode = await pingNodes(grid3, nodes); | ||
const domain = subdomain + "." + gatewayNode.publicConfig.domain; | ||
|
||
const vms: MachinesModel = { | ||
name, | ||
network: { | ||
name: "jitnet", | ||
ip_range: "10.251.0.0/16", | ||
}, | ||
machines: [ | ||
{ | ||
name: "jitsi", | ||
node_id: vmNode, | ||
disks: [ | ||
{ | ||
name: "jitDisk", | ||
size: instanceCapacity.sru, | ||
mountpoint: "/mnt/data", | ||
}, | ||
], | ||
planetary: true, | ||
public_ip: false, | ||
public_ip6: false, | ||
mycelium: true, | ||
cpu: instanceCapacity.cru, | ||
memory: 1024 * instanceCapacity.mru, | ||
rootfs_size: 0, | ||
flist: "https://hub.grid.tf/tf-official-apps/jitsi-latest.flist", | ||
entrypoint: "/sbin/zinit init", | ||
env: { | ||
SSH_KEY: config.ssh_key, | ||
JITSI_HOSTNAME: domain, | ||
}, | ||
}, | ||
], | ||
metadata: "", | ||
description: "test deploying Jitsi via ts grid3 client", | ||
}; | ||
|
||
// Deploy VMs | ||
await deploy(grid3, vms, subdomain, gatewayNode); | ||
|
||
// Get the deployment | ||
await getDeployment(grid3, vms, subdomain); | ||
|
||
// Uncomment the line below to cancel the deployment | ||
// await cancel(grid3, { name }, { name: subdomain }); | ||
|
||
await grid3.disconnect(); | ||
} | ||
|
||
main(); |
Oops, something went wrong.