Perfect Proxmox Template with Cloud Image and Cloud Init

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
using cloud images along with cloudinid is a great way to provision linux machines in proxmox cloud init is a standard linux package that helps take care of the initialization of a virtual machine instance when using cloud init you can configure your network settings and your ssh keys so that when your machine starts up for the first time it has the right settings and cloud images are minimal customized images of linux that are meant to run in public clouds most of these images like the ones from ubuntu are certified and optimized to run in public clouds like aws google azure openstack and more and these cloud images already have cloud init on them just waiting to be configured and the good news is that proxmox uses these too so today we're going to configure a virtual machine on proxmox to use a cloud image we're going to configure cloud init on that machine giving us the flexibility to bootstrap these machines with our settings before they're created and then we'll turn this machine into a template creating an easy way to provision new machines with our network settings ssh keys and more and without the need of cleaning up things afterwards and we'll do all this in just a couple of minutes so to create our ubuntu cloud image the first thing we'll need to do is download the ubuntu cloud image we can download this from the repository now i'm going to download the focal image or the current lts but feel free to download anyone you like once you're inside of this folder you'll want to find the one labeled focal server cloud image amd64.img now instead of downloading this you want to actually copy the link to the download to your clipboard because we need to do this inside of a terminal now this might not make sense right now but we're actually going to use this image as a hard drive for a virtual machine then you'll want to ssh into your proxmox server once you're in your server we'll download the image with wget next we'll run a command to create a virtual machine and the reason why we're doing this is so we can attach that image we just downloaded to this virtual machine then we'll go back to the gui so the command we're going to run is qm create 8000 so 8000 is an id you can pick any id you want but i'm going to pick a high id so i can identify this for when we use it as a template later we're going to set the memory to 2048 or 2 gigs we're going to name this ubuntu cloud i'm going to set the networking to use the vert i o driver and we're going to set it to bridge mode and i'm telling it to use the interface vmbr0 don't worry all of these commands will be in the documentation and you can find that in the description so you can just copy and paste all this so we've created that vm and we can actually see it in proxmox here but we're not done yet so let's go back to the terminal the next command we're going to run is a qm import disk and then the id of this machine and then pointing to the cloud image that we downloaded right here and then we're telling it local lvm so this is where we're going to put it so this is saying import the disk on this id use this image and then place it in local lbm now you don't have to put it in local lvm you can put it anywhere you want for example i'm going to put mine in fast10 and this maps to one of your storage devices that are attached to that server so i'm going to upload mine here and there we go so it uploaded that image and the next command we're going to use this is the last one hang in there is qm set 8000 and then we're going to set scuzzy hardware bur io scuzzy pci and then scuzzy zero to local lvm and to that disc we just uploaded so this is configuring that virtual machine we're adding a scuzzy controller and then we're adding a scuzzy drive and attaching the disk that we just uploaded and again if you put your somewhere else like i did it will be in that device that you specified earlier okay so i ran the command and it attached just be sure that your disk number matches the one that you uploaded previously in the previous command if you get an error you might want to check to make sure it's disk 0 or disk 1 it should have been echoed out in the previous command before we ran this and use that one to attach it anyways now that we have this working we should be able to go into here and see our ubuntu cloud machine and if we look at the devices that are attached we can see here we have our scuzzy controller and our scuzzy disk that we specified earlier so real quick we have this ubuntu virtual machine that can boot up now and look for the cloud init drive we haven't configured that cloud init drive but that cloud init drive will supply networking information as well as our ssh case so we need to configure a cloud init drive and attach it to this virtual machine so let's go back to the terminal really quick and let's run this command right here qm set 8000 the id of our machine then we're passing in a flag of ide 2 and then we're pointing it to a cloud init drive and all this is doing is creating a virtual cd-rom and attaching it to this virtual machine so i have mine on a different drive let's run that so now it created that logical volume for cloud init next we'll run this command qm set 8000-boot c boot disk scuzzy zero and this is so we can boot from this cloud init drive directly and it will also speed up boot times the next thing we're going to do is enable a serial console now this might not make sense because we'll end up ssh into it but for the webvnc part if you want to be able to see the output we need to configure this serial so we can actually see the terminal itself and this is the way that most cloud vendors have their images configured so we'll need to turn this on okay so now we can go back to the gui and if we go into cloud init we now see we have a cloud init drive configured so awesome now we can initialize virtual machines with these values when it boots up for the first time so if we wanted to set a user of server admin and a password we could we can also configure dns settings we can configure dns domains and dns servers or just tell it to use the host we can also configure ssh keys which is really cool because now we can ssh directly into this machine without having to add our keys first and here you want to paste your public ssh key and we can also configure our network settings so if you didn't want to configure dhcp you can configure a static one here you could set your ip address the gateway or do that same thing in ipv6 but we'll use dhcp now this caught me up for a minute but the default value is static of nothing so if you don't set anything you're not going to have any network access at all this trip me up for a minute so at bare minimum set it to dhcp and hit ok so a word of caution once you create this template you don't want to start it up the reason is is because if you start that machine you'll bootstrap that machine with a machine id and a uuid and if that happens you'll end up with the same machine config across all your templates so don't start it up if you did there are ways to reset it but i would highly recommend just recreating it and start with a good state so now that we have a cloud image with cloud init we should create a template from this so to create a template we can right click and convert to template but before we do i know you're probably asking well why didn't you install the qemu guest agent or any other tool well i've run into issues before where i install the guest agent and then create clones from it but rather than bake those things into this image i end up automating it with ansible later we'll talk about that here in a little bit so i'm gonna keep this base image as clean as possible now don't get me wrong we can configure some hardware so if you wanted to say hey my base image will always have four processors and it will always have four gigs of ram that's totally fine and arguably you could install some tools on this machine ahead of time but again i like to keep mine as clean as possible so that i don't have to undo anything in the future or fix or correct if something goes wrong so for me this is my perfect base ubuntu cloud init image four gigs of ram four cores and cloud init already configured on this so now we can right click and convert to template and this is a one-way ticket there's no going back after you do this but you saw how easy it was to spin this up if something goes wrong so let's convert it to a template and now you can see it has a slightly different icon so now from here we can actually clone this machine and when we clone this machine we get options to create this clone from that base image so for the name of the first one i'm going to name it yoshi then we can choose our resource pool we can set a vmid and even our target node if it's clustered not going to touch any of that but what you'll want to pay attention to is the mode now we have linked clone and full clone now link clone is always going to keep a reference back to this image which is nice because you save a little bit of space but then you're always bound to this image you can't clean up this image you can't do anything to this image without deleting everyone who depends on it so typically i like to choose full clone now we'll set our target source and for me that's that fast directory but feel free to choose local lvm or any other place you store your virtual machines and then we can hit clone so we've created yoshi and we can start up yoshi and while that's starting up let's create another one so let's create another clone let's name this one bowser and we're going to choose a full clone again and we're going to choose the storage it belongs to mine again is fast so clone this one so while that's cloning let's check on yoshi so yoshi is booted um we can log in using that account we created we can see we have an ip address and we can see our host name is yoshi do the same thing for bowser see how happy he is usually not happy in general bowser's not a happy person but this virtual machine a bowser he's going to be pretty happy okay now with bowser up and running we should be able to remote into this machine we should be able to run an ipa and we can see we have an ip address of 192 168 0.204 so that's a good sign a different ip address than yoshi and we can ssh into this machine as i mentioned before we'll need to accept this and get right in and you can see that this is that yoshi machine so we can ssh in using cloud init in the key we provided now as i mentioned before when creating the template if you're seeing multiple machines with the same ip address that means that your machine id or your uuid is the same across those machines and so they're getting the same ip address because they have the same identity and to your dhcp server they look the same and if you're getting stuck there i'll leave some links in the documentation on how you can fix that because you may want to boot up that base image to do some additional maintenance and then shut it back down and so you'll have to run some commands before you shut it back down to remove the machine id and uuid so each new machine is unique so what do i think about cloud images and cloud init i think they're awesome they're really small they're really optimized for a cloud environment and everyone that's running in a cloud environment wants something super secure super optimized and super small and they also want it to boot really fast so i want all of those qualities of a cloud image for my base images for my own machine and cloud init saves a lot of tweaking and configuration of your base image after you've deployed it before cloud init i've had all kinds of cleanup scripts i've had to run the e2 machine either manually or with ansible so what do you think of cloud images and cloud init and templates do you already use them or do you just clone another base image you already have let me know in the comments section below and remember if you found anything in this video helpful don't forget to like and subscribe thanks for watching uh three point six minutes he's bragging geeky rand uh nah nah banging not bad a little bit uh it's a humble break no it's uh it's not i'm amazed i don't to don't want to say like yeah i split up a whole entire you know bare metal uh you know kubernetes cluster in 3.6 minutes but it kind of did
Info
Channel: Techno Tim
Views: 73,960
Rating: undefined out of 5
Keywords: proxmox, cloud image, cloud init, cloud-init, clone, template, proxmox clone template, cli, ubuntu, cloud-image, virtualization, pve, clone vm, homelab, home lab, cloud, techno tim, technotim, vm, ubuntu cloud image, ubuntu cloud init, linux, proxmox cloud init, cloud init drive, cloud-init support, hypervisor, ssh, network, openstack, vm templatem, ssh keys, qemu, kvm, virtual machine, proxmox ve, cloud-init ssh keys, cloud-init clean, cloud-init tutorial, small, optimized, perfect, efficient
Id: shiIi38cJe4
Channel Id: undefined
Length: 11min 51sec (711 seconds)
Published: Sat Mar 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.