cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Improve ConfigDrive to store network information

Open wido opened this issue 7 years ago • 15 comments

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 avatar Oct 02 '18 15:10 wido

More information:

  • https://cloudinit.readthedocs.io/en/latest/topics/datasources/configdrive.html
  • https://cloudinit.readthedocs.io/en/latest/topics/network-config.html

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.

wido avatar Oct 02 '18 15:10 wido

@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.

rohityadavcloud avatar Oct 03 '18 12:10 rohityadavcloud

@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

wido avatar Oct 03 '18 20:10 wido

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

DaanHoogland avatar Jan 29 '20 14:01 DaanHoogland

Hi, I'd be interested as well.

NuxRo avatar May 21 '20 22:05 NuxRo

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.

wido avatar May 22 '20 08:05 wido

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

DaanHoogland avatar May 22 '20 15:05 DaanHoogland

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.

wido avatar May 23 '20 09:05 wido

@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.

svenvogel avatar May 25 '20 13:05 svenvogel

@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.

NuxRo avatar May 26 '20 09:05 NuxRo

@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.

wido avatar May 26 '20 10:05 wido

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

ccycv avatar Oct 20 '21 17:10 ccycv

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

DaanHoogland avatar Oct 21 '21 06:10 DaanHoogland

this issue is not implemented yet in 4.18.0

weizhouapache avatar Jan 11 '23 11:01 weizhouapache

Especially relevant to Edge Zones.

alexandremattioli avatar Jan 30 '23 18:01 alexandremattioli

In progress by @vishesh92 at https://github.com/apache/cloudstack/pull/9329

rohityadavcloud avatar Jul 09 '24 12:07 rohityadavcloud