-
Notifications
You must be signed in to change notification settings - Fork 8
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
khaledyoussef24
wants to merge
5
commits into
development
Choose a base branch
from
development_adding-application-scripts
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+480
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0f4bdb4
Add deployment scripts for Gitea, Jenkins, Jitsi, and Nostr
khaledyoussef24 9e85413
fixed jitsi and nostr
khaledyoussef24 4c9e99d
fixes for gitea
khaledyoussef24 524a2d5
randomize name generation fixing gateway creation
khaledyoussef24 c256363
using public ip for gitea
khaledyoussef24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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; | ||
|
||
// Name Gateway Model | ||
const gw: GatewayNameModel = { | ||
name: subdomain, | ||
node_id: gatewayNode.nodeId, | ||
tls_passthrough: false, | ||
backends: [`http://[${VMmyceliumIP}]:3000`], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
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(); |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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/
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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