Virtualisation
What is cloud-init?
cloud-init is the standard mechanism for configuring a virtual machine on first boot, using metadata supplied by the platform. It handles SSH key injection, hostname, network configuration and arbitrary user scripts, which is what makes fully automated provisioning possible.
Why cloud-init matters
It handles SSH key injection, hostname, network configuration and arbitrary user scripts, which is what makes fully automated provisioning possible.
cloud-init in practice
On a fresh boot, cloud-init runs before your services start. You would watch the console for 'running modules' and check /var/log/cloud-init-output.log. A misconfigured user-data script can hang boot or leave SSH locked out. You would test in a disposable instance first. You can re-run with 'cloud-init clean' and reboot. Getting it wrong costs you time re-provisioning from the panel, or a VNC session to fix it by hand.
What people get wrong about cloud-init
The common error is assuming cloud-init re-runs on every boot. It runs once on first boot. If you add a script to user-data expecting it to apply on restart, it will not. Correction: use it only for initial provisioning, or explicitly call 'cloud-init clean' to reset the state for a fresh run.
cloud-init — common questions
How do I pass user-data to cloud-init?
When provisioning from the panel or API, you can supply a user-data field. It gets injected via metadata, and cloud-init applies it on first boot. Keep it as a shell script or a cloud-config YAML, depending on what you need.
Can I use cloud-init with a custom ISO?
Yes, if the ISO has cloud-init installed. For instance, cloud images of major distros include it. You can also upload your own image with cloud-init. Ensure the instance is KVM, not a container, as cloud-init relies on metadata provided by the platform.
More from virtualisation
- KVM
- KVM is full hardware virtualisation built into the Linux kernel, giving each guest its own kernel and hardware-enforced isolation from other tenants.
- OpenVZ
- OpenVZ is container-based virtualisation in which every instance shares the host kernel, so guests cannot load kernel modules or run a different operating system.
- LXC
- LXC is Linux-native containerisation that isolates processes with namespaces and cgroups while sharing the host kernel.
- Hypervisor
- A hypervisor is the software layer that creates and runs virtual machines, allocating physical CPU, memory and IO between them.
- Nested virtualisation
- Nested virtualisation lets a virtual machine itself run virtual machines, by exposing the processor virtualisation extensions to the guest.
- vCPU
- A vCPU is a virtual processor presented to a guest, backed by scheduling time on a physical core or thread.