Kubernetes is an open-source software that helps you manage and deploy your containerized applications. Kubernetes consists of two major component control planes (which decide where to run your pod) and a worker node (where your workload runs). As Kubernetes is a complex system, managing these components is challenging, and this is where you can use a Kubernetes as a Service solution like Amazon Elastic Kubernetes Service (EKS). In this blog, we will see how you can set up and manage EKS and take advantage of the native integration of EKS with other AWS services (Amazon CloudWatch, Amazon VPC, etc.).
Amazon EKS is a managed Kubernetes service that makes it easy to run Kubernetes on AWS without installing and managing your Kubernetes cluster. AWS takes care of all the heavy lifting like cluster provisioning, performing upgrades and patching. EKS runs the upstream Kubernetes version, so you can easily migrate your existing Kubernetes cluster to AWS without changing the codebase. EKS runs your infrastructure to multiple availability zones, eliminating a single point of failure.
An AWS EKS cluster consists of two primary components:
Amazon EKS will completely manage your controlplane, but how much or little control you need to manage your data plane depends on your requirements. AWS gives three options to manage your data plane nodes.
In this competitive cloud market, there are numerous cloud providers that offer services which support the usage of Kubernetes. Here is the comparison to help you pick a cloud provider that meets your needs better.
Before selecting a managed Kubernetes service, it's vital to know the strengths and weaknesses of each. All managed services solve your goal of easily deploying your Kubernetes cluster. The first decision is where your existing workload is running. It might be easier to remain with the cloud provider you already use.
Some comparisons between the three managed services:
These were the major differences between the three cloud offerings in how they offer Kubernetes solutions.
Here are the primary reasons to use EKS:
This section will show how to set up your EKS cluster using eksctl. It is a simple command-line utility that helps you set up and manage the EKS cluster. For more information, check the documentation at https://github.com/weaveworks/eksctl.
You must fulfill a few prerequisites before installing and setting up the EKS cluster using eksctl.
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/118aa784c92901084ec5dae0c6de559e.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/6d6054023072c6b36bcbc98e54e399c9.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/2fcf09165175ac9f3b8a1027072d98c1.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/239bad94dc94a48a1d3049e3a62b03bd.js</p>
NOTE: To install Kubectl on other platforms like Windows or Mac, check the following documentation: https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/33aed411295adb613796624510416329.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/49b92d1b5a993982ee59709a5abc0339.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/76e228ad268a7c9d3328dc4c188f39e4.js</p>
The next step is to create the EKS cluster with all the prerequisites in place. Run the eks cluster command and pass the following options
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/083feffaebbe3b28de9fa03863788a3b.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/04672e38406fc79b1ece2675f1983e91.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/9c4955e682653ab959e09a4c2cd2fad9.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/0999a26ba33dfadb18a0be3e772a8b1a.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/8f5d54f8f4fac3d166b147839442a292.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/9497e2c1fce3a737ce0976160824c097.js</p>
At this stage, your EKS cluster is up and running. The next step is to install CloudWatch container insight to collect your metrics. But first, ensure that the identity and access management (IAM) policy is attached to your instance. In this case, you need a CloudWatch Full Access policy for your worker node so it can push metrics to CloudWatch.
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/242d1df61175481a3fa506be40dccf0d.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/71393c71fe32e1bd379c41e63239c102.js</p>
AWS EKS supports virtual private cloud (VPC) networking using the AWS VPC Container Network Interface (CNI) plugin for Kubernetes. Using this plugin, Kubernetes pods have the same IP as on the VPC network. For more information, check the following link: https://github.com/aws/amazon-vpc-cni-k8s
For EKS, authorization is managed by role-based access control (RBAC) for Kubernetes commands, but for AWS commands, identity and access management (IAM) manages both authentication and authorization. EKS is tightly integrated with the IAM authenticator service, which uses IAM credentials to authenticate the Kubernetes cluster. This greatly helps to avoid managing separate credentials for Kubernetes access. Once an identity is authenticated, RBAC is used for authorization. Here is the step-by-step procedure:
Amazon Elastic Container Registry (ECR) Repository is a fully managed registry to store container images. Every AWS account comes with a single (default) ECR registry, but you can create one or more registries to store container images. ECR is well-integrated with other AWS services like identity and access management (IAM), and you can use it to set permissions to control access. You can use ECR to store other artifacts like Helm charts.
To push your image to ECR Repository, follow these steps
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/03115d33661e1df3fbb1ab5456af8a94.js</p>
NOTE: The authentication token is valid only for 12 hours from when it is issued.
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/9b45adbee4797d924a48fe3536e534e4.js</p>
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/3fda5f90028b3809795d45881b06e2a0.js</p>
NOTE: 1234567890 is your AWS account ID. Replace it with your account ID.
<p>CODE: https://gist.github.com/ShubhanjanMedhi-dev/598249327fde372096acc453f62eebcd.js</p>
Amazon EKS is one of the most widely used Kubernetes managed services. In this blog, you have learned how to set up an EKS cluster and deploy your workload. One of the primary advantages of using EKS is its integration with AWS services like identity management and virtual private cloud. Also, AWS will take care of all the heavy lifting like patching, performing an upgrade and provisioning your cluster. On top of that, if you use AWS offerings like Fargate, AWS will manage your worker node.