How to deploy a Kubernetes Cluster with Amazon EKS (Step by Step Lab demo) #kubernetes #aws

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to my channel AWS devops rich 11. in this video I'm going to touch a niche topic so we will see how to set up cuber latest cluster in AWS using eks so eks is a managed service that is used to manage your kubernetes clusters that is create and manage your kubernetes clusters eks elastic cuber latest service so I am going to give a lab demo on how can we create our kubernetes cluster using the E case so as I highlighted in my previous video on kubernetes these are all the various ways how we can set up the kubernetes cluster so if at all you want to set up a learning environment you can use mini Cube or Kai and if you want to go for a production setup we can use qkdm we can use cops or we can use Cube spray but if you want to set up the kubernetes clustered as a managed service within the cloud then we have Azure kubernetes service for Azure Cloud then we have eks for AWS cloud and we have Google kubernetes engine further Google Cloud so in this video we are going to see how to create a cuber that is clustered using eks in AWS so let us get into the lab demo so these will be our steps on how to implement this cluster in each case first is we will go ahead and launch an ec2 instance which I am calling it as a eks bootstrap okay so it will be a ec2 Linux instance and from this instance we are going to create a cluster then we will install the AWS CLA latest version which is the prerequisite then we will set up the latest version of cube CTL we will set up the latest version of EA CTN so eka CPL is the command line interface with which you can opt to the the kubernetes cluster in eks then we need an IAM role with the needed permissions which we need to attach it to the eks bootstrap instance then we will create the cluster we will validate the cluster and we will delete the cluster so this will be this will be our step-by-step instructions to create the kubernetes cluster in eks now let us go ahead into the lab the first step is launching an ec2 instance which is the eks bootstrap so let me go back to my AWS console and I'm in the ec2 dashboard gear so let me click instances I'll click launch instances so I will name this as eks bootstrap and in the Amis I'm just going to change it to the Amazon line X2 that should be sufficient P2 dot micro that is fine I'm going to select my existing keypad and with respect to the security group I am going to allow only SSH just from my IP address and let us go ahead and launch the instance okay this is the pending state it should shortly coming into the running state okay so the instance is in the running State let us go ahead and log into this instance I'll grab the public IP I will open the and let me select my private key okay now we have logged into the Linux instance which is the eks bootstrap so from here we will execute the commands to create the cluster one by one so let me go to my instructions here so first is launching an easy to it runs so this is done so the next step is installing the AWS CLI latest version right so for that let us go into this link and we will download and install the latest version of the AWS CLI okay so I'll click AWS CLI install and update instructions and let me go into the Linux section and you can see here we have some instructions for Linux x86 stick to 4 bit this is what we want so let me just copy this and I will put it here in the instance okay pseudo AWS installed we'll say enter okay fine so AWS CLI latest version has been installed now let us take a look at the version of the AWS CLI okay you can see here it is CLI 2.12.7 with python 3.11.4 okay so this is our first step to install the AWS CLI now what is our next step set up the cube CTL so we need to download the latest version of the cube so which I am going to do it from this particular link let me copy the link okay so I'll click this section install cubectl binary with curl on Linux and we have the the step for x8664 I'm going to copy this so this is for the latest version but if you see the node here if you want to download a specific version of cube CPL so you will have to replace this particular section with the actual version number that you want to download right instead of stable.thd you need to mention the the actual version of cube CTL that you would like to download okay if at all you want to go for a test version but if you want to install the latest version of cube CTL or sorry if at all you want to go for some older versions of the cube CL you can replace the staple.txt with a particular version number or if you want to go ahead with the latest version of cube CTL you can straight away copy this command so I will copy this command enter okay so Cube CTL has been downloaded now let us go ahead and give execute permissions so I will say chmod plus X for chmod Plus Cube CTL okay so I have given execute permissions to this Cube CTL binary and then we'll have to move the binary into the user local bin so I will say MV Cube ctls 2 USR slash local slash again so this is also done so let's verify if our Cube CTL installation is successful if I just give the command Cube CDL I'm getting all the flags that need to be used with the command so we are done with the cube CDL setup now what is our next step you have to set up the EK a CTL which I mentioned before it is a command line interface to interact with the kubernetes cluster in eks so now let us go ahead and download the latest release of eks so this is a command so let me copy this command so it is available in the GitHub repository okay now we have installed it and we have even more the binaries to the USR local bin now let us check what is the version of e a CTL okay it is 0.147.0 okay so that is a version of EK CTL that we are running let me also check order subversion of cube CTL okay so it is version 1.27.3 3 okay fine so we are done till the setup of the actl what is our next step it is a creation of IIM role and if even if I go back to my uh instructions here so we are done with setup of the ec2 instance we have installed the AWS CLI we have set up the cube CPL we have set up the EK CDL we have to create the IAM role and attach it to the bootstrap instance so that this instance will have necessary permissions in order to create a cluster in AWS so let now let us see what are all the permissions that we need to map it to the IIM Road so these are all the permissions so we need to have IIM full access easy to full access EPC full access cloud formation full access also we need to attach some policy also right so which is having this permission of TKS colon asterisk all the actions pertaining to the eks cluster we need to map that permission also as part of our role so now let me go ahead and create this IAM role in the AWS console so here let me search for iam and I'll click roles okay so what are all the permissions we need to map first is IIM full access so I will search for iam full access sorry I will first say create role okay so it is a AWS service and to which resource we are going to assign this role it is going to be assigned to the ec2 instance so I'm going to select ec2 here click next now we need to wrap up permissions so our first permission is game full access so let me copy this IAM full access I'm going to search for it here okay here it is so let me select it and I'm going to search for the next role next permission which is easy to full access on easy to full access I'll select that the third permission is VPC full access okay we see full access and the next one is cloud formation full access okay here it is so now we have mapped all these four permissions to this role I'll give it I'll give it a name as vks oh okay so this role will give all the necessary permissions for our eks bootstrap instance to launch the cluster in AWS now let me go ahead and create row okay now you can see that the role has been created but this is not sufficient as I mentioned before you need to attach one custom policy also in which the actual eks colon asterisks is defined so how do we create this custom policy I will click policies here and I will say create policy and I will click Json because policy will be generally in the Json format so what I will do is I am going to directly copy this impact which is having that the custom code and I'm pasting it here and I will say next okay and let me give the name for this policy as eks custom let us go ahead and create this policy right now this policy is also created now what we need to do we have to go back to our role and attach this policy also along with those four permissions I will search for eks rule now you can see here these are all the four permissions that we have mapped to this particular role now we need to add a policy also I will say add permissions attach policies and which is our policy name the custom policy name it is eks custom so I'm going to select that and I will click add permission now use you will see that this role is assigned with all the needed permissions these are all the standard permissions this is one custom policy what we have assigned to this rule right so we are done with our next step also in terms of creating an IAM role but we have not still assign this role to our ec2 instance right so that is our next step we need to assign this role to our eks bootstrap instance so how do I do that select this instance go to actions security modify IAM room and here you select this eks rule one word that we created and just say update I am now we have assigned this role to the ec2 instance so I think now with this we are done with all the prerequisites uh before we create our cluster in EAS now let us go ahead and create our cluster so this is a command eks CTL create cluster minus minus name this is your cluster name then we have to define the region where we are hosting the cluster and what should be the type of the node within that cluster what should be the type of instance should it be a T2 dot small or should it be a T2 dot micro so this depending on the type of workloads that we are going to run in your cuber that is clustered you have to select the the instance type accordingly but for our lab purpose here I'm going to just use this command let me copy this EK CTL create cluster minus minus name I am naming the cluster as test hyphen cluster and the region is Us West 2 maybe I will launch it in the North Korea itself so I'm going to change the region name as us hyphen East hyphen 1. which is for North Virginia and the node type instance type I'm selecting is E2 dot spot enter now you can see that it has started creating a cluster so if at all we had any permission issues we would have got the error know itself but now it is telling that it is basically deploying the stack so what it will do is this command is going to create a a stack in cloud formation so it is going to create a stack in the cloud formation and that start creation will involve creation of all the needed components for your kubernetes cluster so that involves your ec2 instances Auto scaling groups some Route 53 hosted zones Etc everything will be managed end to end by the ease itself okay so this is going to take some time maybe 15 to 20 minutes so I'm going to pause the video for some time and once a cluster is online we can continue further hi everyone welcome back so the cluster has got created you can see this message uh this eks cluster test hyphen cluster in the U.S hyphen East hyphen region is ready okay so now our cluster is created as I mentioned before this cluster is actually created via the cloud formation stack okay so if you see here I'm in the cloud formation dashboard it has basically created uh two stacks here okay and if I check this uh stack for EK CTL test cluster now you can see that these are all the the various resources it has created there is a shared node Security Group there is a control plane all the associated security groups we have an internet gateway in that Gateway lat IP all the needed subnets uh cloudwatch metrics or the permissions for the elb so there are so many components that got created as part of the cluster creation through this cloud formation stack and if I go back again if I click the first stack here also you can see that there is a launch template there is a managed node group there is a node instance role so so many components got created so now we will validate our cluster so this is a command to validate the cluster so I just say eks CTL get cluster okay I think we need to give the region name also so get cluster minus minus region U.S hyphen each hyphen one so you can see here this is a cluster that is available in the North Virginia region and we can also give the command qccl its nodes in order to see what are all the the nodes or the instances that is running as part of the cluster so you can see that we have two instances that is running which is running the version 1.25.9 this is part of the you know the kubernetes cluster created as part of eks okay so we can also check that the instance dashboard as well so if I go to my ec2 dashboard you can see here these are all the two nodes that is part of the eks cuber latest cluster okay so now whatever deployments that we will create they will be created on these any of these modes okay now we will see how to create a deployment under service using this eks cluster on how to access that application via other cluster right so so this is a command I'm going to use I am going to create a tomcat application on our ecase cluster by creating a deployment so by creating deployment we can create the pods as well automatically so let me use this command to create a deployment so Cube CTL create deployment my deployment name is stopped at hyphen deployment okay and the image what will be downloaded from the docker Hub it will be Tomcat colon 8.0 okay so now I'll say enter you can see that it has created the deployment with the name Tomcat hyphen deployment we can verify the command Cube CTL get deployed you can see that it is saying uh zero slash Oneness ready so it's still spinning up the deployment now it is ready now creation of the deployment will automatically create the parts as well so we can check what part it has created sub Cube CTL get bot you can see here this is a part that it has created and there is one part which is running one Tomcat container okay so we can also see some additional information about the part Cube CTL get pod minus o y you can see here this is the odd IP address well this is the quad name now how do we access this Tomcat application from the outside world so we saw various service types so first and foremost we need to create a service and we need to configure a service type also the service type can be a cluster IP it can be a load balancer it can be an external name there are multiple times which we saw in my last video so in this lab I am going to create a service type as a load balancer in order to expose our Tomcat application running on the eks cluster so let me expose our deployment as a service so this is a command Cube CTL exposed deployment the deployment name the port will be 8080 because there is a default port for the Tomcat application and what is the service type it is load balancer so I am going to access this Tomcat application via the load balancer or any external use cell whoever wants to access the Tomcat application running on the eks cluster he will be able to access it via the load balance okay so this is my command to expose my deployment as a service via the load balance you can see here it is saying service Tomcat hyphen deployment exposed so Cube CTL yet service minus o y in order to look into the details of that serving so there is a default cluster IP address and this is the the load balancer that it has pinned up as you can see here for the Tomcat deployment this is a IP address of the load balancer and this is the load balancer endpoint so if you want to access the Tomcat application we need to give this a load balancer endpoint in the browser and we need to use the port 8080 because that is a port we have defined here also when we expose the deployment we have mentioned the port as 8080 so we can access the application using the load balancer on port 8080 okay so let us verify it so let me go to my AWS console and we can also go to the load balances to see whether this load balancer is successfully provisioned you can see here this is the load balancer only F6 one ef6 right and let me see whether the instances on this load balancer or in the healthy state if I click instances okay you can see here both the instances are in in service state so we should be good the load balancer is healthy now now let us try to access the the Tomcat application from this load balancer so how do you do that just let me grab the DNS name of the load balancer and I'll put it here I will say colon 8080 because that is a port on which we can access the Tomcat application so load balancer endpoint colon supports 8080 enter can you see here now we can access the Tomcat application which is running on the eks cluster right so we created the service type as a load balancer we entered the load balancer endpoint in the browser and we gave the port that is colon 8080 to access our Tomcat application okay so I hope this is clear how to create an eks cluster how to create a deployment in the eks cluster how to expose the deployment as a service using load balancer as a service type so that's all I had pretty much on this video so now we will see the command how to delete the cluster so it's important that you delete your cluster also once you create it because it is going to take up a lot of resources and you might be charged as well so once you have done your testing or you know checked your access of the application Etc it's better to delete the cluster immediately this is a command to delete the cluster you can say EK CDL delete cluster the cluster name so in my case it is test hyphen cluster and you can also give the region name minus minus region us hyphen against hyphen one that's it so this command will delete your cluster and before that it will also delete the deployments and services whatever you created so in our case we created a tomcat deployment we also created a service using load balancer as a service type so first it will clean all those and then it will delete the cluster as I hope this video was helpful so if I tell you like this video please press the like button and if at all you want to share it with your lonesome of course please feel free to share this video so thank you so much everyone and I will meet you all in my next video
Info
Channel: awsdevopsniche11
Views: 12,624
Rating: undefined out of 5
Keywords: managing deployments using kubernetes engine, eks aws, aws eks kubernetes tutorial, kubernetes project, kubectl, kubectl commands, eks in aws, create eks cluster aws using terraform, eksctl, how to setup eks cluster in aws, eks kubernetes, aws load balancer controller eks, ecs and eks in aws, eks workshop aws, setup eks cluster aws, aws eks project, aws eks terraform, create aws eks cluster, aws kubernetes, how to create kubernetes cluster in aws, kubernetes aws tutorial
Id: 8QX50F0IBYs
Channel Id: undefined
Length: 28min 29sec (1709 seconds)
Published: Thu Jul 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.