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

Implement support for global default.yaml and override.yaml configs #436

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

jandubois
Copy link
Member

Stored inside the _config directory, they provide defaults for all instances stored under the same LIMA_HOME. Settings from override.yaml take precedence over the instance settings themselves:

$ cat ~/.lima/_config/override.yaml
mounts:
- location: "~"
  writable: true
- location: /Volumes/ThunderBlade
  writable: true

networks:
- lima: shared

This make the home mount writable, adds a second mount point (because I have symlinks that point to an SSD array), and adds a vmnet IP address to every instance I start, without me having to modify the examples/*.yaml file when I create the instance.

The settings could have been in _config/default.yaml too, except making ~ writable wouldn't work because we make it explicitly readonly in our sample configs.

This mechanism also allows users of Rancher Desktop or Colima to modify the config of the embedded instance without worrying about getting their customizations wiped during app updates, or instance restarts.

Still needs polishing and more testing (and updating the docs), but otherwise fully functional, so please give some feedback!

@jandubois jandubois force-pushed the default-and-override branch 2 times, most recently from 224a03e to c30b563 Compare November 26, 2021 06:57
@AkihiroSuda
Copy link
Member

~/.lima/_config/override.yaml

Maybe we want to support multiple override yamls?
~/.lima/_config/override/{00-foo.yaml, 01-bar.yaml, ...}

@jandubois
Copy link
Member Author

Maybe we want to support multiple override yamls?

Can you explain the use case?

@AkihiroSuda
Copy link
Member

Maybe we want to support multiple override yamls?

Can you explain the use case?

I was thinking that splitting the override yaml into multiple files may increase readability of the yamls, but we can revisit that later.

@AkihiroSuda
Copy link
Member

Looks good after adding docs and tests.
Especially we should clarify how the default yaml and the override yaml are applied to []string fields such as .mounts and .containerd.archives.

@jandubois
Copy link
Member Author

I was thinking that splitting the override yaml into multiple files may increase readability of the yamls, but we can revisit that later.

I think the overrides or defaults will typically be very small, so splitting them into multiple files doesn't make that much sense.

The one exception would be provisioning and probe scripts. But I think a better solution for those would be to allow them to be filename references and not require them to be inlined into the YAML file. That would allow you to use a proper "shell" mode for editing them, and also enables running shellcheck against them etc.

So yeah, we can revisit later, but I don't expect that there will be a need for this.

However, what we will need eventually is a per-instance override that will be stored inside the instance directory, and can be used to store modified setting specified e.g. via limactl start alpine --set cpus=2. But this can wait until we actually have a way to modify settings during restarts.

@jandubois jandubois force-pushed the default-and-override branch 3 times, most recently from b3a7d58 to 87ddd43 Compare December 9, 2021 19:27
@jandubois jandubois marked this pull request as ready for review December 9, 2021 19:34
@jandubois
Copy link
Member Author

@AkihiroSuda PTAL, I think it is basically done now

@jandubois jandubois added this to the v0.7.5 milestone Dec 9, 2021
@jandubois
Copy link
Member Author

Sorry, pushed one more update to allow "merging" of networks using Interface as the shared key. That will allow the override.yaml to change the network type of a named interface e.g. form "shared" to "bridged".

The docs at the bottom of default.yaml feel rather verbose, but not sure how to tighten them up.

Stored inside the _config directory, they provide defaults for all
instances stored under the same LIMA_HOME. Settings from override.yaml
take precedence over the instance settings themselves.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 6ae76d8 into lima-vm:master Dec 13, 2021
@jandubois jandubois deleted the default-and-override branch January 2, 2022 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants