WIP: feat: add Hetzner deployment example

- Added a new example demonstrating deployment on Hetzner using the `tfgrid3deployer`.
- The example creates a VM and adds a webname.

Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com>
This commit is contained in:
2025-01-27 18:55:01 +02:00
parent ca8799af39
commit f8d675dcaf

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env -S v -gc none -no-retry-compilation -d use_openssl -enable-globals -cg run
//#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals -cg run
import freeflowuniverse.herolib.threefold.gridproxy
import freeflowuniverse.herolib.threefold.tfgrid3deployer
import freeflowuniverse.herolib.installers.threefold.griddriver
import os
import time
griddriver.install()!
v := tfgrid3deployer.get()!
println('cred: ${v}')
deployment_name := 'herzner_dep'
mut deployment := tfgrid3deployer.new_deployment(deployment_name)!
// TODO: find a way to filter hetzner nodes
deployment.add_machine(
name: 'hetzner_vm'
cpu: 1
memory: 2
planetary: false
public_ip4: true
size: 10 // 10 gig
mycelium: tfgrid3deployer.Mycelium{}
)
deployment.deploy()!
vm1 := deployment.vm_get('hetzner_vm')!
println('vm1 info: ${vm1}')
vm1_public_ip4 := vm1.public_ip4.all_before('/')
deployment.add_webname(name: 'gwtohetzner', backend: 'http://${vm1_public_ip4}:80')
deployment.deploy()!
gw1 := deployment.webname_get('gwtohetzner')!
println('gw info: ${gw1}')