2048 Game Deployment on EKS using Fargate
Table of contents
Install AWS CLI along with eksctl on Windows 11 using Chocolatey Package Manager.
Create Fargate Profile in namespace alb-sample-app in namespace game-2048
Now, Deploy the Deployment, Service, and Ingress from the reference yml file.
Create an Ingress controller using AWS Application Load Balancer (ALB) for Ingress.
Install AWS CLI along with eksctl on Windows 11 using Chocolatey Package Manager.
if you don't have Chocolatey Package Manager on Windows follow the process: https://chocolatey.org/install
now install eksctl using choco install eksctl
configure AWS CLI
All Set.
Create EKS Cluster
Create EKS Cluster using the following command
eksctl create cluster --name demo-cluster --region ap-south-1 --fargate
we have used AWS Farget as a serverless compute engine for the containers. Fargate allows you to deploy and manage containerized applications without having to manage the underlying infrastructure.
It might take up to 10-15 minutes to start your EKS cluster.
Create Fargate Profile in namespace alb-sample-app in namespace game-2048
Now, Deploy the Deployment, Service, and Ingress from the reference yml file.
kubectl apply -f
https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/examples/2048/2048_full.yaml
COPY
COPY
---
apiVersion: v1
kind: Namespace
metadata:
name: game-2048
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: game-2048
name: deployment-2048
spec:
selector:
matchLabels:
app.kubernetes.io/name: app-2048
replicas: 5
template:
metadata:
labels:
app.kubernetes.io/name: app-2048
spec:
containers:
- image: public.ecr.aws/l6m2t8p7/docker-2048:latest
imagePullPolicy: Always
name: app-2048
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
namespace: game-2048
name: service-2048
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
type: NodePort
selector:
app.kubernetes.io/name: app-2048
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: game-2048
name: ingress-2048
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service-2048
port:
number: 80
Create an Ingress controller using AWS Application Load Balancer (ALB) for Ingress.
currently, our ingress-2048 doesn't have any ADDRESS so to fix this we will create ALB for Ingress, these will involve several Steps.
6.1 Create IAM OIDC Identity Provider: The ALB Ingress Controller requires an IAM OIDC identity provider. You can create one using the AWS CLI:
6.2 Create IAM Policy and Role: Create an IAM policy and role that grants the necessary permissions to the ALB Ingress Controller.
Download IAM Policy: curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json
this will download a file named "iam_policy.json".
6.3 Create IAM Policy
aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy --policy-document
[file://iam_policy.json
](file://iam_policy.json)
6.4 Create IAM Service Account :
eksctl create iamserviceaccount --cluster= --namespace=kube-system --name=aws-load-balancer-controller --role-name AmazonEKSLoadBalancerControllerRole --attach-policy-arn=arn:aws:iam:::policy/AWSLoadBalancerControllerIAMPolicy --approve
After completing all the Steps proceed to Step 7 i.e. Deploy the ALB Controller.
Deploy ALB Controller using HELM
Add Helm Repo : helm repo add eks
https://aws.github.io/eks-charts
Update Helm Repo : helm repo update eks
Install ABL Controller:
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system --set clusterName= --set serviceAccount.create=false --set
serviceAccount.name
=aws-load-balancer-controller --set region= --set vpcId=
- Verify it from EC2 > Load Balancers
Access the Application
Furthermore, You can use Route 53 for DNS Configuration.
Thank you for Reading.
Subscribe to my newsletter
Read articles from V S S Ram S directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
V S S Ram S
V S S Ram S
๐ DevOps Engineer | Bridging the Gap Between Development and Operations โ๏ธ Passionate about creating seamless software delivery pipelines and optimizing infrastructure for innovation. I thrive on automating processes, enhancing collaboration, and ensuring the reliability and scalability of applications. With a strong foundation in continuous integration/continuous deployment (CI/CD), containerization, and cloud technologies, I'm here to transform the development landscape. Let's make technology work smarter, not harder. ๐ป๐ง