Kubernetes by AWS Management Console in step by step
Tags: awscommunitybuilder, aws, cloudskills, beginners
Published: 2022-11-26 16:38:08

**Outline**


 What is Kubernetes
 Kubernetes on AWS
 Why use Kubernetes
 How Kubernetes work
 Amazon EKS clusters
 Container orchestration
 Create EKS by AWS Management Console



** What is Kubernetes**

Kubernetes is open-source software that allows you to deploy and manage containerized applications at scale. Kubernetes manages clusters of Amazon Elastic Compute Cloud (EC2) compute instances and runs containers on those instances with processes for deployment, maintenance, and scaling. Using Kubernetes, you can run any type of containerized applications using the same toolset on-premises and in the cloud.

AWS makes it easy to run Kubernetes in the cloud with scalable and highly available virtual machine infrastructure, community-backed service integrations, and Amazon Elastic Kubernetes Service (EKS), a certified conformant, managed Kubernetes service.



** Kubernetes on AWS**

AWS makes it easy to run Kubernetes. You can choose to manage Kubernetes infrastructure yourself with Amazon EC2 or get an automatically provisioned, managed Kubernetes control plane with Amazon EKS. Either way, you get powerful, community-backed integrations to AWS services like Amazon Virtual Private Cloud (VPC), AWS Identity and Access Management (IAM), and service discovery as well as the security, scalability, and high- availability of AWS.



** Why use Kubernetes**

• RUN APPLICATIONS AT SCALE
• SEAMLESSLY MOVE APPLICATIONS
• RUN ANYWHERE
• ADD NEW FUNCTIONALITY


** How Kubernetes work**

Kubernetes works by managing a cluster of compute instances and scheduling containers to run on the cluster based on the available compute resources and the resource requirements of each container. Containers are run in logical groupings called pods and you can run and scale one or many containers together as a pod.
Kubernetes control plane software decides when and where to run your pods, manages traffic routing, and scales your pods based on utilization or other metrics that you define.
Kubernetes automatically starts pods on your cluster based on their resource requirements and automatically restarts pods if they or the instances they are running on fail. Each pod is given an IP 
 address and a single DNS name, which Kubernetes uses to connect your services with each other and external traffic.


** Amazon EKS clusters**

An Amazon EKS cluster consists of two primary components:

• The Amazon EKS control plane
• Amazon EKS nodes that are registered with the control plane

The Amazon EKS control plane consists of control plane nodes that run the Kubernetes software, such as etcd and the Kubernetes API server. The control plane runs in an account managed by AWS, and the Kubernetes API is exposed via the Amazon EKS endpoint associated with your cluster. Each Amazon EKS cluster control plane is single-tenant and unique, and runs on its own set of Amazon EC2 instances.

Amazon EKS nodes run in your AWS account and connect to your cluster's control plane via the API server endpoint and a certificate file that is created for your cluster.


** Container orchestration**

Container orchestration is the automation of much of the operational effort required to run containerized workloads and services. This includes a wide range of things software teams need to manage a container’s lifecycle, including provisioning, deployment, scaling (up and down), networking, load balancing and
more.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7i3a8cghaurbhg47h6p.png)



** Create EKS by AWS Management Console**

Before create eks cluster, we need to do some basically requests like **EKS cluster role**.

To create the Amazon EKS cluster role in the IAM console:
• Open the IAM console
• Choose **Roles**, then **Create role**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nadh2twy75gz4edew44l.png)


• Under **Trusted entity type**, select **AWS service**.
• From the **Use cases** for other AWS services dropdown list, 
  choose **EKS**.
• Choose **EKS - Cluster** for your use case, and then choose 
  **Next**.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obnzzjj5ozmj6ota2saj.png)


• On the **Add permissions** tab, choose **Next**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opj1e29chu56diwmdcjx.png)


• For **Role name**, enter a unique name for your role, such as eksClusterRole.
• For **Description**, enter descriptive text such as Amazon EKS - Cluster role.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/if7o2aevry3h6lx7pd9m.png)


• Then choose **Create role**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j1qtlsx0pq0egdaoiswk.png)


• The Role is successfully created.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kia0jq465yo1aiulimnv.png)


And we can add another permissions to the role by :
• choose the role that we are created.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ggg2pknoifmksxjd8sf.png)


• Select Add permissions then Attach polices .


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/461t9i5vdxj8toka95df.png)



• Search for the polices we need and choose it by click the check box


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ky6o9g5mbwz57xy0wsru.png)


• After add the polices click on Add polices.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ee36ii39fba52fo534a.png)


• Notice that all policies have been successfully attached to our role.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7a1nmybt5q5jjqsozpdu.png)



In the next step to create the cluster:
- **Open the Amazon EKS console at**
**https://console.aws.amazon.com/eks/home#/cluster**s .
From services choose **Containers** then choose **Elastic Kubernetes Service** .


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvbtixees99jzdzyj345.png)

- Choose Add cluster and then choose Create.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bnvp4ofegflsrz7o0b4c.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5w4en55nw6feobgppbj.png)


• Amazon EKS cluster is created in a VPC. Pod networking is provided by the Amazon VPC Container Network Interface (CNI) plugin.
So, the configuration of the networking :


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4zet3fuxh6lu1pvybhk.png)


• To enable private access for your Amazon EKS cluster's Kubernetes API server endpoint and limit, or completely disable, public access from the internet, you can choose the configure you need.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jogqt84cn7kpbrxt7u90.png)


• Other eks cluster network setting, then click on Next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yn1m4gblequ3g9up8cj2.png)


• We can enable any logs to Send audit and diagnostic logs from the Amazon EKS control plane to CloudWatch Logs, then click on Next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9qfc0p2hkne1ypalaa7.png)


• Next page show the Review and create for all component and setting of the eks cluster and you can modify any setting by click on Edit.
• After all click on Create.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rd0cprdx70lr6mimx4hq.png)


• The creation is in progress, and wait a few minutes to complete the creation.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iuiaqeg1lhm0ixkgwh6z.png)


• Notice that the cluster is Active, Now to configure the worker nodes :
• Click on Compute and choose Add node Group (which is the collection of nodes).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41pa44had163r0npnp71.png)


Step1-The configuration of node group:

1. Name: give any name for the group.
2. Role : select role for that will be used by the node, Or create a new role.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bh13p3jy2uycju2cyml2.png)



• To create the new role: Open the IAM console
• Choose **Roles**, then **Create role**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbb947352ljy454u00nf.png)


• Under **Trusted entity type**, select **AWS service**.
• From the **Use cases** for other AWS services dropdown list, choose **EC2**,and then choose **Next**.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8gjuyl478hfg10dxshw.png)


We need to choose the three permissions:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rzsb8y4ba2s0me2lysb.png)

Then click on **Next**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wcyqk1ih7tphzw2y0v32.png)


In the next step:
• chose name to the role , such as EKSWorkerNodeRole.
• Add a short explanation for this role.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3s4c6u3x5m28dxy7qmmd.png)

• In the same page we can see the permissions we chose it, and the click on **Create role**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yn1s1ddae3r9ndunyos4.png)

• When the role is created back to the previous tap:


• Refresh the (Node IAM role ) and choose the role the we are created.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3esgg73gi4verdw726d.png)


• In the same page, the next configurations:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sqqyefi937uzh3k5v8pd.png)


The next step is to Set compute and scaling configuration:
• Choose the AMI type (Select the EKS-optimized Amazon Machine Image for nodes).
• Capacity type (On-Demand or Spot).
• Select the instant type (here select t3.micro to save cost)
• Select the size of the attached EBS volume for each node.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bk91i5xoqrf7jdwx91hq.png)


• Set the **desired** , **Minimum** and **Maximum number** of nodes that the group should launch with initially, scale in to or scale out to.
• Then click on Next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfwy7k5v5xzavz9gy0w5.png)

• The next step is to select the subnet which is the network of the worker nodes.
(you can choose the default) , then click on Next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4mzettgeu2ppydnv07d.png)
Note, When enabling this option, managed node groups will create a security group on your behalf with port 22 inbound access. If launching your worker in a public subnet, it’s strongly recommended to restrict the source IP address ranges.

• If we select to configure the SSH access node we need to Select an SSH key pair to allow secure remote access to your nodes, or create a new SSH key pair.
• To create a new SSH key pair go to the corresponding page in the **EC2 console**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhl1470o0nzz7j2fohns.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wntv8n04a6yffh6ui5e.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cajxizr3zfiiaue90emd.png)

• The key pair was created and download in your machine.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ro2f2lo137wt7jbpgjh.png)

• Back to the previous tap and refresh the key pair space the choose the one we are created.
• Choose SG, then click on **Next**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5puoexdkqqc5mcle0l0.png)

• Next page show the Review and create for all component and setting of the node group and you can modify any setting by click on **Edit**.
• After all click on **Create**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgvgjwvstwvluefs84ix.png)

• The creation is in progress, and wait a few minutes to complete the creation.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qr8zt2rxwtmkyqlz483q.png)

• After refreshing the node group was created.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2f8hq3j5teu6gm3o94u5.png)


• Click on Node, notes that two nodes is created and its status is Ready.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zqmguyxuf1fxwb20qmrg.png)

• To delete the cluster, first delete the node group then delete the eks cluster.






<u>References:</u>

1) https://aws.amazon.com/kubernetes/
2) https://docs.aws.amazon.com/eks/latest/userguide/clusters.html
3)https://www.vmware.com/topics/glossary/content/containerorchestration.html