eksctl - How to Create and Manage AWS EKS clusters

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
just slightly less horrible than web ui don't do that that it's not a good idea in some ways better than terraform you cannot upgrade worker nodes you're bad click buttons i think it's an excellent choice actually [Applause] i will make two important assumptions here first you're using aws second you're using kubernetes or more specifically elastic kubernetes service or eks now if i'm wrong about the first assumption that's normal because you might be using azure or google and then this video might not be the best choice for you if you're not using kubernetes then i don't know what you're doing you must be i mean everybody is so go ahead switch to kubernetes right this video is about how do we create manage destroy handle upgrade kubernetes clusters in aws which tools should we use and how should we use them you could create and manage eks cluster using aws console or web ui don't do that don't don't even think about it that's the worst idea except if you're learning if this is the first time you're starting to experience and to figure out aws maybe other than that click click click click is unacceptable don't do you web ui that means that you're not doing things that are reproducible you don't know what you're doing others cannot review your code just don't click don't click click it needs to be as code write or commands at least something scriptable at least right the second option is for you to use aw cli that's just slightly less horrible than web ui or maybe it's even more horrible i don't know aws cli 40 ks at least is really really bad option and even aws is not talking about it much so don't the second option also bad you could use terraform now this is potentially the best option managing everything infrastructure related with terraform is an exceptionally good option probably the best but you might not want to do that either actually it depends if you're really proficient with everything aws if you understand how to represent some i don't know 30 minimum 30 resources in terraform how to define them and all the stuff it's a great option it's a probably the best option but it's complex aws is complex a lot of moving parts are around and defining all that in terraform can be a bit down thing i mean if you would be talking about google cloud or azure you know creating kubernetes managed kubernetes clusters over there it's relatively easy maybe one or two resources maybe 20 30 lines of terraform eks in terraform would need let me stop there let me double check something just a second let's take a look at this terraform definition this is the shortest terraform definition that i could find among those that i wrote before it is the simplest possible eks cluster definition that i have so let's see how many lines of code is there so that's 176 lines of terraform definition required for the simplest possible eks cluster now there is a good reason to do that terraform is extremely powerful it's extremely versatile and generally speaking it is a preferable way to do it but if you want simplicity connected with aws that's not it so there must be a simpler option to have configuration is code with dks and without hundreds of lines for something relatively simple and there is there is a better option a simple option that is a good option and that option is eks cattle ek scuttle was initially created by v works it is open source now it is adopted by aws they even converted it into their official whatever the official means uh cli for eks let's explore it let's see eks cattle in 20 minutes or less it's not going to happen it will not be 20 minutes it will take more likely 30 minutes and the reason why i know that is because in post-production i realized how long does it take to go through a gas cuttle and aws and eks and what's not think of it as being a mistake 30 minutes not 20. the only thing i did in advance beyond having aws account is installation of eks cattle cli so i have the cli already downloaded and the executable from my machine other than that we are going to do everything together so just go and install eks cattle cli and you can follow along and by the way all the commands are in a gist that is in the description of this video so you can just copy paste the commands right you will need few environment variables so that your laptop the cli knows how to connect to your aws account and those two are export aws access to access key id and set it to the value of your access key id now if you don't know how to if you don't have access key id and secret access key you will need to go to aws ui console and create the credentials for your user usually people if you're using aws you should have those if you're if you're given account by somebody just ask them your administrator anyway get access key id and paste the value into this variable instead of three dots as you see here and you will also need to export aws secret access key and i will not show you what's the value either because i already created those variables i don't trust you otherwise if you would see it on my screen you would be able to access my cluster and i cannot let that happen and the last one we will need we will create is we will export cubeconfig to be whatever is the current directory and then cubeconfig you don't have to do that you actually don't have to have create this environment variable i just like to have cubeconfig in the working directory instead of the default one and this also assumes that you have cube catalan if you're using kubernetes you don't have cube cattle then you're in a definitely wrong place so i'm assuming you you do have cube cattle cli okay good good good to know i was worried for a moment and now we can start using eps cattle right and let's say we could do eqs cattle create cluster if i would press the enter key right now it would ask me a couple of questions i would answer them and i would have a cluster in like five minutes five to ten minutes but we shouldn't do that because not everything should have default values we might want to specify additional stuff with arguments instead of being asked questions and that's much better it's much better always to use arguments because then you can stall the full command in some reap points and documentation so that objects can do exactly the same and that could be for example the name of the cluster it could be devops catalog a region where we want to run the cluster let's say you assist uh which one one and the version of the of kubernetes you want to use let's say 118 or one i don't know he's 19 available maybe not anyways node group group name could be for example primary and so on and so forth now we are not going to do that either most people who use eks cuttle execute commands like this and don't do that that it's not a good idea actually it might be a good idea if you're creating a demo cluster and you're just executing as capital this and that but if you're going to be serious you want to create a configuration and then execute ekscatal against that configuration stored as a file potentially living in one of your git repositories you know everything defined this code everything code code code code we want to define infrastructure as code and not as random cli commands so if we could do that if we managed to define uh our request clusters code then we would get to a similar result as using terraform but in a much simpler form that's the goal let's see whether we can do that i already created the configuration we can use so let's check it out and it's stored in a git repository so actually let's clone that git ripple first it might contain couple of useful stuff we might want to use so git clone http https github.com oh git knob no git nam not github.com my user is vfrsek and it's called eks cuttle what is the name i forgot demo yes dot go git right the commands are in the gist it's in the description so i'm cloning the repository i'm going to go into that repo and let me show you a file and the file is cluster 1.17 let's say that we want to create the kubernetes cluster based on kubernetes 1.17 this is how the definition would look like so instead of us specifying arguments which we might easily forget and which we couldn't share easily with others and what's or not we can define a cluster config right and that cluster config has some metadata like this is the name of the cluster this is the region and this is the version of kubernetes cluster i'm running intentionally all the version you will see soon why and then we have a group of managed nodes it could be one or many we could have many node groups but in this case one should be enough i'm calling that one primary the instance type the size of vms we want to use for the worker nodes of our cluster is going to be t2 small anything smaller than that micro nano whatever they call it is too small for kubernetes so t2 small i i believe is the smallest workable node size in aws we should have a minimum of three three nodes and a maximum of six now this minimum maximum is pointless let me tell you it's pointless as is for that to work we would need to set up a cluster autoscaler which we might do later depending on how much time i have anyway and spot set to true yes i want to use spot instances meaning cheaper instances now you might be wondering hey how do how do i or how can you know about what do you specify there right did they just type random values i didn't of course there is a schema and we can consult that schema through ekscattle.io documentation and that one is this one over here and we can see all the parameters of the arguments everything that we can specify it's not huge i mean considering that it's aws and in aws everything is huge this is bearable amount of stuff we can specify some of them you might need some of them not anyway here are all the options you can use with eks actually now when i look at it it is kind of huge it is massive but the good news actually this is very good news because that means that you have freedom to be very specific while still be going with a very simple solution if that's what you want if that's what you need and the simplest solution is this one the file that i'm showing you here i'm specifying just the bare minimum and then you can expand that to whatever you need so now that we have a file let's try again to execute eks cattle uh cli so eks cattle and then we want to create a cluster just like before but instead of specifying arguments i'm going to specify config file and the file will be cluster 1.17 dot yaml so we will create a cluster or update existing cluster we don't know we're about to find out using the definition stored in that file and there we go now it is creating all the resources everything and everything it needs and there is actually quite a lot availability zones subnets now it is create then you started creating eks cluster and the node group and it will create cloud formation stack and this will take a while right so we'll fast forward to the end of the process it will be pointless for me to let you watch me watch this screen for like 5-10 minutes so fast forwarding [Music] hey while waiting for your cluster to be created this is the perfect opportunity the best possible you will ever have to subscribe to this channel and they know that you haven't seen the whole video but hey click the like button if you already have a feeling that this might be a good one if you don't think that's the case then wait until the end and then click the like button this is what happens when you're impatient and you wait for infinity what is it like 14 minutes 13 minutes 13 14 minutes and still we are not we're halfway through or something like that and then i start inventing silly things to say i should go back to watching youtube [Music] hey it's finished that's brilliant okay so let's let's see what did we get right uh well how much does they take like 17 minutes give or take slow shame on you aws this is not an issue with dks cattle simply it takes a lot of time to create the cluster and all the related resources in aws what can you do okay so we got the cluster let's um what should we do first this is my aws console yours is as well make sure that you selected the region that you're using i'm using uscs2 uh actually usc 1 is my preferable region but uh there was not enough capacity there so i switched to usc's 2 and i can go to let's say yes and elastic kubernetes service and i can see my cluster here in the list of clusters it says update now don't do that i already told you don't click buttons use dashboards only to see what's going on not to operate your cluster everything define this code use store it in some config files like like what we're doing right now i'm going to show you how to upgrade your cluster later if you go to the search box and say cloud formation we can see here cloud formation and those are the cloud formation definitions stocks the thickest cattle created for us right those are all the events all the resources this is those are the things that were created from one stack and those are the things created from another which is much shorter but it eks cattle does for us is it creates uh stockpiles cloud formation stockpiles which are horribly complicated so don't try to do it yourself this is one of the big advantages that aks cattle gives us let's go back to the terminal and uh what did we get eks cattle we can do something like get clusters in the region us is oh i don't know how to type ps2 was it right and then we can use zks cattle to list all the clusters we have i have only one this is a demo one um we can also it created the cube config for us right so we can do something like cube couple get nodes we can see all the nodes in a cluster and you will notice that the version is 117 that's because simply that's the one we specified in the config file we used we can do eqs cattle uh scale node group and then type the name of the cluster which is devops catalog and specify how many nodes we want like let's say four we have three right now and the name of the node group which is primary we could do this but don't don't do not do this this is another important thing do not press the enter key by any chance because you don't want to manage the size of your cluster like this you want to install cluster outer scaler and to install cluster auto scaler unfortunately eks cattle does not provide the option to install cluster autoscaler at least not today which january 2021 which is very unfortunate because that means that you would need to go to um and follow the instructions from aws itself and those instructions are i will post the link in the description section those instructions are those and look at this you need to follow all these create policies create this create that and that those are all the instructions how to create cluster auto scalar which will scale your cluster automatically depending on the workload which is definitely something you should do but this documentation is horrifying horrifying especially since knowing that azure and google they all give you checkbox and do you want cluster autoscaler yes except the guess anyway happy thoughts happy thoughts so but the summary of what i'm trying to say is that do not scale your cluster manually like using eks cattle scale node group do it automatically by following the instructions how to create cluster auto scaler what we did so far we enabled it we we have all the labels and everything in the cluster you just need to follow instructions to create additional resources that you need for that so scale it automatically don't scale it manually yourself going back to um now let's go back to what else we can do i'm going to cancel this command we're not going to scale our cluster manually let's say that we have a task that we want to upgrade our cluster from running kubernetes 1.17 to kubernetes 1.18 how would we do that and i already told you do not go to the web ui and say yes i want to update don't change the definition you would go to the file that we defined and change it or for simplicity reasons i defined another file and i'm going to show you what's the difference so if we take a look at what this is the file that we use to create a cluster initially we would make changes like the ones i created in this file 1.18.jumbo and the changes are just um change the version to 1.17 from from 1.17 to 1.18 and here is the tricky part and this is one of the things that really annoy me with the eks it doesn't have rolling updates you we cannot upgrade the worker nodes of the cluster the only thing we can do is create a new node group so we're instead of primary we're going to create a new node group called 118 and the name can be anything except that it must be different uh and that node group will be with the correct version of kubernetes so in other words what they did here is that before in the old definition it was called primary the node group now it's called primary dash something else for a simple reason because it needs to be new node group to run new version of kubernetes on the worker nodes horrifying horrible but again this is not the fault of eks cattle actually now when i think about it it might be ecs cattle could implement that logic internally uh but anyways the main culprit here is zks you cannot upgrade worker nodes you can you must create a new node group so to upgrade the cluster summary we change the version of the cluster and it was 117 before now it's 118 and we change the name of the node group silly i know so now to upgrade it we can do eks cattle upgrade cluster and then config file will be cluster 1.18 right and we hit the enter key and let's see what will happen what will if you're familiar with terraform you probably know that the results the result actually the outcome is that nothing happened uh we are just seeing on the output the plan so if we do continue with this uh the version will change from 117 to 118. and this is informative it is telling us what would happen if it would if we would proceed with the process so we do want to proceed so we need to type approve as additional argument so we're going to execute the same command but with dash dash approve and then it's going and this will take a lot of time now because it needs to create a completely new set of no so actually one step back it will need to upgrade the control plane that's the manage control plane by aws and it will create a second node group that is based on the newer version of kubernetes and then we will see later what we have to do with the old node group but we'll get there for now i'm going to fast forward to the end of this process it will take a while a lot of time not a while it will take a long long time i'm in a mood today and then then my mood goes terribly wrong when i need to wait but that's life [Music] let me interrupt fast forward this part is extremely annoying i cannot explain how annoyed i am and i know what you're thinking you're thinking that i'm annoyed that it takes so long and i am i'm very annoyed that it's so slow but what irritates me even more is that there is no status i don't know what's going on is it blocked is it hanging is it progressing we don't know or at least we cannot know by looking at the cli it would be great if it would provide some form of status hey everything is okay i'm upgrading the control plane which is most likely what is doing i don't know i cannot know what it's doing by looking at it it may be some estimated time to i don't know give me something that would give me hope that after 10 minutes of waiting or more this is not just hanging indefinitely but it's going to result in something useful so the lack of information about the progress is horrible you can get away with it if it takes a minute or two but when it takes 10 15 20 minutes or i don't i i stopped even counting time anymore and then it's very very disappointingly annoying yeah it did okay back to fast forward happy thoughts capitals finished oh my ah i cannot believe it's done okay this thing actually didn't take that much longer to be honest upgrading cluster is slow in all the vendors like it's slowing it takes like 20 15 20 sometimes half an hour in azure and google but are we finished with upgrading that's the question that's the real question we need to ask ourselves are is this it single command to update the cluster let's check it out cube cattle get nodes what are the nodes we have here in the cluster [Music] no not yet done so what this command did actually i mean i knew in advance i'm just pretending that this is a dramatic effect what that command did is it upgraded the cluster and in aws in eks terms upgrading the cluster doesn't mean upgrading the cluster it means upgrading the control plane so the control plane of our cluster is upgraded the nodes are not yet upgraded we need to do that next so we have our control plane upgraded let's see how we can upgrade the nodes the working nodes right because they're still running 1.17 control plane is 118. hey so we need to execute eqs cattle create node group that is specified in config file cluster 118. you remember how i showed you before in the config map that the name i changed the name of the node group now it will think that that node group doesn't exist and it will create it let's see oh configure that's a wrong argument config file you out okay now it is creating a new node group it is creating a node group based on kubernetes 1.18 and you know what comes next fast forwarding because this is this will so actually no before i fast forward let me let me let me retrieve my steps i said earlier that it's slow everywhere it's slow it takes 10 15 20 sometimes even 30 minutes in azure and google but they upgrade your whole cluster the nodes and the control plane and everything this was very slow considering that in all this time and i did not measure how many minutes but it was a lot all we accomplished so far was to upgrade the control plane now we are not even upgrading now the nodes remember you cannot upgrade worker nodes you cannot upgrade node group at least not that i know we are creating a new node group so that there will be new nodes based on 1.18 we're going to see later what what we should do with the old gold nodes that's coming later for now we are creating a second node group based on kubernetes 1.18 now fast forward [Music] okay we got a new node group so are we finished now with upgrading let's take a look cube cattle get notes so what do we have now we have six nodes this is ridiculous this is funny oh my god again i cannot blame eks couple this is how eks works anyways uh we can see that we have six notes and some of them are 1.17 some of them are 1.18 we still need to delete now the old group right so it is not doing rolling upgrades which are standard basically every single vendor is doing rolling upgrades except eks so we need to create a new node group we already did that that's what we just finished doing and now we need to delete this the old node group the one running 1.17 so how do we do that eks cattle delete node group and the config file is what is the config file cluster 1.18 and then only missing right so we are telling ekscattle that we want to create delete all the node groups that are not specified in that config file because we changed the name through that we created a new one and now we're telling telling it hey delete everything that is left over from before and there we go so we got the plan because whenever there is a destructive action or action that modifies the state of something we need to confirm it with the same command but then approve right and now we're deleting the node group and it should hopefully not take long i mean just deleting stuff it is not um actually it might take a while because it needs to evict all the pods and it might need to wait until the sick term signal responses are coming from the pods and so on and so forth so uh let's see it shouldn't take that much so i will fast forward still oh no it's finished no need for to pass forward okay excellent excellent the whole process is silly but i'm not trying to convince you to go somewhere else away from because this is a this is a session about tks so um what else um no let's check the notes cube cuddle get nodes and now we have almost uh three nodes right so the old nodes those based on 117 are being deleted now scheduling is disabled and they will be gone a few minutes later uh you need to trust me um it takes time because really the previous command did not terminate the whole process just send the signal hey delete it and deletion is now going on okay what else can we do um there is utilities we can we can install some add-ons let's see which add-ons we have so it's going to be eks cattle uh utils we want to describe add-on versions for the cluster oh not caster cluster devops catalog in the region us east 2 and then these are the add-ons we can use now unfortunately this moment the only other there is one addon only which is vpcc and i uh we might be able to extend it with our own we could write to our own but anyway not many others not much more we can do the last thing we're going to do right is to destroy everything we did and then we're going to talk about what we experienced and what's or not so uh destroying the cluster eks cattle we want to delete the cluster defined in config file cluster 1.8 and we want to wait until that is finished and this means you guessed right fast forward actually not fast forward i'm going to leave this running in a background let's go to the other screen and uh have a quick chat about eks in eks cattle and what's not so that was ekscattle is that the way how you should manage your eks clusters in aws maybe yes most likely i'm not sure that's a confusing answer isn't it so what i'm really trying to say is that it is definitely one of the two recommended or best ways to manage your cluster now the second one would be terraform i'm going to skip explaining why doing it from web ui or console is bad why aws cli uh is really horrible why chef and puppet are out of the game anymore and so on and so forth so it's really down to terraform and eks cattle which one i prefer now effects castle would be only command line that doesn't have a config file i would say without doubt it's not worth it you cannot store it in git you cannot do version control you cannot do the reviews and so on and so forth go with terraform but see cks cut allows us to specify those config files within with yaml that defines everything we need to have it's actually in some ways better than terraform now let me explain what in some ways that means terraform is still more versatile right it manages everything including eks so from that perspective terraform is much better now the problem with terraform and specifically related to eks is that you need a lot of things you need to define a lot of resources there is a lot it's not just hey i want the ks cluster no no no it's a lot of resources are involved in enabling eks cluster to work and as you saw before at the very beginning there we're talking about hundreds of lines of terraform hcl uh configuration for something that is not any better than what we just did in like 20 lines so eks cuttle is simpler it's straightforward it abstracts the things that are just silly that are not necessary for many people so i would say if you're looking for if simplicity is important without sacrificing uh a lot at least the versatility and then the ability to do things that you need i would say case cattle is is a better option terraform so if you want simple if you don't want to lose your hair over trying to figure out everything you need for creating and managing and upgrading and what's not an eks cluster go with eks couple now if you're a power user if you really really understand aws then terraform still might be a better option but and there is actually another thing another thing you might want to have in consideration if eks if kubernetes is only a fraction of what you have in aws then definitely terraform but if you're mostly running uh your stuff in kubernetes if the main workload that the majority of the workload is in kubernetes then yes eks cattle is is a good choice i think it's an excellent choice actually so go with it try it out let me know what you think and what else yes subscribe to the channel hit the like button you know the stuff buy the books i don't know maybe i should do commercial adding marketing is not my thing uh and see you next time cheers
Info
Channel: DevOps Toolkit
Views: 11,061
Rating: undefined out of 5
Keywords: eksctl create clusters, eksctl, cluster, clusters, kubernetes, k8s, aws, eks, elastic kubernetes service, eksctl create cluster, cli, infrastructure as code, IasC, weaveworks, amazon, aws eks tutorial, aws eks, aws eks kubernetes tutorial, kubernetes on aws, aws cloud, aws kubernetes tutorial, kubernetes aws tutorial, amazon web services, cloud computing, aws eks cluster setup, kubernetes tutorial, amazon eks, kubernetes cluster, aws kubernetes, eksctl tutorial, aws eks cluster
Id: pNECqaxyewQ
Channel Id: undefined
Length: 35min 29sec (2129 seconds)
Published: Tue Jan 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.