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

Doc: Better DNS persistence solution for systemd #14589

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kkovacs
Copy link

@kkovacs kkovacs commented Dec 5, 2024

Amended documentation with a better way to setup DNS-resolving LXD containers from the host machine.

This is a re-submit of #14572 .

@github-actions github-actions bot added the Documentation Documentation needs updating label Dec 5, 2024
@kkovacs
Copy link
Author

kkovacs commented Dec 5, 2024

Hi @simondeziel and @tomponline , I've re-submitted the PR as you asked.

I've added information regarding the situation Simon has encountered, and also opened #14588 , because lxdbr0 not being in a managed state is an issue that needs to be handled separately, not in this documentation snippet (even if I've added a workaround here).

@kkovacs kkovacs marked this pull request as ready for review December 5, 2024 17:50
@simondeziel
Copy link
Member

@kkovacs If the existing .service hack doesn't work reliably on its own we might need to add something (udev rules?) to restart the service whenever the network device itself is changed.

@kkovacs
Copy link
Author

kkovacs commented Dec 5, 2024

I'm not very familiar with udev configuration. :) The .network file should be the correct solution IMHO; the one-shot service – even if somehow fortified by udev rules – is many more "rubber balls" on each other, and feels more hack-ish.

The .network solution is robust, and it would work immediately if the bridge was not out of sight for systemd-networkd after install. This temporary situation could easily cause other issues too, which are yet unknown.

But of course, it's up to the LXD project how to do this. I would be most happier if resolving the lxd-container-name.lxd names from the host would just work out of the box, and would not need a post-install snippet :)

doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
@tomponline tomponline requested a review from minaelee December 9, 2024 15:55
@tomponline
Copy link
Member

Please sign the CLA https://ubuntu.com/legal/contributors/agreement

@tomponline
Copy link
Member

Please can you also rebase as main has fixes for some linter issues that are blocking the tests.

@kkovacs kkovacs force-pushed the documentation-systemd-dns-network branch from 50cc98f to cd26ca4 Compare December 9, 2024 21:00
@kkovacs
Copy link
Author

kkovacs commented Dec 9, 2024

Please sign the CLA

I did!

Please can you also rebase as main has fixes for some linter issues that are blocking the tests.

I did :)

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomponline
Copy link
Member

The CLA check is failing with

  • user@kk-e1 ✕ (has no Launchpad account)

…ntainers from the host machine.

Signed-off-by: Kristof Kovacs <[email protected]>
@kkovacs kkovacs force-pushed the documentation-systemd-dns-network branch from cd26ca4 to 878d2a5 Compare December 10, 2024 16:29
@kkovacs
Copy link
Author

kkovacs commented Dec 10, 2024

Signed off, removed "apparently", fixed "author", rebased, pushed. Fingers crossed. :)

@tomponline
Copy link
Member

DCO and CLA check are good :)

@tomponline
Copy link
Member

@minaelee happy with this?

tomponline
tomponline previously approved these changes Dec 10, 2024
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
@tomponline tomponline changed the title Better DNS persistence solution for systemd (resubmit) Doc: Better DNS persistence solution for systemd Dec 11, 2024
Co-authored-by: Minae Lee <[email protected]>
Signed-off-by: K Kovács <[email protected]>
@kkovacs
Copy link
Author

kkovacs commented Dec 11, 2024

Thank you @minaelee! It's incredible how much clearer you have made the text. Kudos!

@@ -72,7 +72,70 @@ You must repeat the commands after each reboot and after LXD is restarted, or ma

You can automate the `systemd-resolved` DNS configuration, so that it is applied on system start and takes effect when LXD creates the network interface.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can automate the `systemd-resolved` DNS configuration, so that it is applied on system start and takes effect when LXD creates the network interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is repeated in line 75

@@ -72,7 +72,70 @@ You must repeat the commands after each reboot and after LXD is restarted, or ma

You can automate the `systemd-resolved` DNS configuration, so that it is applied on system start and takes effect when LXD creates the network interface.

To do so, create a `systemd` unit file named `/etc/systemd/system/lxd-dns-<network_bridge>.service` with the following content:
You can automate the systemd-resolved DNS configuration so that it is applied on system start and takes effect when LXD creates the network interface. To do so, there are two approaches you can take, detailed below. Use only one of the approaches.
Copy link
Contributor

@minaelee minaelee Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can automate the systemd-resolved DNS configuration so that it is applied on system start and takes effect when LXD creates the network interface. To do so, there are two approaches you can take, detailed below. Use only one of the approaches.
There are two approaches to automating `systemd-resolved` configuration to ensure that it persists when the LXD bridge network is re-created. Use only one of these approaches, described below.

To do so, create a `systemd` unit file named `/etc/systemd/system/lxd-dns-<network_bridge>.service` with the following content:
You can automate the systemd-resolved DNS configuration so that it is applied on system start and takes effect when LXD creates the network interface. To do so, there are two approaches you can take, detailed below. Use only one of the approaches.

The first approach is recommended as more resilient; it is reapplied if the lxdbr0 network is re-created at any point. For example, updating and restarting LXD can occasionally cause the lxdbr0 network to be recreated.
Copy link
Contributor

@minaelee minaelee Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The first approach is recommended as more resilient; it is reapplied if the lxdbr0 network is re-created at any point. For example, updating and restarting LXD can occasionally cause the lxdbr0 network to be recreated.
The first approach is recommended because it is more resilient. It applies your desired configuration whenever your system is rebooted, _and_ whenever the LXD bridge network is re-created outside of a system reboot. For example, updating and restarting LXD can occasionally cause its bridge network to be re-created.

doc/howto/network_bridge_resolved.md Outdated Show resolved Hide resolved
Copy link
Contributor

@minaelee minaelee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested updates based on this conversation, thanks!


The first approach is recommended as more resilient; it is reapplied if the lxdbr0 network is re-created at any point. For example, updating and restarting LXD can occasionally cause the lxdbr0 network to be recreated.

If you are unable to use the recommended approach for some reason, the second alternative approach can be used. However, if the lxdbr0 network is re-created, you must reapply that solution manually.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you are unable to use the recommended approach for some reason, the second alternative approach can be used. However, if the lxdbr0 network is re-created, you must reapply that solution manually.
If you are unable to use the recommended approach, the alternative approach can be used. The alternative approach applies your desired configuration only when your system is rebooted. If LXD re-creates its bridge network outside of a system reboot, you must reapply the configuration manually.

Domains=~<dns_domain>
```

So for example, `/etc/systemd/network/lxdbr0.network` with the following content (your IP, of course):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
So for example, `/etc/systemd/network/lxdbr0.network` with the following content (your IP, of course):
Example file content for `/etc/systemd/network/lxdbr0.network` (insert your own DNS value):

```

### Alternative approach

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```{warning}
This approach only automates applying your desired configuration when your system is rebooted. If LXD re-creates its bridge network outside of a system reboot, you must reapply the configuration manually with the following command:
systemctl restart lxd-dns-<bridge_network>.service
Example:
systemctl restart lxd-dns-lxdbr0.service
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation needs updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants