-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add VM integration #346
Add VM integration #346
Conversation
85ad3a5
to
eef4b8e
Compare
eef4b8e
to
43a6034
Compare
43a6034
to
c89ff4c
Compare
Adds full integration for managing virtual machines in development via https://github.com/lima-vm/lima as an alternative to Vagrant. Lima stands for "Linux virtual machines (on macOS, in most cases)" and that's exactly our use case. Lima isn't just a replacement for Vagrant, it also replaces the VM provider like VirtualBox or Parallels too. Lima supports two ways of running guest machines: * [QEMU](https://www.qemu.org/) * macOS Virtualization.Framework ("vz") For this initial integration, we're only supporting the macOS Virtualization.Framework because it offers near-native performance, and that includes file syncing via `virtiofs`. For macOS Ventura (13.0+) users, we'll eventually recommend using trellis-cli's VM feature over Vagrant as the default since it's easier and faster. We'll look into expanding support for Linux users as well depending on performance of the file mounts on the VM. Requirements: * Intel or Apple Silicon * macOS 13 (Ventura) * Lima >= 0.14 Usage: There's 5 new commands: * `trellis vm start` * `trellis vm stop` * `trellis vm delete` * `trellis vm shell` * `trellis vm sudoers` Under the hood, those commands wrap equivalent `limactl` features. Just like the previous Vagrant integration, you can always run `limactl` directly to manage your VMs. For default use cases, `trellis vm start` can be run without any customization first. It will create a new virtual machine (using Lima) from a generated config file (`project/trellis/.trellis/lima/config/<name>.yml`). The site's `local_path` will be automatically mounted on the VM and your `/etc/hosts` file will be updated. Note: run `trellis vm sudoers -h` to make `/etc/hosts` file passwordless: ```bash $ trellis sudoers | sudo tee /etc/sudoers.d/trellis ``` Configuration: Right now configuration options for the VM are limited. The intention is to the most common use cases without any configuration needed. A trellis-cli config file (global or project level) supports a new `vm` option. The only useful config option right now is `images` (to switch between Ubuntu 20.04 and 22.04 for example). 20.04. Here's an example of specifying Jammy 22.04 for ARM (`aarch64`) only, since that's what I use): ```yml vm: images: - location: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img arch: aarch64 ```
c89ff4c
to
d3894d6
Compare
https://github.com/lima-vm/lima/releases/tag/v0.15.0 is finally out so I'm going to merge this now. Note: this is still under "experimental" status until we get more people testing it out. |
Great improvement, congrats @swalkinshaw! Following the guide above now to try this out, but quick note the command above should be: |
I didn't get this right on the first go and had to start over a few times, but I think the necessary steps are:
Just use |
Thanks @jkananen — that all totally makes sense! So adjusting the |
Yes, just like that. I changed the last digit of the IP to one that's so far not been used. |
Thank you for the testing and feedback 😄 I'll write more documentation on this feature soon including details on how to migrate or use it concurrently with Vagrant since you might run into One quick clarification: in most situations, you shouldn't need to manually edit the
|
Some replies to your questions @artshostak
If you run into that again, I'd recommend running the lima command directly. eg:
As @jkananen said, right now
Before running
I wonder if all your stability/networking issues were related 🤔 I haven't heard of any issues like that yet. I'm wondering if a reboot helped (or would have)? If you run into that situation again, it would be good to confirm networking/DNS by continously |
Correct, it's not needed. It coincided earlier with rebooting my Mac, which seems to be necessary after the first Anyone else experiencing the need for a reboot? |
What makes you need to reboot? I've had an issue before where it never got passed the SSH requirement and rebooting fixed it. |
Browser fails to load the page and finally gives up with "This site can't be reached / ERR_CONNECTION_REFUSED" |
@jkananen next time that happens it would be useful to see:
|
I'm actually having similar connection issues, but I'm not using Lima yet, but still Vagrant & Parallels on a M1 machine. When I ping the hostname at that moment in the VM with ...
64 bytes from example.test (127.0.2.1): icmp_seq=100 ttl=64 time=0.229 ms
64 bytes from example.test (127.0.2.1): icmp_seq=101 ttl=64 time=0.076 ms
64 bytes from example.test (127.0.2.1): icmp_seq=102 ttl=64 time=0.137 ms
64 bytes from example.test (127.0.2.1): icmp_seq=103 ttl=64 time=0.159 ms
... My
My
I don't know if it's related? |
Adds full integration for managing virtual machines in development via https://github.com/lima-vm/lima as an alternative to Vagrant. Lima stands for "Linux virtual machines (on macOS, in most cases)" and that's exactly our use case.
Lima isn't just a replacement for Vagrant, it also replaces the VM provider like VirtualBox or Parallels too. Lima supports two ways of running guest machines:
For this initial integration, we're only supporting the macOS Virtualization.Framework because it offers near-native performance, and that includes file syncing via
virtiofs
.For macOS Ventura (13.0+) users, we'll eventually recommend using trellis-cli's VM feature over Vagrant as the default since it's easier and faster. We'll look into expanding support for Linux users as well depending on performance of the file mounts on the VM.
Requirements:
Usage:
There's 5 new commands:
trellis vm start
trellis vm stop
trellis vm delete
trellis vm shell
trellis vm sudoers
Under the hood, those commands wrap equivalent
limactl
features. Just like the previous Vagrant integration, you can always runlimactl
directly to manage your VMs.For default use cases,
trellis vm start
can be run without any customization first. It will create a new virtual machine (using Lima) from a generated config file (project/trellis/.trellis/lima/config/<name>.yml
). The site'slocal_path
will be automatically mounted on the VM and your/etc/hosts
file will be updated.Note: run
trellis vm sudoers -h
to make/etc/hosts
file passwordless:$ trellis vm sudoers | sudo tee /etc/sudoers.d/trellis
Configuration:
Right now configuration options for the VM are limited. The intention is to the most common use cases without any configuration needed.
A trellis-cli config file (global or project level) supports a new
vm
option. The only useful config option right now isubuntu
(to switch between Ubuntu 20.04 and 22.04 for example).Here's an example of specifying Jammy 22.04: