commit fix
This commit is contained in:
54
generate.py
Normal file
54
generate.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
BASE_IP = "192.168.20"
|
||||
START = 10
|
||||
COUNT = 5
|
||||
|
||||
CPU = 2
|
||||
MEMORY = 2048
|
||||
GATEWAY = "192.168.20.1"
|
||||
|
||||
def generate():
|
||||
print("locals {")
|
||||
print(" nodes = {")
|
||||
|
||||
for i in range(COUNT):
|
||||
idx = i + 1
|
||||
last_octet = START + i
|
||||
|
||||
if last_octet > 254:
|
||||
raise ValueError("IP overflow")
|
||||
|
||||
ip = f"{BASE_IP}.{last_octet}"
|
||||
comma = "," if i < COUNT - 1 else ""
|
||||
|
||||
print(f""" k8s-worker-{idx} = {{
|
||||
index = {idx}
|
||||
cpu = {CPU}
|
||||
memory = {MEMORY}
|
||||
|
||||
disks = [
|
||||
{{
|
||||
datastore = "ssd2"
|
||||
interface = "scsi0"
|
||||
size = 20
|
||||
import_from = "local:import/ubuntu-24.qcow2"
|
||||
}}
|
||||
]
|
||||
|
||||
network_devices = [
|
||||
{{
|
||||
bridge = "vmbr0"
|
||||
vlan_id = 20
|
||||
ip = "{ip}"
|
||||
cidr = 24
|
||||
gateway = "{GATEWAY}"
|
||||
}}
|
||||
]
|
||||
}}{comma}""")
|
||||
|
||||
print(" }")
|
||||
print("}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate()
|
||||
Reference in New Issue
Block a user