Help improve this page
Want to contribute to this user guide? Choose the Edit this page on GitHub link that is located in the right pane of every page. Your contributions will help make our user guide better for everyone.
Deploy a sample load balancer workload to EKS Auto Mode
This guide walks you through deploying a containerized version of the 2048 game on Amazon EKS, complete with load balancing and internet accessibility.
Prerequisites
-
An EKS Auto Mode cluster
-
kubectl
configured to interact with your cluster -
Appropriate IAM permissions for creating ALB resources
Step 1: Create the Namespace
First, create a dedicated namespace for the 2048 game application.
Create a file named 01-namespace.yaml
:
apiVersion: v1 kind: Namespace metadata: name: game-2048
Apply the namespace configuration:
kubectl apply -f 01-namespace.yaml
Step 2: Deploy the Application
The application runs multiple replicas of the 2048 game container.
Create a file named 02-deployment.yaml
:
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 resources: requests: cpu: "0.5"
Key components:
-
Deploys 5 replicas of the application
-
Uses a public ECR image
-
Requests 0.5 CPU cores per pod
-
Exposes port 80 for HTTP traffic
Apply the deployment:
kubectl apply -f 02-deployment.yaml
Step 3: Create the Service
The service exposes the deployment to the cluster network.
Create a file named 03-service.yaml
:
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
Key components:
-
Creates a NodePort service
-
Maps port 80 to the container’s port 80
-
Uses label selector to find pods
Apply the service:
kubectl apply -f 03-service.yaml
Step 4: Configure Load Balancing
You will set up an ingress to expose the application to the internet.
First, create the IngressClass
. Create a file named 04-ingressclass.yaml
:
apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: namespace: game-2048 labels: app.kubernetes.io/name: LoadBalancerController name: alb spec: controller: eks.amazonaws.com/alb
Then create the Ingress resource. Create a file named 05-ingress.yaml
:
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
Key components:
-
Creates an internet-facing ALB
-
Uses IP target type for direct pod routing
-
Routes all traffic (/) to the game service
Apply the ingress configurations:
kubectl apply -f 04-ingressclass.yaml kubectl apply -f 05-ingress.yaml
Step 5: Verify the Deployment
-
Check that all pods are running:
kubectl get pods -n game-2048
-
Verify the service is created:
kubectl get svc -n game-2048
-
Get the ALB endpoint:
kubectl get ingress -n game-2048
The ADDRESS field in the ingress output will show your ALB endpoint. Wait 2-3 minutes for the ALB to provision and register all targets.
Step 6: Access the Game
Open your web browser and browse to the ALB endpoint URL from the earlier step. You should see the 2048 game interface.
Step 7: Cleanup
To remove all resources created in this tutorial:
kubectl delete namespace game-2048
This will delete all resources in the namespace, including the deployment, service, and ingress resources.
What’s Happening Behind the Scenes
-
The deployment creates 5 pods running the 2048 game
-
The service provides stable network access to these pods
-
EKS Auto Mode:
-
Creates an Application Load Balancer in AWS
-
Configures target groups for the pods
-
Sets up routing rules to direct traffic to the service
-
Troubleshooting
If the game doesn’t load:
-
Ensure all pods are running:
kubectl get pods -n game-2048
-
Check ingress status:
kubectl describe ingress -n game-2048
-
Verify ALB health checks: Check the target group health in AWS Console