AWS EKS
AWS EKS 🌱
Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that simplifies the deployment, management, and scaling of containerized applications using Kubernetes on AWS infrastructure.
Overview 📝
This project showcases the seamless experience of utilizing Amazon Elastic Kubernetes Service (EKS) by deploying a delightful application game called ‘pod-birds’ 🐦 onto the EKS cluster.
Features ✨
Managed Kubernetes Service: Enjoy the benefits of a fully managed Kubernetes service with Amazon EKS, eliminating the need for manual setup and maintenance of Kubernetes control plane components, enabling you to focus on building and deploying your applications.
Simplified Deployment with kubectl: : Streamline the deployment process of containerized applications with Amazon EKS, using the familiar kubectl command-line tool to interact with your Kubernetes cluster.
Integration with AWS Services: Seamlessly integrate Amazon EKS with other AWS services such as AWS IAM and AWS LB enhancing the overall efficiency and capabilities of your Kubernetes deployment.
Cost Optimization: Optimize your infrastructure costs with Amazon EKS using serverless - Fargate.
High Availability: Ensure high availability for your applications with Amazon EKS, leveraging multi-AZ deployment options.
pre-requisites
- awscli - Command line tool for working with AWS services here
- eksctl - Command line tool for working with EKS clusters here.
- kubectl - Command line tool for working with kubernetes API here.
Setup Instructions 🚧
- Create an access key for your user and from IAM user section better to use user which has admin access.
- Configure the access key in the system using aws cli
1 2
#The below command will prompt for ACCESSKEY and PASSWORD aws configure
- Now that the aws cli configuration setup is done, let’s create the (fargate) cluster from the command line, this will take sometime:
1
eksctl create cluster --name <your-cluster-name> --region <region> --fargate
This creates a VPC by itself with public/private subnet hence we don’t have to manually create it.
Let’s check if the cluster is created, goto AWS EKS -> Cluster
- Check if the kubeconfig file is having the correct details i.e. it is aws eks context, server settings. Run below to configure kube config.
1
aws eks update-kubeconfig --region <region> --name my-cluster
- Create fargate profile to attach to the namespace
1
eksctl create fargateprofile --cluster <your-cluster-name> --namespace development --name flying-bird-fargate
If fargate profile is not created, the pods which are supposed to be deployed to development namespace, will not be deployed, it is to link the fargetprofile with the namespace.
- Now Let’s deploy the application, it will create deployment, service and ingress
1 2
curl -O https://raw.githubusercontent.com/erom-teknas/pod-birds/main/bird-pods.yml kubectl -f bird-pods.yaml
Note the ingress will not be in effect as we have not deployed the ingress controller, which we will see in below steps.
- Check if the deployment of the bird-pod is done.
1 2
# You should see bird-pod-xx running kubectl get pods -n development
- Now let’s download the IAM policy provided by aws-loadbalancer-controller.
1
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json
- Create the policy using the iam_policy.json
1
aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy --policy-document file://iam_policy.json
- Create the service account using eksctl for the aws-load-balancer-controller in EKS and a role for it, using the below command.
1 2 3 4 5 6 7
eksctl create iamserviceaccount \ --cluster=<your-cluster-name> \ --namespace=kube-system \ --name=aws-load-balancer-controller \ --role-name AmazonEKSLoadBalancerControllerRole \ --attach-policy-arn=arn:aws:iam::<your-aws-account-id>:policy/AWSLoadBalancerControllerIAMPolicy \ --approve
- Install the ALB controller in the kube-system namespace for ingress to work.
1 2 3 4 5 6 7 8
helm repo add eks https://aws.github.io/eks-charts helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system \ --set clusterName=<your-cluster-name> \ --set serviceAccount.create=false \ --set serviceAccount.name=aws-load-balancer-controller \ --set region=<region> \ --set vpcId=<your-vpc-id>
- Once the ALB controller is installed correctly, the ALB controller will create the ALB load balancer based on the rules set in the ingress object as part of (kubectl -f bird-pods.yaml)
Testing 🧪
- Verify using the ALB URL if you are able to access the browser
Resources 📚
- AWS EKS OIDC
- AWS EKS