Classic games like Super Mario are timeless. With modern cloud infrastructure, we can deploy these classic games in a scalable, reliable environment such as AWS Elastic Kubernetes Service (EKS). This blog post will guide you through deploying a Super Mario game on AWS EKS using Kubernetes.

Introduction to Deploying Classic Games on AWS EKS

Deploying classic games on the cloud allows gamers and developers to relive nostalgic moments while benefiting from the power of cloud computing. AWS EKS, a managed Kubernetes service, provides a robust platform for scalable and secure game hosting, enabling you to leverage auto-scaling, security, and high availability. By the end of this tutorial, you’ll have Super Mario running on AWS EKS and understand how to apply the same methodology to other classic games.

Prerequisites for Game Deployment on AWS EKS

Before you get started, ensure you have the following:

  1. AWS Account: An active AWS account.
  2. AWS CLI Installed: The AWS Command Line Interface should be installed and configured.
  3. kubectl Installed: The Kubernetes command-line tool for interacting with your EKS cluster.
  4. eksctl Installed: A command-line utility for creating and managing Kubernetes clusters on EKS.
  5. Docker Installed: Docker to build the game image.
  6. A Classic Game Image: In this case, a Docker image of the Super Mario game or a similar classic game image you wish to deploy.

Step-by-Step Guide to Launching an Ubuntu Instance

  1. Launch an EC2 Ubuntu Instance:
    Launch an Ubuntu instance on AWS to serve as a development and testing environment.

    • Go to the AWS Management Console and navigate to EC2.
    • Click Launch Instance and select Ubuntu 20.04 LTS.
    • Choose an instance type, typically t2.micro, for basic tasks.
    • Configure network settings such as VPC and subnets and ensure the security group allows SSH access.
    • Review and launch the instance, ensuring you have an SSH key pair for secure login.
  1. SSH into Your EC2 Instance:
    Once the instance is launched, use SSH to connect to the instance:
    ssh -i your-key.pem ubuntu@your-ec2-ip

Creating an IAM Role for Secure Access

AWS requires an IAM role to allow secure and controlled access to your resources. Follow these steps to create an IAM role:

  1. Create a Role for EKS:
    • In the AWS Management Console, navigate to IAM > Roles and click Create Role.
    • Select EKS as the trusted entity, then attach the necessary policies (like AmazonEKSClusterPolicy and AmazonEC2ContainerRegistryReadOnly).
    • Name the role and click Create Role.
  2. Attach the Role to EC2:
    After creating the role, go to your EC2 instance and attach the IAM role to it. This ensures that the instance can interact with EKS securely.

Provisioning a Kubernetes Cluster on AWS EKS

Now that your EC2 instance is ready let’s provision a Kubernetes cluster using EKS:

  1. Create an EKS Cluster with eksctl:
    eksctl create cluster –name super-mario-cluster –version 1.23 –region us-west-2 –nodegroup-name standard-workers –node-type t3.medium –nodes 3 –nodes-min 1 –nodes-max 4 –managed

This command provisions an EKS cluster named “super-mario-cluster” with three worker nodes, allowing for autoscaling between 1 and 4 nodes.

  1. Verify Cluster Configuration: After the cluster is created, verify that it is correctly configured:
    kubectl get nodes

Deploying the Super Mario Game on AWS EKS

Once your cluster is running, it’s time to deploy Super Mario:

  1. Build the Game Docker Image:
    If you don’t have a pre-built Docker image, create one:
    docker build -t super-mario .

docker tag super-mario:latest your-docker-repo/super-mario:latest

docker push your-docker-repo/super-mario:latest

  1. Create a Kubernetes Deployment:
    Create a deployment file for the game:
    apiVersion: apps/v1

kind: Deployment

metadata:

  name: super-mario

spec:

  replicas: 1

  selector:

    matchLabels:

      app: super-mario

  template:

    metadata:

      labels:

        app: super-mario

    spec:

      containers:

      – name: super-mario

        image: your-docker-repo/super-mario:latest

        ports:

        – containerPort: 8080

Save this YAML file and deploy it using the following:
kubectl apply -f super-mario-deployment.yaml

  1. Expose the Game with a Service:
    Create a service to expose the game externally:
    apiVersion: v1

kind: Service

metadata:

  name: super-mario-service

spec:

  type: LoadBalancer

  selector:

    app: super-mario

  ports:

    – protocol: TCP

      port: 80

      targetPort: 8080

Apply the service:
kubectl apply -f super-mario-service.yaml

Retrieve the load balancer URL:
kubectl get svc super-mario-service

Playing the Game and Cleaning Up Resources

Once your game is deployed and exposed, access it via the Load Balancer URL in your web browser. Enjoy your nostalgic trip with Super Mario running on the cloud!

When finished, ensure to clean up resources to avoid unwanted charges:

eksctl delete cluster –name super-mario-cluster

Conclusion

Deploying a classic game like Super Mario on AWS EKS showcases how modern cloud technology can revitalize timeless entertainment. By leveraging Kubernetes, you’ve set up a scalable, containerized environment to host your game efficiently. With this knowledge, you can deploy other classic games or even more complex applications using the same principles.

References

AWS Case Study: Nintendo Co., Ltd. and DeNA Co., Ltd

Nintendo Turns to Amazon Aurora to Support The Mario Kart Tour