Screen.Recording.2024-10-07.152519.mp4
Welcome! This project showcases how to set up a Kubernetes cluster on AWS using EKS and Fargate, then deploy a sample game application (2048). You’ll find clear instructions on how to replicate the setup on your own, even if you're new to Kubernetes or AWS.
The goal of this project is to:
- Create a Kubernetes cluster on AWS using EKS.
- Deploy the classic 2048 game in the cluster.
- Use an Application Load Balancer (ALB) to make the game accessible from the internet.
By following the steps, you’ll learn how to:
- Set up a cluster using eksctl.
- Deploy resources with kubectl.
- Manage permissions with AWS IAM.
To get started, clone this repository to your local machine:
git clone https://github.com/yourusername/my-eks-project.git
cd my-eks-project
Here’s how the files are organized:
/my-eks-project
├── README.md # You're reading this!
├── deployment/ # Contains Kubernetes YAML configuration files
├── 2048_full.yaml # The file for deploying the 2048 game application
├── scripts/ # Useful scripts for setting up AWS and Kubernetes
├── create-cluster.sh # Script to create the EKS cluster
├── create-iam-role.sh # Script to set up IAM roles for ALB
├── .gitignore # Standard gitignore file
You’ll need a few tools installed on your machine:
- AWS CLI – Command-line tool to interact with AWS. Download it here.
- eksctl – CLI tool for creating and managing EKS clusters. Download it here.
- kubectl – CLI tool for interacting with Kubernetes clusters. Install it here.
- Helm – A package manager for Kubernetes. Install it here.
Once these tools are installed, you're ready to proceed!
You’ll need to configure the AWS CLI so that it can interact with your AWS account:
aws configure
It will ask you for your AWS Access Key, Secret Key, and region (choose your preferred AWS region).
Run the following script to create your cluster:
./scripts/create-cluster.sh
This will set up a Kubernetes cluster named demo-cluster
in the AWS region eu-north-1
.
To make sure kubectl
can communicate with your cluster, update the kubeconfig:
aws eks update-kubeconfig --name demo-cluster --region eu-north-1
Deploy the 2048 game into your cluster:
kubectl apply -f deployment/2048_full.yaml
Check if everything is running properly:
-
List services in the
game-2048
namespace:kubectl get svc -n game-2048
-
List the pods in the same namespace:
kubectl get pods -n game-2048
To allow users to access the game from their browser, you need to deploy the ALB controller. Run the following commands to set up IAM roles and the ALB controller:
./scripts/create-iam-role.sh
Once the ALB is ready, you can access the game by checking the Ingress:
kubectl get ingress -n game-2048
The ADDRESS field will show the public URL for your 2048 game.
If you're new to Kubernetes or AWS, don't worry! Feel free to open an issue or reach out for help. Here are some useful links to get more information:
Enjoy deploying your Kubernetes cluster and have fun with the 2048 game! 🚀🎮