Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment scripts for Gitea, Jenkins, Jitsi, and Nostr #3689

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions packages/grid_client/scripts/applications/gitea.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a Gateway Timeout when trying to access an instance deployed from with the script https://gt79newgitea.gent01.dev.grid.tf , https://gt79newgitea2.gent01.dev.grid.tf/
while everything works fine when deploying from the dashboard https://gt79gtett7l.gent01.dev.grid.tf/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will check the scripts and try the deployment again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed resolve but it only works with public ip

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
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 GatewayIP = (await client.machines.getObj(vms.name))[0].publicIP;

Check warning on line 11 in packages/grid_client/scripts/applications/gitea.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'GatewayIP' is assigned a value but never used

// Name Gateway Model
const gw: GatewayNameModel = {
name: subdomain,
node_id: gatewayNode.nodeId,
tls_passthrough: false,
backends: [`http://[${VMmyceliumIP}]:3000`],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in an error since you removed VMmyceliumIP

};

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) {

Check warning on line 37 in packages/grid_client/scripts/applications/gitea.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'cancel' is defined but never used
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${Math.random().toString(36).substring(2, 8)}`;
const networkName = `net${Math.random().toString(36).substring(2, 8)}`;
const grid3 = await getClient(`gitea/${name}`);
const instanceCapacity = { cru: 2, mru: 4, sru: 50 };
const subdomain = `gt${grid3.twinId}${name}${Math.random().toString(36).substring(2, 6)}`;

// 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: networkName,
ip_range: "10.253.0.0/16",
},
machines: [
{
name: `vm${Math.random().toString(36).substring(2, 8)}`,
node_id: vmNode,
disks: [
{
name: `disk${Math.random().toString(36).substring(2, 8)}`,
size: instanceCapacity.sru,
mountpoint: "/mnt/data",
},
],
planetary: true,
public_ip: true,
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", // Optional: SMTP Configuration
// GITEA__mailer__ENABLED: "false", // Set to true if enabling mail server
// GITEA__mailer__HOST: "smtp.example.com",
// GITEA__mailer__FROM: "[email protected]",
// GITEA__mailer__PORT: "587",
// GITEA__mailer__USER: "admin",
// GITEA__mailer__PASSWD: "password123",
},
},
],
metadata: "",
description: "Deploying Gitea via TS Grid3 client",
};

// Deploy VMs
await deploy(grid3, vms, subdomain, gatewayNode);

// Get the deployment
await getDeployment(grid3, vms, subdomain);

// Uncomment to cancel the deployment
// await cancel(grid3, { name }, { name: subdomain });

await grid3.disconnect();
}

main();
119 changes: 119 additions & 0 deletions packages/grid_client/scripts/applications/jenkins.ts
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();
117 changes: 117 additions & 0 deletions packages/grid_client/scripts/applications/jitsi.ts
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();
Loading
Loading