apache / cloudstack

Apache CloudStack is an opensource Infrastructure as a Service (IaaS) cloud computing platform
https://cloudstack.apache.org/
Apache License 2.0
1.84k stars 1.07k forks source link

Improve ConfigDrive to store network information #2872

Open wido opened 5 years ago

wido commented 5 years ago

ConfigDrive / cloud-init supports a network_data.json file which can contain network information for a VM.

By providing the network information using ConfigDrive to a VM we can eliminate the need for DHCP and thus the Virtual Router in some use-cases.

An example JSON file:

{
    "links": [
        {
            "ethernet_mac_address": "52:54:00:0d:bf:93",
            "id": "eth0",
            "mtu": 1500,
            "type": "phy"
        }
    ],
    "networks": [
        {
            "id": "eth0",
            "ip_address": "192.168.200.200",
            "link": "eth0",
            "netmask": "255.255.255.0",
            "network_id": "dacd568d-5be6-4786-91fe-750c374b78b4",
            "routes": [
                {
                    "gateway": "192.168.200.1",
                    "netmask": "0.0.0.0",
                    "network": "0.0.0.0"
                }
            ],
            "type": "ipv4"
        },
        {
            "id": "eth0",
            "ip_address": "2001:db8:100::1337",
            "link": "eth0",
            "netmask": "64",
            "network_id": "dacd568d-5be6-4786-91fe-750c374b78b4",
            "routes": [
                {
                    "gateway": "2001:db8:100::1",
                    "netmask": "0",
                    "network": "::"
                }
            ],
            "type": "ipv6"
        }
    ],
    "services": [
        {
            "address": "8.8.8.8",
            "type": "dns"
        }
    ]
}

In Basic Networking and Advanced Networking zones which are using a shared network you wouldn't require a VR anymore.

wido commented 5 years ago

More information:

I tested this with this cloud-init configuration under Ubuntu 18.04

root@ubuntu-test:~# cat /etc/cloud/cloud.cfg.d/99_cloudstack.cfg 
system_info:
  default_user:
    name: root
  package_mirrors:
    - arches: [i386, amd64]
      failsafe:
        primary: http://ubuntu.apt-get.eu/ubuntu
        security: http://security.ubuntu.apt-get.eu/ubuntu

disable_root: false

cloud_config_modules:
 - emit_upstart
 - snap_config
 - ssh-import-id
 - locale
 - [ set-passwords, always ]
 - grub-dpkg
 - apt-pipelining
 - apt-configure
 - ntp
 - timezone
 - disable-ec2-metadata
 - runcmd
 - byobu

datasource:
  None: {}
datasource_list:
  - ConfigDrive
root@ubuntu-test:~#

Files on the CD-Rom:

root@ubuntu-test:~# find /mnt/cdrom/
/mnt/cdrom/
/mnt/cdrom/openstack
/mnt/cdrom/openstack/latest
/mnt/cdrom/openstack/latest/meta_data.json
/mnt/cdrom/openstack/latest/network_data.json
root@ubuntu-test:~#

I generated this ISO manually on a non-CloudStack environment to test it, but we could store all the network information we have from a VM inside the ConfigDrive.

rohityadavcloud commented 5 years ago

@wido yes ideally that's the use of config drive feature. I would see this as a bug, if currently it's not possible to share/send the network (ip and dns) currently. If you do decide to implement the fix, please open PR for 4.11 branch.

wido commented 5 years ago

@rhtyd Yes, it would be great! It would allow for much larger scaling without the need of DHCP. That removes the VR in many use-cases.

I haven't got ConfigDrive to work yet (offerings which wouldn't work...), but from the code I saw it only generates a empty network_data.json file.

Happy to work on this and write against 4.11

DaanHoogland commented 4 years ago

no milestones and no related PRs is this resolved or being worked on?

NuxRo commented 4 years ago

Hi, I'd be interested as well.

wido commented 4 years ago

This is still interesting. But @GabrielBrascher and me have been working on other things and haven't been able to give this more attention.

With this (as mentioned) there would be no need for a Virtual Router in many cases.

DaanHoogland commented 4 years ago

but no milestone to put to it still, @wido ?

wido commented 4 years ago

Not yet @DaanHoogland. I'd like to keep this open for future reference. Might be that somebody else wants to pick this up before we have time.

svenvogel commented 4 years ago

@wido is there any idea how you plan to implement this without a virtual router. this will be interesting for us because of the future use of TF we will lost the VR.

NuxRo commented 4 years ago

@svenvogel Not sure if this is what you are asking, but the DHCP server would not longer be needed as the IP addressing details will be supplied to the VM via the configdrive ISO, cloud-init/scripts will read them and do the rest of the config.

wido commented 4 years ago

@svenvogel and @NuxRo Indeed. With ConfigDrive and network information there is no more need for a DHCP server (thus Virtual Router) in a network.

From the local drive cloud-init can fetch all the required network information and configure the network interface accordingly.

ccycv commented 2 years ago

Was this tested in cloudstack 4.15.x? Should work or it was not implement yet?

DaanHoogland commented 2 years ago

@ccycv, it is not implemented and no plans to implement it are out there (hence the milestone 'unplanned';).

weizhouapache commented 1 year ago

this issue is not implemented yet in 4.18.0

alexandremattioli commented 1 year ago

Especially relevant to Edge Zones.