Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rfc]: Add support for allowing user-defined network configuration at runtime #4764

Open
holmanb opened this issue Jan 10, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@holmanb
Copy link
Member

holmanb commented Jan 10, 2024

How the network is configured today

In many cases, manually configuring an instance's network configuration on boot is unnecessary. This is handled automatically by cloud-init in the following way:

Cloud-init automatically configures the network when a cloud image boots. To accomplish this, it provides a reasonable default network configuration to the system's network manager (systemd-networkd, NetworkManager, netplan, eni, sysconfig, etc).

In some cases, the cloud may request that the network be configured in a specific way at runtime. This allows cloud providers to support a more dynamic network environment. Cloud-init accomplishes this by setting up a temporary network to read a configuration[1] from the cloud's IMDS server. This all happens before the networking manager is started by the init system, so no service restarts or reconfiguration is necessary.

The cloud-provided configuration may be overridden by the user in the base image by modifying /etc/cloud/cloud.cfg.d/*, or in the kernel command line. This doesn't, however, allow the user to manually set the network configuration at runtime.

More details on network configuration can be found here.

Allowing user-defined network configuration at runtime

Despite cloud-init configuring networking in a way that accomplishes the users' needs in many cases, some users might wish to customize their instance with a configuration at runtime. This might be provided in the same way that users provide cloud-config user-data (perhaps as a new sub-key?).

Such a feature would be quite powerful. It would also be difficult to debug (though some clouds provide a way to "serial console" into the instance for debugging). Since some clouds expect to be able to provide dynamic configuration via cloud metadata, a user that overrides this configuration with a custom one might unexpectedly prevent the cloud from delivering the configuration that is needed to deal with a dynamic network environment. This means that if cloud-init grows the ability to allow users to provide network configuration, this would require that either 1) users are expected to know what they are doing or 2) we provide some safety net, such as the ability for the cloud-provided configuration to (optionally) merge with the user-provided configuration. At a minimum, we would have to document which clouds provide networking configuration.

Example use cases (add more in comments below please)

[1] the configuration formats[1][2] are converted (rendered)

@jsf9k
Copy link
Contributor

jsf9k commented Jan 10, 2024

@holmanb
Copy link
Member Author

holmanb commented Jan 10, 2024

Continued from the original comment in a separate issue: #4621 (comment)

It sounds like I'll have to use runcmd to edit the /etc/netplan/50-cloud-init.yaml file that cloud-init produces, then run netplan generate. Do you see any other workaround?

You probably want netplan apply actually. The command netplan generate will generate the configuration that is used by networkd/networkmanager, but won't actually configure the network. For now, this is probably the best workaround.

@holmanb
Copy link
Member Author

holmanb commented Jan 10, 2024

FWIW, I don't see anything in the AWS EC2 IMDS about DHCP.

Agreed, but in cloud-init the capability already exists to set this (via netplan / networkv2) - it's just not possible for users to set this at runtime.

jsf9k added a commit to cisagov/cool-assessment-terraform that referenced this issue Jan 10, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  This script takes care of the
modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/cool-assessment-terraform that referenced this issue Jan 10, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  There is a Python script that fixes
the DHCP4 options in the netplan configuration already generated by
cloud-init.  This cloud-init fragment simply reapplies the Netplan
configuration after the modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/cool-assessment-terraform that referenced this issue Jan 10, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
@TheRealFalcon TheRealFalcon removed the new An issue that still needs triage label Jan 11, 2024
jsf9k added a commit to cisagov/skeleton-packer that referenced this issue Jan 12, 2024
jsf9k added a commit to cisagov/cool-assessment-terraform that referenced this issue Jan 12, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/openvpn-server-tf-module that referenced this issue Jan 12, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  This script takes care of the
modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/openvpn-server-tf-module that referenced this issue Jan 12, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  There is a Python script that fixes
the DHCP4 options in the netplan configuration already generated by
cloud-init.  This cloud-init fragment simply reapplies the Netplan
configuration after the modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/openvpn-server-tf-module that referenced this issue Jan 12, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/openvpn-server-tf-module that referenced this issue Feb 16, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  This script takes care of the
modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/openvpn-server-tf-module that referenced this issue Feb 16, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  There is a Python script that fixes
the DHCP4 options in the netplan configuration already generated by
cloud-init.  This cloud-init fragment simply reapplies the Netplan
configuration after the modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/openvpn-server-tf-module that referenced this issue Feb 16, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
mcdonnnj pushed a commit to cisagov/skeleton-packer that referenced this issue Mar 7, 2024
mcdonnnj pushed a commit to cisagov/skeleton-packer that referenced this issue Mar 7, 2024
jsf9k added a commit to cisagov/cool-assessment-terraform that referenced this issue Mar 12, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  This script takes care of the
modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/cool-assessment-terraform that referenced this issue Mar 12, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.  There is a Python script that fixes
the DHCP4 options in the netplan configuration already generated by
cloud-init.  This cloud-init fragment simply reapplies the Netplan
configuration after the modification.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
jsf9k added a commit to cisagov/cool-assessment-terraform that referenced this issue Mar 12, 2024
The Netplan config is created by cloud-init, but it needs to be
slightly modified and reapplied.

See these issues for more details:
- cisagov/skeleton-packer#300
- canonical/cloud-init#4764
@github-actions github-actions bot added the Stale label Sep 16, 2024
@aciba90
Copy link
Contributor

aciba90 commented Oct 1, 2024

This might be a way to fix #5249.

@aciba90 aciba90 removed the Stale label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants