Deploying Super Mario on Kubernetes🎮🎮
Tags: aws, eks, kubernetes, mariogame
Published: 2023-12-20 07:15:09

Hey folks, remember the thrill of 90's gaming? Let's step back in time and relive those exciting moments! With the game deployed on Kubernetes, it's time to dive into the nostalgic world of Mario. Grab your controllers, it's game time!

[GIT](https://github.com/SwapnilM24/k8s-mario)
[linkedin](www.linkedin.com/in/swapnil-m-2424sm)

```

https://www.linkedin.com/posts/activity-7143143843671048192-siWq?utm_source=share&utm_medium=member_desktop
```

Super Mario is a classic game loved by many. In this guide, we'll explore how to deploy a Super Mario game on Amazon's Elastic Kubernetes Service (EKS). Utilizing Kubernetes, we can orchestrate the game's deployment on AWS EKS, allowing for scalability, reliability, and easy management.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3rz1f68h998o2otaiim.gif)

**Prerequisites:**
1. An Ubuntu Instance
2. IAM role
3. Terraform should be installed on instance
4. AWS CLI and KUBECTL on Instance

**LET'S DEPLOY**

**> STEP 1: Launch Ubuntu instance**

1. Sign in to AWS Console: Log in to your AWS Management Console.

2. Navigate to EC2 Dashboard: Go to the EC2 Dashboard by selecting "Services" in the top menu and then choosing "EC2" under the Compute section.

3. launch Instance: Click on the "Launch Instance" button to start the instance creation process.

4. Choose an Amazon Machine Image (AMI): Select an appropriate AMI for your instance. For example, you can choose Ubuntu image.

5. Choose an Instance Type: In the "Choose Instance Type" step, select t2.micro as your instance type. Proceed by clicking "Next: Configure Instance Details."

6. Configure Instance Details:

- For "Number of Instances," set it to 1 (unless you need multiple instances).
- Configure additional settings like network, subnets, IAM role, etc., if necessary.
- For "Storage," click "Add New Volume" and set the size to 8GB (or modify the existing storage to 8GB).

- Click "Next: Add Tags" when you're done.

7. Add Tags (Optional): Add any desired tags to your instance. This step is optional, but it helps in organizing instances.

8. Configure Security Group:

- Choose an existing security group or create a new one.
- Ensure the security group has the necessary inbound/outbound 
  rules to allow access as required.
9.Review and Launch: Review the configuration details. Ensure everything is set as desired.

10. Select Key Pair:

- Select "Choose an existing key pair" and choose the key pair from the dropdown.
- Acknowledge that you have access to the selected private key file.
- Click "Launch Instances" to create the instance.

11. Access the EC2 Instance: Once the instance is launched, you can access it using the key pair and the instance's public IP or DNS.

Ensure you have necessary permissions and follow best practices while configuring security groups and key pairs to maintain security for your EC2 instance.

**STEP 2: Create IAM role**

Search for IAM in the search bar of AWS and click on roles.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofnn67hgjajkh62oobzy.png)

Click on Create Role


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kvpd2mxwiwwrjvezmpe.png)

Select entity type as AWS service

Use case as EC2 and click on Next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0mpyhhitlwx2e9istkzt.png)

For permission policy select Administrator Access (Just for learning purpose), click Next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uogvbo51u502nzypzfci.png)

Provide a Name for Role and click on Create role.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aphr3zgj83zjdxrowqnl.png)

Role is created.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dt8l6liu6loiblpsnfqh.png)


Now Attach this role to Ec2 instance that we created earlier, so we can provision cluster from that instance.

Go to EC2 Dashboard and select the instance.

Click on Actions --> Security --> Modify IAM role.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w57vmftwh92tfwizyxdj.png)

Select the Role that created earlier and click on Update IAM role


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wgpolll8v7u6xr1xpgf.png)

**STEP 3: Cluster provision**


Now clone this Repo.

```
git clone https://github.com/SwapnilM24/k8s-mario.git
```

change directory

```
cd k8s-mario
```

Provide the executable permission to script.sh file, and run it.

```
sudo chmod +x script.sh
./script.sh
```

This script will install Terraform, AWS cli, Kubectl, Docker.

Check versions

```
docker --version
aws --version
kubectl version --client
terraform --version
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2x81ffs9bp3l56fjnfdo.png)

Now change directory into the EKS-TF

Run Terraform init

> NOTE: Don’t forgot to change the s3 bucket name in the backend.tf file

```
cd EKS-TF
terraform init
```

Now run terraform validate and terraform plan


```
terraform validate
terraform plan
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93q2wls4wh5vovs2fv9q.png)


Now Run terraform apply to provision cluster.

```
terraform apply --auto-approve
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njoo6poz05fd3c4s6vs8.png)

Completed in 10mins


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4o9fqnkkf5lxu3y4mq8g.png)

Update the Kubernetes configuration

Make sure change your desired region

```
aws eks update-kubeconfig --name EKS_CLOUD --region ap-south-1
```

Now change directory back to k8s-mario

```
cd ..
```

Let’s apply the deployment and service

```
Deployment
```

```
kubectl apply -f deployment.yaml
#to check the deployment 
kubectl get all
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xop4t0ez6slmgqu2ovb1.png)

Now let’s apply the service

**Service**

```
kubectl apply -f service.yaml
kubectl get all
```

Now let’s describe the service and copy the LoadBalancer Ingress

```
kubectl describe service mario-service
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5j7plvbof9kee0tsp6p6.png)

Paste the ingress link in a browser and you will see the Mario game.

Let’s Go back to 1985 and play the game like children.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qxjbh5uhb2i68vkhggxd.png)

**Destruction :**

Let's remove the service and deployment first


```
kubectl get all
kubectl delete service mario-service
kubectl delete deployment mario-deployment
```

Let’s Destroy the cluster

```
terraform destroy --auto-approve
```

After 10mins Resources that are provisioned will be removed.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wsouxjl3rcuyjqd27i59.png)


Thank you for joining this nostalgic journey to the 90s! We hope you enjoyed rekindling your love for gaming with the deployment of the iconic Mario game on Kubernetes. Embracing the past while exploring new technologies is a true testament to the timeless allure of classic games. Until next time, keep gaming and reliving those fantastic memories! 👾🎮.