nanovms / ops

ops - build and run nanos unikernels
https://ops.city
MIT License
1.27k stars 132 forks source link

Added some configurable options for ProxMox API via CloudConfig #1370

Closed asyslinux closed 2 years ago

asyslinux commented 2 years ago

1356 - Had some questions

  1. Added full support of configurable options (CloudConfig) with backward compatibility:

Arch (Not work correctly through ProxMox API, but may be need later for other Clouds) (default: "" ; autodetect by ProxMox) Machine (Not used if empty) (default: "" ; autodetect by ProxMox) Sockets (default: "1") Cores (default: "1") Numa (default: "0") Memory (default: "512M") BridgeName (BridgeName0) (default: "vmbr0") BridgeName1 (default: "") (Not used yet) IsoStorageName (default: "local") StorageName (default: "local-lvm") Onboot (default: "0") Protection (default: "0")

  1. Added support for timestamps in instance names (if not used -i argument from command line).
  2. Also fixed and extended some checks.
  3. Added import dep of "github.com/docker/go-units" in proxmox/proxmox_instance.go for converting human-readable M,G memory settings to bytes for ProxMox

Short example of configuration file:

{
    "Dirs": ["static"],
    "NameServers": ["172.21.1.1"],
    "CloudConfig": {
        "BridgeName": "vmbr0",
        "ImageName": "mytest",
        "IsoStorageName": "local",
        "StorageName": "local-lvm"
    },
    "RunConfig": {
        "Accel": true,
        "InstanceName": "mytest",
        "ImageName": "mytest",
        "IPAddress": "172.21.1.75",
        "NetMask": "255.255.255.0",
        "Gateway": "172.21.1.1",
        "Verbose": true,
        "ShowErrors": true,
        "ShowWarnings": true
    }
}

Full example of configuration file:

{
    "Dirs": ["static"],
    "NameServers": ["172.21.1.1"],
    "CloudConfig": {
        "Arch": "x86_64",
        "Machine": "q35",
        "Sockets": 2,
        "Cores": 4,
        "Numa": true,
        "Memory": "4096M",
        "BridgeName0": "vmbr0",
        "ImageName": "mytest",
        "IsoStorageName": "local",
        "StorageName": "local-lvm",
        "Protection": false,
        "Onboot": true
    },
    "RunConfig": {
        "Accel": true,
        "InstanceName": "mytest",
        "ImageName": "mytest",
        "IPAddress": "172.21.1.75",
        "NetMask": "255.255.255.0",
        "Gateway": "172.21.1.1",
        "Verbose": true,
        "ShowErrors": true,
        "ShowWarnings": true
    }
}

Now with fully customizable base options, you can already normally use ops with ProxMox. It may be necessary to add some more options to the command line arguments, but this is after agreement with the Author of ops utility.

eyberg commented 2 years ago

so we now have 15 different infrastructure targets, i think it'd be best if cloudconfig/runconfig remain as generic as possible (eg: a given var should be more or less equal across target platforms), open to suggestion on this but kinda wondering if it might make sense to introduce optional platform specific config

we could provide a new interface that supplies custom config pertinent to each platform

for example all for these (which don't have equivalents in other platforms):

BridgeName (BridgeName0) (default: "vmbr0")
IsoStorageName (default: "local")
StorageName (default: "local-lvm")
Onboot (default: "0")
Protection (default: "0")

could all be a part of a proxmox specific config so we don't pollute all the other platform's config

asyslinux commented 2 years ago

so we now have 15 different infrastructure targets, i think it'd be best if cloudconfig/runconfig remain as generic as possible (eg: a given var should be more or less equal across target platforms), open to suggestion on this but kinda wondering if it might make sense to introduce optional platform specific config

we could provide a new interface that supplies custom config pertinent to each platform

for example all for these (which don't have equivalents in other platforms):

Are you mean like this? Ok, i will try to add separate ProxmoxConfig part, please wait a little, but this is broke backward compatibility:

{
    "Dirs": ["static"],
    "NameServers": ["172.21.1.1"],
    "CloudConfig": {
        "ImageName": "mytest",
        "Arch": "x86_64",
        "Machine": "q35",
        "Sockets": 2,
        "Cores": 4,
        "Numa": true,
        "Memory": "4096M"
    },
    "ProxmoxConfig": {
        "BridgeName0": "vmbr0",
        "IsoStorageName": "local",
        "StorageName": "local-lvm",
        "Protection": false,
        "Onboot": true
    },
    "RunConfig": {
        "Accel": true,
        "InstanceName": "mytest",
        "ImageName": "mytest",
        "IPAddress": "172.21.1.75",
        "NetMask": "255.255.255.0",
        "Gateway": "172.21.1.1",
        "Verbose": true,
        "ShowErrors": true,
        "ShowWarnings": true
    }
}
asyslinux commented 2 years ago

I changed the code as you indicated. If You prefer to move other options to ProxmoxConfig, please say me.

Now configuration files is like as: Full example of configuration file:

{
    "Dirs": ["static"],
    "NameServers": ["172.21.1.1"],
    "CloudConfig": {
        "ImageName": "mytest",
        "Arch": "x86_64",
        "Machine": "q35",
        "Sockets": 2,
        "Cores": 4,
        "Numa": true,
        "Memory": "4096M"
    },
    "ProxmoxConfig": {
        "BridgeName0": "vmbr0",
        "IsoStorageName": "local",
        "StorageName": "local-lvm",
        "Protection": false,
        "Onboot": true
    },
    "RunConfig": {
        "Accel": true,
        "InstanceName": "mytest",
        "ImageName": "mytest",
        "IPAddress": "172.21.1.75",
        "NetMask": "255.255.255.0",
        "Gateway": "172.21.1.1",
        "Verbose": true,
        "ShowErrors": true,
        "ShowWarnings": true
    }
}

Short example of configuration file:

{
    "Dirs": ["static"],
    "NameServers": ["172.21.1.1"],
    "CloudConfig": {
        "ImageName": "mytest"
    },
    "ProxmoxConfig": {
        "BridgeName": "vmbr0",
        "IsoStorageName": "local",
        "StorageName": "local-lvm"
    },
    "RunConfig": {
        "Accel": true,
        "InstanceName": "mytest",
        "ImageName": "mytest",
        "IPAddress": "172.21.1.75",
        "NetMask": "255.255.255.0",
        "Gateway": "172.21.1.1",
        "Verbose": true,
        "ShowErrors": true,
        "ShowWarnings": true
    }
}
eyberg commented 2 years ago

chatted offline - closing in favor of https://github.com/nanovms/ops/pull/1373