[SOLVED] clones? Or Cloud Init?

Nov 26, 2021
388
180
63
Hi guys

I never took the time to create clones or bother with cloud init.
Today I took the time to read up on it and it honestly created more questions than answers.
Also interested in your real world expiriences.

So normally when I need a VM, I simply create a new one and set no SWAP, DHCP and SLAAC, import-id my public key and install qemu-guest-agent. This is not a huge deal,
but apparently, there are some sleeker way to do this. I found 4 ways on how to achieve this, two clone options and two cloud init option.


Clone 1:
I could simply take the VM from above and create a clone.
MAC will be random, but the hostname and probably SSHD I have to change.

Clone 2:
Convert the VM to template.
Basically the same as Clone1, but it is easier to not mess it up, since it is now read only.
Another advantage is that I can create a linked clone (instead of the full clone above).

Question 1: Since I use ZFS this probably works with the built in ZFS snapshot capability and has no performance implications? While saving a little bit of storage?

Question 2: PBS is probably not affected by this will still do a "full" backup, but maybe the dedup ratio is even a little bit higher, since the base should be matching hashes?

Cloud Init 1:
Out of my custom VM, I can also create a cloud init base.
This is even the from the docs preferred way:
While it may seem convenient to get such ready-to-use images, we usually recommended to prepare the images by yourself. The advantage is that you will know exactly what you have installed, and this helps you later to easily customize the image for your needs.

Question 3:
Why does the Doc prefer this over downloading say something like the Ubuntu Cloud image? I could imagine that it has better defaults (like no SWAP). Is the document referring to something like a Ubuntu + LAMP VM that you could reuse multiple times?

Question 4:
How does such a VM behave in regards to settings that are defined multiple times?
For example, I set the username to "Sandra" during the install, and set "Sandy" in cloud init, which setting will be used?

Cloud Init 2:
Getting the cloud image from the vendor directly. This seems to be the sleekest option.

Question 5:
How would you "integrate" the guest-agent stuff into this? Creating a yaml file, store that somewhere, add it to the template?
Something like this
YAML:
#cloud-config

package_update: true
package_upgrade: false

packages:
  - qemu-guest-agent

runcmd:
  - systemctl enable qemu-guest-agent
  - systemctl start qemu-guest-agent

How do you handle that in your homelab?
 
Question 1: Since I use ZFS this probably works with the built in ZFS snapshot capability and has no performance implications? While saving a little bit of storage?
Yes, Linked clone from a template is thin until you start writing to it.
Question 2: PBS is probably not affected by this will still do a "full" backup, but maybe the dedup ratio is even a little bit higher, since the base should be matching hashes?
PBS is not aware of the thin nature of the underlying disk. It will do full and incremental backups where appropriate.
Why does the Doc prefer this over downloading say something like the Ubuntu Cloud image?
The doc snippet you quoted explains exactly why. That said, if the standard image suites your needs - go for it. PVE is a hypervisor, it does not care what you run inside of your VM and where that VM came from as long as the VM boots.
How does such a VM behave in regards to settings that are defined multiple times?
For example, I set the username to "Sandra" during the install, and set "Sandy" in cloud init, which setting will be used?
Each OS/VM starts with some sort of hostname during the initial boot. A few services come up before CI is engaged. While the end result will depend on the OS, the CI will likely win.
How would you "integrate" the guest-agent stuff into this? Creating a yaml file, store that somewhere, add it to the template?
Guest Agent is pre-installed on many/most vendor provided images. If its not, you can modify the image and pre-install it. If you insist on doing it inline of the first boot - you will need to create custom CI file. YAML is one format that CI understands, there are others. Use whatever makes sense for you.
The CI files are called Snippets in PVE, they should be stored in the dedicated Snippet location, and the storage pool where you store them should have Snippet option enabled.



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: IsThisThingOn