Effortlessly Create Proxmox VE Debian Templates at Lightning Speed with Cloud-Init

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you have a plan on creating virtual machines in a hypervisor it makes sense to create a template and then clone that as it saves you a lot of time but creating a template by installing an operating system from an ISO image for instance can be time consuming itself and that's where clouded it comes to the rescue because it saves you time when creating templates now most Linux dis drawers support this and a lot time to CL providers you can also use this with proxmox v but how do you use cloud in it to create de and BAS virtual machines for instance well if that's something that you're interested in finding out then stick around and watch this video as that's what we'll be going over now the first thing I'm going to do is to create a generic template because the idea is this is going to save me time creating other templates for the actual Linux disc Ros that I want to use I mean across the board the actual Hardware requirements are going to be pretty much the same no matter which Dro I use so if I actually set up a generic template that defines all the actual Hardware need it'll save me a bit more time when it comes to actually creating those more specific Linux disc drawers and I'm also thinking ahead here in terms of just Debian for instance when I want to start using the actual latest major version it's actually better to start with a fresh install so I can save myself a bit of time when it comes to creating a template for that newer version of Debian now when it comes to proxmox V uh in order to create a template you first need to create a virtual machine and then convert it into a template so we're going to click on create VM I'm going pick a different node out of this cluster if I wanted to but I'll leave that as is but for the virtual machine ID I'm going to set this to 9,000 now the ordering that you normally get in this leftand pain is numerical uh so it's just a case of well give it a higher ID just to make sure that it ends up lower down in the list that'll make it easy to actually identify templates versus ual virtual machines but it's entirely up to you what you do with that and for the name I'm going to call this Linux template specifically because I want to be able to pick it out easier now we've got Advanced options below which refer to Startup and uh shut down processes for virtual machines and you can set these here as partly your defaults if you like but I'm just going to leave those as is and if you're going to be using resource pools well if you've got a common resource pool that you use you could set that here as well and I'm not so I'm just going to leave that as is and then click on next now when it comes to the operating system we're not actually installing an operating system especially from an ISO image when it comes to using cloud in it so for that reason we're going to select the option do not use any media and fortunate by default it's picking Linux as the actual operating system so we can leave that as is and click on next for the system what proxmox themselves suggest is changing the graphic card to uh serial terminal so we're going to pick out serial terminal zero here now the reasoning behind that is that you're dealing with cloud in it which is really intended for cloud providers the expectation is no keyboard no mouse and you've got no monitor either so for that reason the expectation is it would be a Serial terminal that you've got so that's why we're picking that now as an aside have founded the default graphics card does actually work when you're using Debian for instance but it's better to go with whatever proxmox are suggesting anyway there are other options here that you can change if you like but what I'm going to do here is to actually pick out that quemu agent and enable it because usually it's actually installed and ready to go on Linux computers anyway and it does get better feedback uh for the hypervisor if you use it so with all those chosen we're going to click on next for diss well actually we don't need a disc disc I'm going to click on the recycle bin and delete this actual uh suggested dis the reason being is that well we're not actually installing an operating system as such what we're going to do is attach an actual pre-built hard drive essentially uh later down the line to our virtual machines so we don't need an actual hard drive to install anything onto so click on next how many CPUs you allocate whether you're going to be having certain numbers of Cs or certain numbers of sockets really depends on your actual own system in my case I tend to find Linux computers especially the servers that I build they usually don't need more than one core at least the majority don't so I'm just going to leave this as my default setting there are other various settings and flags you can pick out if you need to but the only thing that really normally interests me is the actual type of CPU now it has picked out one here that we could go with but because the cluster that I've got has actual um computers that are actually identical what I can do is take advantage of that and scroll all the way down to the bottom here and select out host reason for that is that gives you faster performance you're not really emulating the CPU as such um the only thing to bear in mind is that's not practical if you've got a mixed environment of computers in the cluster with different CPUs so whatever you pick out here I would suggest reading prox mox's documentation especially if you've got a mixture of CPU use within your cluster otherwise you could run into live migration problems for instance in any case with those options selected we'll click on next now I'm quite happy with 2 gig of RAM uh but you can change this if you want a higher default setting but what I'm definitely going to do is deselect the ballooning device option that's definitely not practical when it comes to Performance uh problems you could potentially run into because when it comes to ballooning the idea is you don't actually allocate all of the actual physical memory that you've toed a VM it has you might put certain amount of um space aside reserved on a hard drive for example which that can cause performance issues the uh performance of a hard drive versus Ram is significantly different so unless you're really pushed for um Ram within your actual physical hypervisor it's best to leave that disabled click on next then the network options really depend on what you're network settings are you might have a specific VLAN tag for an naturual build Network for example which is definitely a good recommendation in other words you build your virtual machines in an isolated Network keep them protected from other devices less chance of them getting infected by viruses and so on um but in this particular case well this is just a lab that I've got setup so I can leave the bridge set as is there's no vlans uh I don't need to change the MTU that would be useful if for example all of the actual systems would to be running on 10 gig for example I could uh Crank that up to support jumbo frames for instance by default but in this case I can just leave all of these settings as is and then just click on next and then we get an option here just to give you a summary of what you want to do uh this is going to be a template so it's certainly doesn't um sound like a good idea to start after created not really going to start at all really and in which case as long as you're happy with what you're seeing here we'll click on finish and then we'll wait for this actual virtual machine to be created uh so you can see it's showing up over here at the moment it's got a little question mark and now it although it's called Linux template it's not actually a template so it's got the same icon of a little monitor next to it but we're going to select that then we're going to select more and then we're going to select the option convert template yeah just confirm that and then it's actually going to convert that over to a template and once it does the little icon over here should actually change so I'll just click on re I was just about to click on refresh but now you can see it's just slightly different it's got like a little looks like a little piece of paper or something just behind it or something and then you got a much smaller little icon of the the monitor or computer there so that's it we've got our generic template created now the goal here is to create an actual deian template and what we've got so far is a generic Linux template so what we're going to do next is to actually clone this template to create our deian one so I've selected this template then go to more and select clone now I could change the actual Target Nord if I wanted to but I'm just going to leave this as is the VM ID it's picked out the next available ID for virtual machines but I'm trying to keep my virtual machines and uh templates clearly separate from each other so I'm actually going to change this to 9,001 which is the next available ID uh that I'm using for templates the name want to make this as obvious as possible so I'm calling it Debian 12 template because it's going to be Debian the operating system version 12 and it's going to be a template uh if you're using resource pools you could pick out a default one if you wanted to here uh I'm not using them so I'll leave that as is the mode um I'm not sure why but the default option is link clone now there is a bit of a performance gain when you're using link clones or at least if You' got hard drives this template doesn't have one so won't make any difference but the big problem with link clones is that if the original is ever lost well any VM that was cloned from it as a link clone won't work um maybe in a byon era that might make sense you know the lab instance when you're really struggling for storage space but personally I prefer to avoid it all together and just always pick out a full clone now in this case there isn't a hard drive to copy so things like a Target storage or a format really don't make any relevance but one thing to point out is that these actual computers have got just a hard drive as local storage now that reason you'll see the formatting is grayed out um if I go and select VMS on the other hand which is my Nas that supports different formats so for example I can have qow 2 uh a raw disc and I could have a a VMware image format if I wanted to but for the sake of this we're just going to leave that as is but it's something to bear in mind because qout 2 will give you support for snapshotting if you just got a basic hard drive attached to your computer chances are all you're going to get is that raw format I mean if I specifically pick that you'll see it doesn't give me any formatting options cuz all can actually support is Ru anyway so that's just something to bear in mind but in any case what I'm going to do is just click on clone and then off that will go and create our actual template so shouldn't take too long because it's certainly not as I say creating uh a new hard drive and copying a lot of data across in this case but one thing I'll point out is that numerically things are looking a bit odd because we've got 100 9,000 And1 then 9,000 the reason being is that well this is a virtual machine where this is a template so proxmox is quite useful in that it's putting the virtual machines first and the templates after but I I still like to have that blly obvious bigger number just to be on the safe side as well as the the name template you know just in case because the idea is templates are um kind like read only virtual machines you're supposed to create a template and just leave it in that format don't change it again and then it keeps everything consistent but in this case what we've got is just a uh BB's computer really certainly doesn't have a hard drive and not what use without one so for that reason we need to create one so if we go over to Hardware um there is no hard drive CU well we didn't create one in the original generic template so we need to give this actual virtual machine a hard drive to use and that's what cloud in it comes into play so if we go over to this web page and I'll include a link in the description as well as my blog this is where you can actually get debian's official cloud images um it does tell you a bit more details about them one thing to point out is uh it's suggesting for things like uh Azure you want the Azure image ec2 in other words Amazon's uh AWS service you want that version what we're interested in is a generic version which includes Bare Metal Solutions including proxmox so what I need to do is find the image that I want at the time of the recording we're on on The Bookworm project so I'm going to pick Bookworm I do want the latest version so I'll click latest and usually this is what you'll want Debian 12 generic EMD 64 qcow 2 because we this is what we've got as a Linux hypervisor um amd64 in words 64-bit Intel or EMD processor so that's the file we want but instead of downloading this to my computer then uploading it to proxmox what I'm going to do is right click on that and then select the option copy link go back to proxmox pick my server um I'll just click on the shell and then I'm going to type in w get because I can use that to actually download the file so I'll paste in the URL hit return and it's now downloading that actual image now it isn't a particularly a large image which is fortunate um it's intended for cloud um Solutions anyway but that's it the file is now downloaded the only thing is unlike with other hypervisors um what we're going to have to do is to actually import this actual image as a hard drive to our virtual machine we can't just simply attach it as is we've got to import it and create a hard drive out of it so what I need to do is to run a command from the command line I don't have an option at least at the time of the recording that I'm aware of to be able to attach an image and import an image through the guy so I'm going to have to do it for the through the command line for now but basically we're running the qm import disc command we then give it the uh virtual machine ID which is 901 we tell it what the file is so that's the one we downloaded you then need to tell it what the storage is so for me I've got uh these proxo servers talking to a Nas so they're they're connected to an NFS share which I've called VMS so that's why I've got that as the storage and the reason I'm doing that is I want to use qout 2 as a format the benefit of that is that it allows the actual snapshotting of the hard drives something that you can't do on just a basic hard drive they just support uh a raw format unfortunately um so it depends on you know your own setup but in my case these nodes have got a local lvm storage which is just a basic hard drive it'll only allow me to use a raw image so that's the reason I'm making sure that these go on under the nest because it's a cluster that's where they really should go anywhere to be fair but that's just something to bear in mind um in your case you'll have to pick out whatever your storage is and then whatever formats suitable to you but that is the better option if you want snapshotting and you can always move this at a later date if you want it to anyway but anyway I'm just going to hit return and then what it'll do is it'll actually then go off and then create the hard hard drive for our virtual machine it's well it's it's a bit deceptive most done because it'll get to 100% and now I'm going to have to sit twiddling my thumbs CU I've got to wait a while for it to actually create the actual hard drive and make it available and your mileage might vary but for me yeah it's it seems to be quite random oh there you go it's just suddenly finished so sometimes I have to wait a bit longer so it depends but either way it says it's now created a dis the only thing is if we go to the actual virtual machine go to Hardware it shows us an unused disc so what we've got to do is get the virtual machine to actually use it so we select the dis click on edit there's various things you can change here if you want you even do rate limiting and so on but I'm just going to leave those as is then click on ADD and that's it this actual virtual machine now actually has a hard drive but as you can see the size is only 2 gig now maybe a Cloud that's fine but for me I want something bigger than that so I'm going to select the drive uh and then I'm going to select the dis uh dis action drop down menu and select resize now I've got a size increment option here that's something to bear in mind normally when you ever you create a new virtual machine for Linux the hard drive is 32 gig so because it's already 2 gig I want to add another 30 gig to the size click on resize dis and then once it's done we'll then get a dis of 32 gig in other words it's added 30 gig um to the the existing size so it didn't create a dis of 30 gig it added an extra 30 gig to the original size but either way we've now got our actual hard drive now one thing to bear in mind is that we need to change the boot order now because if you go over to options then the boot order you'll see it's not going to actually boot from that drive so I need to select boot order click edit I'm just going to drag this all the way up to the top enable that and I'll deselect the others I've got no particular reason to boot off the IDE or the uh Network I just want to boot off the drive so I'll then click okay now where things get interesting is that we can take advantage of cloud in it and as you can see proxmox does have this Cloud init option so this is an image it's prepared of a cloud image cloud in it but although we can take advantage of it with proxim box in order to do that we need to add another drive so if you go back to Hardware go to add and then select cloud in a drive you've got choices here about the bus or device by default it's IDE you can change it over to something else if you like I'm just going to leave it as is um and then you got to choose your storage now I want to keep the hard drive image and the um cloud and a drive together so I'm going to put this on VMS uh I could change the format I like by default it's picking out qow 2 anyway doesn't really matter um in this case cuz once you actually have created the virtual machine you would remove all this anywhere it's just for the initial um boot up if you will and creation of the actual uh virtual machine later on as you'll find out but either way we need this Cloud init drive so I'm going to click on ADD and that gives us that cloud init drive now you can go back to cloud in it we've got options so that normally when you install uh an oper system you've got to go through a series of questions to answer things like what's the username what's the password DNS domain name DNS servers you can put in public Keys there's upgrade packages options here as well and then there's also IP settings so this to me is much better than uh the alternative method which is to create an actual template uh where you go through the normal installed process but then you create your virtual machine and then go back in and start changing IP settings username and so on specific to that virtual machine you can take care of that here as part of cloud and it so it does save you quite a lot of time one thing I don't like is this idea of a default user account on the other hand I don't want a build in user account as such as part of the build process but it's not a great deal of option you've got to log in at somebody I mean we certainly don't know what the root account password is so we need some user account here so for that reason I am going to change this uh I'm just going to double click on it it doesn't do anything so I've got to click edit and I'm going to call this Bob the Bob builder I mean what else but yeah something else really I'll click on okay and I'll give it a password because you might need to log in to that actual virtual machine maybe through the console for instance at least to begin with but um my train of thought is that this is it's not ideal because it's a user account and password that's kind of baked into hypervisor setup if you will as such that's not really a good idea however my plan is that when I get virtual machines created anible is going to come in and it's actually going to create its own anible account it's going to delete this build account that we've got here anyway so the account only exists kind of permanent if you will on a template which never gets spun up anywhere um you can't read it I mean if you had access to the um actual hypervisor and you could find a way to work out what that password is anyway it's not that big a deal because once the vm's just spun up and an's got a hold of it it's gone anywhere so I'm not really that bothered um so it's it's better to me to have at least something like this rather than a default account in any case we've got options here to set the DNS domain name if you want the DNS servers uh if you don't do anything what it does it inherits what uh the actual hypervisor itself's been set up for usually they same anyway so I'm quite happy to leave those as is but could go in and actually change those if you like entirely up to you now one thing I would certainly suggest because it's makes things a lot more secure is to put in a public key that way you can actually log in from a computer using SSH key authentication which is more secure than user accounts and passwords for me this is what anable is going to do when it logs in using SSH it's going to be using an actual um key uh authentication process so yes it's going to be logging in with a different user account than this one I've created here but that's going to go anywhere and ultimately that's all that's going to happen it it'll only be using um these SSH Keys going forward so at least what I need to do for now is to put in something so I'm just going to use my key here so this is my public key not a private key you definitely don't want to put a private key here use a public key doesn't matter that that's invisible because well to be able to take advantage of that you need to be in possession of the private key so this is quite useful um especially from a security perspective I do have an option to load it in there if I wanted to but I've just copied and paste it in we'll click on okay uh got options to upgrade packages but I'm going to leave that as is but the one thing I'll point out is the IP config I'm not sure why but the default option for ipv4 is static typically you'll probably want to go to DHCP especially for a template and maybe virtual machines as well um because when you create your virtual machines you could go through that process and give them a static IP address it's tends to be a bit more common to actually use DHCP and actually Reserve IP addresses based on the Mac address um rather than having to go through this rather labor ious process of assigning static IP addresses this way so for that reason I'm going to deliberately set it to DHCP um it could all get changed as part of the automation through anible anyway it doesn't really matter all we need is to get this virtual machine up and running on the network now when it comes well I say this virtual machine I mean the actual real virtual machine in this case we're just doing the templat so it doesn't really matter when it comes to the actual virtual machine itself that would be the similar sort of expect a because I don't want to go through this process of having to put the IP address in for every single virtual machine I created for IPv6 it's well it's entirely up to you there doesn't seem to be a way to disable this um it's decades since I ever touched IPv6 in terms of seeing anybody who needed it I mean I've come across a an actual hting provider who wanted it for the customers that was a long long time ago it's been very common in um CISCO exams for example um to actually make sure you'd understand IPv6 but until an actual service provider for instance comes along and actually gives me the option for IPv6 and as long as I can get away with ipv4 well like most companies I'll just stick with ipv4 for now and not touch IPv6 but as you can see the option is there if you want to use it you just forever reason don't have a means to disable it so I'm just going to leave it on the static option click okay and then that at least gives me the basis for my actual template so well now what I need to do is to actually convert this into a template so to do that we'll go to more and then select convert to template say yes of it goes and now it converts that across from being a virtual machine and being a template which essentially it's just a a readon version of an actual virtual machine anyway you'll notice how the orderings changed so now we've got a proper numerical order that we'd expect just that extra feature should we say of virtual machines take precedence over uh templates but there we go we've now got an actual template to create Debian 12 virtual machines from well now that we've got a Debian template created we're can to create virtual machines from it so to do that we'll select our template then we'll go to more and click on the Clone option now I could pick a different node to install it on but I'll leave that as is and I could change the actual virtual machine ID but I'm not really too bothered about this it's just picking out the next available one which is fine uh for me and then need to give this virtual machine a name so I'm was going to call this de test for example if I was using resource pools I could assign it to a specific one but I'm not so I shall leave that blank uh as ever when it comes to the mode I'd much prefer to use a full clone as opposed to a linked clone and then it's really coming down to choices as to where I want the actual hard drive now in this particular case I know the template is on the nas but I can be a bit more specific I can actually tell it that I do want it on my uh BN storage I can change actual format um if I wanted to but I want to use qab 2 because I want snapshotting available uh options here so with all those choices uh picked there I'm going to click on clone and now I'm going to set twit my thumbs because at the moment you can see we've got a virtual machine here but it's saying that it's locked because it's in the middle of actually cloning it in other words it's got to actually copy that hard drive to create an actual new one so this is going to take a bit longer than it took uh to than you know to clone the actual generic template that we had originally so just wait for that to finish okay then so the padlock has now disappeared so that virtual machine should be ready to go so we'll select that now before I actually start this up I've got options so I could for example start changing the hardware give it more um CPUs give it more memory and so on I could go into cloud in it I could make alterations I could make a different user account I can give it a specific static IP address and so on but the thing this was that really everything should be getting all the settings that are needed uh from this Debian template enough for in my case anable to then get a hold of it and update it so I'm just going to leave this all alone and instead what we're going to do is actually click on start and then what I'm going to do is I'm just going to click on the summary because Al it's tempting to click on the console and actually see what's going on from what I've seen in some of the forums kind have problems if you actually interrupt the process here so what we're going to do is just basically keep an eye on this because you're going to see CPU spikes every now and again uh while it goes through the process of um essentially setting up this virtual machine based on the information we gave it in those cloud and its settings eventually what it should do is settle down and one we are found to also just double check is to actually check the DCP server because once the computer's been allocated on I address then it should be ready to go so again I'm just going to twiddle my thumbs and wait until it seems that this virtual machine's ready now it looks like it has actually quieten down so we should be ready to go but what I'm going to do is I'm just going to go over to idhcp server I mean I'm using uh cat here uh here rather so what I'm going to do is just have a look and then I'm going to have a look in the file and see if any IP addresses Rel leased so it looks like we've got an IP address of 103 is the most recent release so what I'm going to do is SS agent that is B but because we're using keys I need to tell it which key to use so that's going to be in my home folder I need to point it to the private key and I'll say yes to the actual fingerprint say that looks fine and there we go we've now got access to uh a computer called Deb test and logged in as B so that's something to point out was the fact that when we actually clone the virtual machine I gave it a name of Deb test now if you've actually created other templates just going down the normal ISO process in other words you build the operating system by going through this long lengthy process of booting from an ISO image answering a load of questions and then sitting for a long long time waiting for the operating system to install and then you turn that into a template when you actually then clone that template the problem is the computer doesn't matter what name you give it as part of the cloning process is the same as the actual template that you create in this case which is extremely useful hor name actually gets changed as part of this process so that's one less thing I need to be concerned about now one thing I will point out though is that there are some aspects of this not overly funded on um if I have a look at the date it's on QTC as far the as far as the time zone concerns as concerned so this is something you might want to look into post install in a big cloud environment chances are you using UDC you'll probably want to centralize all of the actual time zones anyway but if on the other hand you actually want to centralize that to you know whatever country you're in and so on well that's something you want to look into po inst stall so it's not that big of a deal but it's something I came across another thing I found is that well if I have a look in the ety network folder if I can type there's no interfaces file here normally when I install deun and one of the things I like about Debian versus say like a bundu which is based off of Debian this version of Debian uses net plan and I don't like it I've got to be honest I just don't like it at all editing a text file to me is far far simpler and there is another way of doing doing it and I don't like that verion either to me text files are much simpler but in any case it is what it is I prefer this approach of having a much quicker way to create a template um using this cloud in it so once it's got an IP address it's not going to likely change anywhere and if things are bound to an IP address based on a Mac address well it's not that big of a deal I'm not going to be coming in back into this machine and changing anything afterwards anyway but again it's it's something to bear in mind if you're not familiar with net plan you're going to have to get used to it um another thing you might run into is local settings um more around keyboard settings and so on what I found is that with Debian you can run into these problems where you'll run a command and it just bark saying that the local is not set or hasn't been decided in which case you're going to have to fix that uh if you run into it uh it's not specific to the cloud in it image as far as I can tell I've had that with other versions of Debian as well anywhere so these are all features should we say that you need to probably look into po install I'm just having a look for any other thing uh any other gutes oh yes the other one is although I mentioned enabling the quemu agent with Debian software isn't installed at least not with this specific uh image so that's something else you have to bear in mind you have to install the actual agent as another post installed job now these are all to me just minor trivial sort of things but I thought I'd Point them out the reason the minor is really my plan shall we say is to automate as much of this as possible which means going down the anable route and if this is all going to get changed anyway it's not that big of a deal how answer will do all this so that's why I'm not overly concerned now there although I actually logged in using SSH you can also go in through the console if I select that uh eventually it'll come up and say starting the serial terminal to actually get in there what you've got to do is actually select the actual screen and press the return key and then I should be able to log in as B there you go so I can still get in through the console so even if I didn't you know want know what the IP addresses through DHCP I could get it this way as well but I don't know I mean I've as I say I've always played it safe when it comes to running this type of image and just I just leave the console on um just to be on the safe side because it's booting up doing whatever it's doing um using cloud in it and I don't want to it interrupted I mean if I go back again again we back to this process of saying you know start of the serial terminal another thing to bear in mind is there's only four serial terminals potentially available which can limit how many uh you can log into at any given time as far as I can see um but again this this whole image is really intended uh for a cloud provide anyway the whole expectation was you'd set it up like this leave it a while and then you would s sh into it anywhere but overall it's a relatively simple process to follow on it it is much much quicker to me than going down the iso image route now although this method saves me a lot of time versus creating a template from an ISO image it is still a manual process now there are several tools to help automate the building of virtual machines but these usually involve learning new scripting languages getting the key presses correct create the template and so on so for me the long-term goal is to hand over as much as possible to anible in other words once the hypervisors are up and running it should be possible to get anible to create these Cloud init templates and then use them to create the virtual machines but what automation methods are you using up planning to use let me know in the comments below now if you find this video to be useful then do consider subscribing to the channel as that would really mean a lot to me it's also a good indicator to let me know how videos like this are helpful to people such as yourselves that are watching in which case thank you on the other hand if you're not ready for that level of commitment then I'd really appreciate it if you could press the like button because that way that'll help to get the video out to other people that might find it useful as well
Info
Channel: Tech Tutorials - David McKone
Views: 5,237
Rating: undefined out of 5
Keywords: proxmox cloud init, proxmox cloud init template, proxmox cloud init debian, proxmox cloud init ssh key, proxmox cloud init drive, proxmox cloud-init, proxmox cloud-init tutorial, proxmox debian cloud image
Id: M8YckhMTrF0
Channel Id: undefined
Length: 37min 27sec (2247 seconds)
Published: Wed Nov 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.