{"id":386,"date":"2024-07-03T02:06:00","date_gmt":"2024-07-03T02:06:00","guid":{"rendered":"https:\/\/cloudtechs.club\/?page_id=386"},"modified":"2024-07-10T01:19:25","modified_gmt":"2024-07-10T01:19:25","slug":"how-to-create-eks-cluster-using-aws-cli","status":"publish","type":"page","link":"https:\/\/cloudtechs.club\/index.php\/how-to-create-eks-cluster-using-aws-cli\/","title":{"rendered":"How to Create EKS Cluster Using AWS CLI"},"content":{"rendered":"\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>The AWS Command Line Interface (AWS CLI) may be used to create an Amazon Elastic Container Service for Kubernetes (EKS) cluster, providing a hands-on and customized approach to cluster management. This post will show you through the process of installing and configuring the AWS CLI, as well as how to construct an EKS cluster and set up the kubectl client tool.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Deploy an Amazon EKS Cluster using the AWS CLI, kubectl and eksctl #kubernetes #k8s #trending\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/jHdykkqo0Qg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">                         <strong><em>  Deploy an Amazon EKS Cluster using the AWS CLI, kubectl and eksctl<\/em><\/strong><\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<p><strong>Overview<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>Step 1: Install AWS CLI and Configure<\/strong><\/p>\n\n\n\n<p>For this lab purpose , I have created workstation node on AWS platform by using Amazon Linux image which is pre-configured with AWS CLI. In order to configure AWS CLI please use below document as per operating system requirements.<br><br><a href=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/getting-started-install.html\" data-type=\"link\" data-id=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/getting-started-install.html\">https:\/\/docs.aws.amazon.com\/cli\/latest\/userguide\/getting-started-install.html<\/a><\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>To configure AWS CLI, Run below command.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;ec2-user@ip-172-31-24-209 ~]$ aws configure<\/code><\/code><\/pre>\n\n\n\n<p>This command will prompt you to enter your AWS access key ID, secret access key, default region name, and default output format. You can obtain your access key ID and secret access key from the AWS Management Console.<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>Step 2: Setup repository install and set up kubectl on Linux<\/strong><br><a href=\"https:\/\/v1-29.docs.kubernetes.io\/docs\/tasks\/tools\/install-kubectl-linux\/\">https:\/\/v1-29.docs.kubernetes.io\/docs\/tasks\/tools\/install-kubectl-linux\/<\/a><\/p>\n\n\n\n<p>Add the Kubernetes yum repository. If you want to use Kubernetes version different than v1.30, replace v1.30 with the desired minor version in the command below.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;ec2-user@ip-172-31-24-209 ~]$ cat &lt;&lt;EOF | sudo tee \/etc\/yum.repos.d\/kubernetes.repo\n&#91;kubernetes]\nname=Kubernetes\nbaseurl=https:\/\/pkgs.k8s.io\/core:\/stable:\/v1.30\/rpm\/\nenabled=1\ngpgcheck=1\ngpgkey=https:\/\/pkgs.k8s.io\/core:\/stable:\/v1.30\/rpm\/repodata\/repomd.xml.key\nexclude=kubelet kubeadm kubectl cri-tools kubernetes-cni\nEOF<\/code><\/code><\/pre>\n\n\n\n<p><strong>Install kubectl using yum:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;root@ip-172-31-24-209 ec2-user]# yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes<\/code><\/code><\/pre>\n\n\n\n<p><strong>Enable and start Kubelet service.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;root@ip-172-31-24-209 ec2-user]# systemctl enable --now kubelet\n&#91;root@ip-172-31-24-209 ec2-user]# systemctl start --now kubelet<\/code><\/code><\/pre>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>Step 3: Install eksctl on Linux using curl command.<\/strong><br><a href=\"https:\/\/docs.aws.amazon.com\/emr\/latest\/EMR-on-EKS-DevelopmentGuide\/setting-up-eksctl.html\" data-type=\"link\" data-id=\"https:\/\/docs.aws.amazon.com\/emr\/latest\/EMR-on-EKS-DevelopmentGuide\/setting-up-eksctl.html\">https:\/\/docs.aws.amazon.com\/emr\/latest\/EMR-on-EKS-DevelopmentGuide\/setting-up-eksctl.html<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;root@ip-172-31-24-209 ec2-user]# curl --silent --location \"https:\/\/github.com\/weaveworks\/eksctl\/releases\/latest\/download\/eksctl_$(uname -s)_amd64.tar.gz\" | tar xz -C \/tmp\n&#91;root@ip-172-31-24-209 ec2-user]# sudo mv \/tmp\/eksctl \/usr\/local\/bin\n&#91;root@ip-172-31-24-209 ec2-user]# eksctl version<\/code><\/code><\/pre>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>Step 4: Create EKS Cluster<\/strong><br>Now that you have the required network infrastructure in place, you can create the EKS cluster. You can create the cluster using the following command:<br><a href=\"https:\/\/docs.aws.amazon.com\/eks\/latest\/userguide\/getting-started-eksctl.html\">https:\/\/docs.aws.amazon.com\/eks\/latest\/userguide\/getting-started-eksctl.html<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;root@ip-172-31-24-209 ec2-user]# eksctl create cluster --name=eksclicluster01 --region=eu-west-2 --zones=eu-west-2a,eu-west-2b,eu-west-2c --without-nodegroup<\/code><\/code><\/pre>\n\n\n\n<p>After you have run the create-cluster command, you need to wait for the cluster to be created. This can take several minutes. You can check the status of the cluster using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&#91;root@ip-172-31-24-209 ec2-user]# aws eks describe-cluster --name eksclicluster<\/code><\/pre>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>Step 5: Provide necessary IAM role and permissions for nodegroup creation.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;root@ip-172-31-24-209 ec2-user]# eksctl utils associate-iam-oidc-provider --region eu-west-2 --cluster eksclicluster01 --approve<\/code><\/code><\/pre>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>Step 6: Create Node Group<\/strong><\/p>\n\n\n\n<p>EKS clusters consist of control plane nodes and worker nodes. You need to create a node group to run your workloads on the worker nodes. You can create a node group using the following command:<\/p>\n\n\n\n<p>Please keep in mind that for this step, I have created the key pair &#8220;eksnodegroup&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"117\" src=\"https:\/\/cloudtechs.club\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-03-at-7.31.25\u202fAM-1024x117.png\" alt=\"\" class=\"wp-image-387\" srcset=\"https:\/\/cloudtechs.club\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-03-at-7.31.25\u202fAM-1024x117.png 1024w, https:\/\/cloudtechs.club\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-03-at-7.31.25\u202fAM-300x34.png 300w, https:\/\/cloudtechs.club\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-03-at-7.31.25\u202fAM-768x88.png 768w, https:\/\/cloudtechs.club\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-03-at-7.31.25\u202fAM-535x61.png 535w, https:\/\/cloudtechs.club\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-03-at-7.31.25\u202fAM.png 1457w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>\n<code>&#91;root@ip-172-31-24-209 ec2-user]# eksctl create nodegroup --cluster=eksclicluster01 --region=eu-west-2 --name=production-project --node-type=t3.medium --nodes=2 --nodes-min=2 --nodes-max=4 --node-volume-size=20 --ssh-access --ssh-public-key=eksnodegroup --managed --asg-access --external-dns-access --full-ecr-access --appmesh-access --alb-ingress-access<\/code>\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">After you have run the create-nodegroup command, you need to wait for the node group to be created. This can take several minutes. You can check the status of the node group using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>\n<code>&#91;root@ip-172-31-24-209 ec2-user]# aws eks describe-nodegroup --cluster-name eksclicluster01 --nodegroup-name production-project<\/code><\/code><\/pre>\n\n\n\n<p>Once the node group has been created, you should now have a fully functional EKS cluster that you can use to run your containers.<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>Step 7: You can verify the cluster information using below commands.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;root@ip-172-31-24-209 ec2-user]# kubectl get nodes\nNAME STATUS ROLES AGE VERSION\nip-192-168-1-180.eu-west-2.compute.internal Ready 4m9s v1.29.3-eks-ae9a62a\nip-192-168-80-227.eu-west-2.compute.internal Ready 4m3s v1.29.3-eks-ae9a62a<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><code>&#91;root@ip-172-31-24-209 ec2-user]# eksctl get nodegroup --cluster=eksclicluster\nCLUSTER NODEGROUP STATUS CREATED MIN SIZE MAX SIZE DESIRED CAPACITY INSTANCE TYPE IMAGE ID ASG NAME TYPE\neksclicluster usaproject ACTIVE 2024-05-28T20:04:08Z 2 4 2 t3.medium AL2_x86_64 eks-usaproject-9ac7e066-c40c-4d9b-a449-41b9726e10d7 managed<\/code><\/code><\/pre>\n<\/div><\/div>\n\n\n\n<p>Let me know your thoughts in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The AWS Command Line Interface (AWS CLI) may be used to create an Amazon Elastic Container Service for Kubernetes (EKS) cluster, providing a hands-on and customized approach to cluster management. ","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-386","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/pages\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/comments?post=386"}],"version-history":[{"count":8,"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/pages\/386\/revisions"}],"predecessor-version":[{"id":416,"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/pages\/386\/revisions\/416"}],"wp:attachment":[{"href":"https:\/\/cloudtechs.club\/index.php\/wp-json\/wp\/v2\/media?parent=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}