Deploying a 2048 Game App on Amazon EKS using Fargate and ALB Ingress Controller

Anshika MishraAnshika Mishra
3 min read

Amazon EKS (Elastic Kubernetes Service) simplifies the process of running Kubernetes on AWS. In this blog, we’ll walk through deploying a sample 2048 web game on an EKS cluster using AWS Fargate, ALB Ingress Controller, and Helm.


🧰 Prerequisites

Ensure the following tools are installed and configured on your machine:

  • kubectl – CLI for Kubernetes

  • eksctl – CLI for creating and managing EKS clusters

  • AWS CLI – CLI for AWS services

    • Run aws configure to set your credentials and default region

☁️ Step 1: Create the EKS Cluster using Fargate

Use eksctl to create a cluster named demo-cluster with Fargate support:

bashCopyEditeksctl create cluster --name demo-cluster --region us-east-1 --fargate

To delete the cluster later:

bashCopyEditeksctl delete cluster --name demo-cluster --region us-east-1

🔐 Step 2: Configure IAM OIDC Provider

EKS needs an OIDC provider to allow IAM roles for service accounts.

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

Check if it's already configured:

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

If not present, run:

bashCopyEditeksctl utils associate-iam-oidc-provider --cluster $cluster_name --approve

🔧 Step 3: Install the AWS Load Balancer Controller

1. Download the IAM Policy:

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

2. Create the IAM Policy:

bashCopyEditaws iam create-policy \
    --policy-name AWSLoadBalancerControllerIAMPolicy \
    --policy-document file://iam_policy.json

3. Create IAM Role for the controller:

Replace <your-cluster-name> and <your-aws-account-id> with your actual values.

bashCopyEditeksctl 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

4. Install the ALB Controller using Helm:

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

Install the controller (replace placeholders):

bashCopyEdithelm 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>

5. Verify the deployment:

bashCopyEditkubectl get deployment -n kube-system aws-load-balancer-controller

🎮 Step 4: Deploy the 2048 Game App using Ingress

1. Create a Fargate profile for the app:

bashCopyEditeksctl create fargateprofile \
    --cluster demo-cluster \
    --region us-east-1 \
    --name alb-sample-app \
    --namespace game-2048

2. Deploy the app, service, and Ingress:

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

This includes:

  • Deployment (2048 game)

  • Service

  • Ingress (for ALB routing)


🌐 Step 5: Deploy Your Own Sample App (Optional)

1. Save the below as deploy.yaml:

yamlCopyEditapiVersion: apps/v1
kind: Deployment
metadata:
  name: eks-sample-linux-deployment
  labels:
    app: eks-sample-linux-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: eks-sample-linux-app
  template:
    metadata:
      labels:
        app: eks-sample-linux-app
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                - amd64
                - arm64
      containers:
      - name: nginx
        image: public.ecr.aws/nginx/nginx:1.23
        ports:
        - name: http
          containerPort: 80
        imagePullPolicy: IfNotPresent
      nodeSelector:
        kubernetes.io/os: linux

Deploy it:

bashCopyEditkubectl apply -f deploy.yaml

2. Save the below as service.yaml:

yamlCopyEditapiVersion: v1
kind: Service
metadata:
  name: eks-sample-linux-service
  labels:
    app: eks-sample-linux-app
spec:
  selector:
    app: eks-sample-linux-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

Deploy the service:

bashCopyEditkubectl apply -f service.yaml

Conclusion

You’ve now:

  • Set up a serverless EKS cluster using Fargate

  • Installed AWS Load Balancer Controller with proper IAM roles

  • Deployed the 2048 game and a custom app

  • Used ALB Ingress to route traffic

This setup gives you production-grade deployment infrastructure with minimal compute management.

0
Subscribe to my newsletter

Read articles from Anshika Mishra directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Anshika Mishra
Anshika Mishra

Passionate about DevOps, I focus on automating processes and optimizing system performance using tools like Docker, Kubernetes, Terraform, and Ansible. With experience in CI/CD, cloud infrastructure, and container management, I aim to improve efficiency, security, and scalability in every project I work on.