This content originally appeared on DEV Community and was authored by Akshay Jadhav
Github: https://github.com/git-akshay-jadhav/tetris-game.git
Welcome to an electrifying journey where we delve into the dynamic realm of GitOps, all while gearing up for an unforgettable dive into one of gaming's most timeless and captivating experiences: Tetris!
In this blog, we'll demystify the intricacies of GitOps, unveiling its transformative capabilities, all while immersing ourselves in the exhilarating world of Kubernetes deployed on Amazon's Elastic Kubernetes Service (EKS).
Strap in tight, as we embark on a riveting escapade that not only acquaints you with the wonders of GitOps but also offers you the chance to relish the nostalgic thrill of Tetris on a Kubernetes platform.
So, let's dive in and witness the thrilling collision of DevOps and gaming in this epic adventure!
STEP 1: Create IAM Roles
Let’s First start creating two IAM roles one is for Cluster and another is for Nodegroup
Go to Aws console and search for IAM
You will be redirected to the IAM dashboard
Click “Roles”
Click “Create role”
Click “Allow AWS services like EC2, Lambda, or others to perform actions in this account.”
Click “Choose a service or use case”
Type “EKS”
Click this radio button with EKS-Cluster
Click “Next” and you will directly redirect to policy and click Next ( we have only one policy for it and it selects by default for EKS) that is AmazonEKSClusterPolicy
Click the “Role name” field and provide the name (myAmazonEKSClusterRole)
Click “Create role”
A cluster role is created.
Now Create a Role for NodeGroup
Click “Create role”
Click “Allow AWS services like EC2, Lambda, or others to perform actions in this account.”
Click “Choose a service or use case”
Click “EC2”
Click “Next”
Click the “Search” field.
Search these Policy Names and make it check (I already have these in it )
AmazonEC2ContainerRegistryReadOnly
AmazonEKS_CNI_Policy
AmazonEBSCSIDriverPolicy
AmazonEKSWorkerNodePolicy
Click “Next”
Click the “Role name” field.
Add Role name as myAmazonNodeGroupPolicy
Click “Create role”
NodeGroup Role is created.
Step 2: Create EKS Cluster
Click the “Search” field and search For EKS or select directly Elastic Kubernetes Service on the Recently visited tab
Click “Add cluster”
Click “Create”
Click the “Name” field and enter a unique name for the cluster that is anything you want. For example, I used Cloud and version 1.28
Click “myEKSClusterRole” which is created in step 1.
Click “Next”
Click “Select security groups” and Use the existing security group or create a new security Group
Click “Next”
Click “Next”
No changes Click “Next” (Default no need to change anything)
No changes Click “Next” (Default no need to change anything)
Click “Create”
It takes 15 minutes to create.
Once your Cluster up to active status
Click “Compute”
Click on “Add node group”
Click the “Name” field.
Write any Name you want (NodeGroup)
Select the Role that was created for the node Group in Step 1
Click “Next”
On the next page remove t3.medium and add t2.medium as instance type.
Select t2.medium
Click “Next”
Click “Next”
Click “Create”
Node Groups will take some time to create.
Worker nodes created.
Step 3: ARGOCD SETUP
Click on the AWS cloud shell icon on the top right
click on connect
Better to open in a new tab
First set context by providing the following command
Copy
aws eks update-kubeconfig --name EKS_CLUSTER_NAME --region CLUSTER_REGION
example
aws eks update-kubeconfig --name GitOps --region ap-south-1
Check for Nodes
Copy
kubectl get nodes
Check for pods, You will get no resources found.
Copy
kubectl get pods
Let’s install ArgoCD
ARGOCD INSTALLATION LINK
You will redirected to this page
All those components could be installed using a manifest provided by the Argo Project: use the below commands
Copy
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.7/manifests/install.yaml
COMMANDS ARGOCD
By default, argocd-server is not publicly exposed. For this project, we will use a Load Balancer to make it usable:
Copy
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
One load balancer will created in the AWS
Wait about 2 minutes for the LoadBalancer creation
Copy
export ARGOCD_SERVER=kubectl get svc argocd-server -n argocd -o json | jq --raw-output '.status.loadBalancer.ingress[0].hostname'
when you run this command, it will export the hostname of the ArgoCD server’s load balancer and store it in the ARGOCD_SERVER environment variable, which you can then use in other commands or scripts to interact with the ArgoCD server. This can be useful when you need to access the ArgoCD web UI or interact with the server programmatically.
If run this command you will get the load balancer external IP
Copy
echo $ARGOCD_SERVER
Login
The command you provided is used to extract the password for the initial admin user of ArgoCD, decode it from base64 encoding, and store it in an environment variable named ARGO_PWD.
Copy
export ARGO_PWD=kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
If you want to see your password provide the below command
Copy
echo $ARGO_PWD
Now copy the load balancer IP and paste it into the browser
Copy
echo $ARGOCD_SERVER
Now you will see this page. if you get an error click on advanced and click on proceed.
Now you will see this page and log in to ArgoCD
Username is admin
For the password, you have to provide the below command and copy it
Copy
echo $ARGO_PWD
Click on Signin and you will see this page.
Now click on the Setting gear icon in the left side panel
Click on Repositories
Now click on Connect Repo Using HTTPS
Add Github details, Type as git, Project as default and provide the GitHub URL of this project and click on connect
You will get Connection Status as Successful
Click on Manage Your application
You will see this page and click on New App
Now provide the following details as in the image
Finally, click on Create
Now you will see a new App has been created named tetris
Click on tetris
Now click on three dots beside tetris-service and click on the details
Now copy the hostname address
Paste it in a browser you will see this page
Now play the game.
Let’s Break the Highest score in Tetris.
Copy
kubectl get all
Step 5: Termination
Go to Cloud shell and delete service for ArgoCD load balancer
Copy
kubectl delete svc argocd-server -n argocd
Go to AWS and manually delete the load balancer if it is not deleted.
Delete Nodegroup First
Provide the name that you used for your node group and click delete
Delete the Cluster
Provide the name of the Cluster and delete.
As we bring our enthralling journey through the captivating realms of GitOps and the iconic Tetris on Kubernetes to a close, allow us to leave you with a fascinating nugget of knowledge:
Did you know that Tetris, conceived by Alexey Pajitnov in 1984 during his tenure as a computer scientist at the Soviet Academy of Sciences, began as a humble experiment? It swiftly evolved into a global gaming sensation, captivating hearts and minds across the globe for decades.
Much like Tetris, GitOps is a dynamic force, continuously evolving and reshaping the modern landscape of DevOps. It offers ingenious solutions for managing complex infrastructures and applications. We trust this adventure has ignited a spark of curiosity within you, inspiring further exploration of GitOps' limitless potential.
So, whether you're meticulously deploying code, skillfully stacking blocks in Tetris, or boldly venturing into uncharted territories in the tech world, remember: the journey knows no bounds, and every step is filled with delightful surprises. Keep coding, keep gaming, and keep exploring! 🌟
This content originally appeared on DEV Community and was authored by Akshay Jadhav
Akshay Jadhav | Sciencx (2024-07-29T17:08:08+00:00) Akshay JadhavDevOps Insights with Akshay Jadhav. Retrieved from https://www.scien.cx/2024/07/29/akshay-jadhavdevops-insights-with-akshay-jadhav/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.