How to deploy Game-2048 application in AWS EKS cluster (with Fargate option) | Technical EJ - Latest Technology News

Wednesday, 7 May 2025

How to deploy Game-2048 application in AWS EKS cluster (with Fargate option)

  Ekansh Jain       Wednesday, 7 May 2025

Hi Everyone,

I have written an article on how to deploy the game 2048 application on the AWS EKS service using the Fargate method. 


Following are the steps(or commands) to deploy this application.

1. eksctl create cluster --name game-2048 --region ap-south-1 --fargate



Networking of VPC


2. eksctl create fargateprofile --cluster game-2048 --region ap-south-1  --name game2046-fargateprofile --namespace game-2048


3. kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.8.0/docs/examples/2048/2048_full.yaml

namespace/game-2048 created

deployment.apps/deployment-2048 created

service/service-2048 created

ingress.networking.k8s.io/ingress-2048 created

4. kubectl get po -n game-2048

NAME                              READY   STATUS    RESTARTS   AGE

deployment-2048-bdbddc878-hj5bc   1/1     Running   0          105s

deployment-2048-bdbddc878-jvjwl   1/1     Running   0          105s

deployment-2048-bdbddc878-nl7lr   1/1     Running   0          105s

deployment-2048-bdbddc878-vrq58   1/1     Running   0          105s

deployment-2048-bdbddc878-x6kkw   1/1     Running   0          105s

5. curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.12.0/docs/install/iam_policy.json

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100  8912  100  8912    0     0   515k      0 --:--:-- --:--:-- --:--:--  543k

6. aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicyForGame2048 --policy-document file://iam_policy.json

{

    "Policy": {

        "PolicyName": "AWSLoadBalancerControllerIAMPolicyForGame2048",

        "PolicyId": "ANPAZNKPEIHBJUHxxxxxx",

        "Arn": "arn:aws:iam::xxxxxxxxxxxx:policy/AWSLoadBalancerControllerIAMPolicyForGame2048",

        "Path": "/",

        "DefaultVersionId": "v1",

        "AttachmentCount": 0,

        "PermissionsBoundaryUsageCount": 0,

        "IsAttachable": true,

        "CreateDate": "2025-05-01T07:05:39+00:00",

        "UpdateDate": "2025-05-01T07:05:39+00:00"

    }

}

7.

oidc_id=$(aws eks describe-cluster --name game-2048 --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 5)

aws iam list-open-id-connect-providers | grep $oidc_id | cut -d "/" -f4

eksctl utils associate-iam-oidc-provider --cluster game-2048 --approve

2025-05-01 07:10:15 [ℹ]  will create IAM Open ID Connect provider for cluster "game-2048" in "ap-south-1"

2025-05-01 07:10:16 [✔]  created IAM Open ID Connect provider for cluster "game-2048" in "ap-south-1"

8. eksctl create iamserviceaccount --cluster=game-2048 --namespace=kube-system --name=aws-load-balancer-controller-for-game2048 --attach-policy-arn=arn:aws:iam::xxxxxxxxxxxx:policy/AWSLoadBalancerControllerIAMPolicyForGame2048 --override-existing-serviceaccounts --region ap-south-1 --approve

2025-05-01 07:14:59 [ℹ]  1 iamserviceaccount (kube-system/aws-load-balancer-controller-for-game2048) was included (based on the include/exclude rules)

2025-05-01 07:14:59 [!]  metadata of serviceaccounts that exist in Kubernetes will be updated, as --override-existing-serviceaccounts was set

2025-05-01 07:14:59 [ℹ]  1 task: { 

    2 sequential sub-tasks: { 

        create IAM role for serviceaccount "kube-system/aws-load-balancer-controller-for-game2048",

        create serviceaccount "kube-system/aws-load-balancer-controller-for-game2048",

    } }2025-05-01 07:14:59 [ℹ]  building iamserviceaccount stack "eksctl-game-2048-addon-iamserviceaccount-kube-system-aws-load-balancer-controller-for-game2048"

2025-05-01 07:14:59 [ℹ]  deploying stack "eksctl-game-2048-addon-iamserviceaccount-kube-system-aws-load-balancer-controller-for-game2048"

2025-05-01 07:14:59 [ℹ]  waiting for CloudFormation stack "eksctl-game-2048-addon-iamserviceaccount-kube-system-aws-load-balancer-controller-for-game2048"

2025-05-01 07:15:29 [ℹ]  waiting for CloudFormation stack "eksctl-game-2048-addon-iamserviceaccount-kube-system-aws-load-balancer-controller-for-game2048"

2025-05-01 07:15:30 [ℹ]  created serviceaccount "kube-system/aws-load-balancer-controller-for-game2048"

9. helm repo add eks https://aws.github.io/eks-charts

"eks" already exists with the same configuration, skipping

Note: During my testing, I have added the "eks" repo; that's why, while running this command, it is saying it already exists. 

10. helm repo update eks

Hang tight while we grab the latest from your chart repositories...

...Successfully got an update from the "eks" chart repository

Update Complete. ⎈Happy Helming!⎈

11. helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=game-2048 --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller-for-game2048 --set region=ap-south-1 --set vpcId=vpc-0ec00a061e60xxxxx

NAME: aws-load-balancer-controller

LAST DEPLOYED: Thu May  1 07:19:21 2025

NAMESPACE: kube-system

STATUS: deployed

REVISION: 1

TEST SUITE: None

NOTES:

AWS Load Balancer controller installed!

12. kubectl get po -n kube-system

NAME                                           READY   STATUS    RESTARTS   AGE

aws-load-balancer-controller-5c875989b-4vg4q   1/1     Running   0          51s

aws-load-balancer-controller-5c875989b-cqs86   1/1     Running   0          51s

.

.

13. kubectl get ingress -n game-2048

NAME           CLASS   HOSTS   ADDRESS                                                                    PORTS   AGE

ingress-2048   alb     *       k8s-game2048-ingress2-170f34f9e5-181944xxxx.ap-south-1.elb.amazonaws.com   80      22m

How traffic flows from ALB to Pods


Hit the DNS of ALB to access the application deployed in pods.


Play the game (Game-2048)


My GitHub repo of this project:
logoblog

Thanks for reading How to deploy Game-2048 application in AWS EKS cluster (with Fargate option)

Newest
You are reading the newest post

No comments:

Post a Comment

If you have any doubts, Please Comment down