Deploy Super Mario Game on AWS EKS (Elastic Kubernetes Service)

Ajay S Nair
4 min readNov 24, 2023

--

In this tutorial, we are going to deploy a simple Kubernetes application on AWS EKS, which stands for AWS Elastic Kubernetes Service. We will deploy a Super Mario game on AWS EKS using a Super Mario Docker image.

Thanks to the one who created and updated the Docker image (kaminskypavel/mario) on Docker Hub.

Please be aware that the services involved in the tasks may incur charges.

Before starting, I would like to tell you that I have tried my level best to keep the documentation as easy as possible. It is written in a way that is replicable by a newbie. Even if you are a beginner, you might be able to replicate this, but to understand the working, it might require some basic experience in Kubernetes and AWS EKS.

To begin, we need a machine with AWS CLI installed on it. To install AWS CLI, follow the steps given in the AWS Official Documentation.

After installing the AWS CLI, configure a role on the machine with AWS CLI; you can use the same AWS Official Documentation.

We have a few prerequisites such as EKSCTL, kubectl, and GIT. We need to install all three of these before proceeding with the tutorial. Below are the official documentation links to install these tools:

Now we are all set to go.

Add On: you can verify each step’s progression from the AWS console as well.

As a best practice, I am creating a new folder to keep our files. Run the following commands:

mkdir mario && cd mario

Now we need to get the YAML files to create the cluster and deployment. You can either clone the repository or create the files manually. Make sure to retain the names of the files or change them as the steps progress.

git clone https://github.com/ajaysnair1122/k8-mario.git && cd k8-mario

If you haven’t cloned the git repository, create an “eksctl-config.yaml” file with the content below:

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
name: mario-cluster
region: ap-south-1

nodeGroups:
- name: ng-1
desiredCapacity: 2
instanceType: t3.small

Now, let’s create the EKS Cluster:

eksctl create cluster -f eksctl-config.yaml

It will take at least 10 minutes. As someone said, slow and steady wins the deployment 😉

Finally, the cluster has been created. If it is a success, you can see an output similar to the following:

Ending portion of the Cluster Creation output

Verify the created cluster with the “aws eks describe-cluster” command. I have made a few additions to make it look good:

aws eks describe-cluster --name mario-cluster --query "cluster.{Name: name, Status: status, Endpoint: endpoint, Version: version, DateOfCreation: createdAt}" --output table
Cluster Details

Looks good, right? 🤔

To configure “kubectl” to use the newly created cluster, use the following command:

aws eks --region ap-south-1 update-kubeconfig --name mario-cluster

Okay, the time has arrived. Let us create the deployment. Make sure that the “deployment.yaml” file is in the directory. Here’s the content for those who haven’t cloned the git repository:

apiVersion: apps/v1
kind: Deployment
metadata:
name: mario
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: mario
image: kaminskypavel/mario
ports:
- name: mario
containerPort: 8080

Once the file is present, execute the following command:

kubectl apply -f deployment.yaml

If the file is correct, the deployment will be created. Verify the same with the “kubectl describe deployment” command:

kubectl describe deployment mario
Deployment Details

The application has been created now, and next, we need to access the application. We will be using a Load Balancer to access the application. For that, we already have a “service.yaml” file in the directory. If not, create the same with the following content:

apiVersion: v1
kind: Service
metadata:
name: mario-service
labels:
app: my-app
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: my-app
type: LoadBalancer

Execute the following command to create the Load Balancer service:

kubectl apply -f service.yaml

Verify the service with the “kubectl describe service” command:

kubectl describe service mario-service
Service Details

Copy the “LoadBalancer Ingress” value, and Super Mario awaits you.

Final Page

This tutorial represents my first attempt, and I value your feedback to enhance its quality. Feel free to share your authentic comments and any questions you may have. I would be genuinely pleased to see individuals achieve their intended results by following these instructions.

--

--

Ajay S Nair

🌥️ Cloud | DevOps Engineer ☁️ | Automation 💻 | #DevOps #CloudComputing 📦 #AWS