Exercise : 6 Deploying selenium grid on AWS EKS - Raneesh02/ref_workshop_2 GitHub Wiki
This guide provides step-by-step instructions to create a Kubernetes cluster in Amazon EKS using AWS CloudShell and then deploy Selenium Grid using Helm.
Before proceeding, ensure you have the following:
- An AWS account with the necessary permissions to create EKS clusters (the root user has all the rights).
- Just after login select the region in the top right corner so that speed will be high and usage price will be low
-
Access AWS CloudShell:
- Navigate to the AWS Management Console.
- In the search bar, type CloudShell and select the service.
- AWS CloudShell will open in a new browser window.
-
Check AWS CLI Installed:
- AWS CloudShell comes with the AWS CLI pre-installed. You can check the version using:
aws --version
- AWS CloudShell comes with the AWS CLI pre-installed. You can check the version using:
aws cli is a tool to use aws commands in terminal , you can manage your resources through commands using this . Ref: aws_cli
-
Install eksctl:
- AWS CloudShell comes with the AWS CLI pre-installed. You can check the version using:
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz" | tar xz -C /tmp sudo mv /tmp/eksctl /usr/local/bin eksctl version
- AWS CloudShell comes with the AWS CLI pre-installed. You can check the version using:
eksctl is a cli tool to handle clusters of AWS EKS. Ref: eksctl
-
Create an EKS Cluster:
- Run the following command to create an EKS cluster. Replace
<cluster-name>
and<region>
with your desired values:eksctl create cluster \ --name selenium-grid \ --region ap-south-1 \ --nodegroup-name selenium-grid-nodes \ --node-type t3.medium \ --nodes 2 \ --nodes-min 1 \ --nodes-max 4 \ --managed
- Run the following command to create an EKS cluster. Replace
Above command will create a cluster with 2 worker nodes. This command will take 5-10 minutes to run
if you receive below message that means your cluster is ready
2024-11-01 16:41:08 [✔] EKS cluster "selenium-grid" in "ap-south-1" region is ready
if you get repeated AlreadyExistsException for same name change the name and try again
Explanation:
- eksctl create cluster: This command initiates the creation of a new EKS cluster with the configurations specified by the subsequent options.
- --name selenium-grid-cluster : Specifies the name of the EKS cluster to be created. In this case, the cluster will be named selenium-grid-cluster
- --region ap-south-1 : Defines the AWS region where the EKS cluster will be deployed. Here, the cluster will be created in the ap-south-1 region (Asia Pacific - Mumbai)
- --nodegroup-name selenium-grid-nodes : Specifies the name of the node group that will be created as part of the cluster. This node group will be named selenium-grid-nodes
- --node-type t3.medium : Indicates the EC2 instance type to be used for the nodes in the node group. In this case, t3.medium instances are used, which provide a balance of compute, memory, and networking resources
- --nodes 2 : Sets the desired number of nodes to be created in the node group. Here, the command requests 2 nodes.
- --nodes-min 1 : Specifies the minimum number of nodes that should be maintained in the node group. If the cluster scales down, it will ensure at least 1 node remains active.
- --nodes-max 4 : Specifies the maximum number of nodes that can be scaled up in the node group. This allows the cluster to scale out to a maximum of 4 nodes to handle increased workloads.
- --managed : Indicates that the node group will be a managed node group. In a managed node group, Amazon EKS will handle the provisioning and lifecycle management of the nodes, making it easier to keep the nodes updated and secure.
-
Check if kubectl is already configured. Below commands should list nodes of aws
kubectl get nodes
-
if above command did not work then update your kubeconfig to interact with the cluster and then try to list nodes:
aws eks update-kubeconfig --region ap-south-1 --name selenium-grid
-
Install Helm:
- If Helm is not already installed in your CloudShell environment, install it with:
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- If Helm is not already installed in your CloudShell environment, install it with:
-
Copy QA_infra repository:
- Clone The repo
git clone https://github.com/raneeshalt/selgrid_kube_aws_oct.git
- Clone The repo
-
Deploy Selenium Grid:
- cd into cloned repo and then helm directory. Deploy Selenium Grid using Helm:
cd <repo-name> cd helm/selenium-helm helm install selenium-grid selenium-grid
- cd into cloned repo and then helm directory. Deploy Selenium Grid using Helm:
kubectl get svc
Get the URL and then do a curl to get status
curl http://aecd0b193f5c845e5984de7b60d2c8af-683441888.ap-south-1.elb.amazonaws.com:4444/wd/hub/status
Go to src/main/resources/configuration.properties
and enter the noted URL from svc command
configuration.properties
url=https://practicesoftwaretesting.com/
selenium.gridurl=aecd0b193f5c845e5984de7b60d2c8af-683441888.ap-south-1.elb.amazonaws.com
Step 8 : Tear Down . This step is very important as resources can keep on running on AWS so we need to keep a close watch on usage
Only do this if you will not proceed with further exercises. if you are proceeding then do it at the end
-
Uninstall Selenium Chart
helm uninstall selenium-grid
-
Delete cluster along with worker nodes
eksctl delete cluster --name selenium-grid
-
Go to AWS Console to see if any resources are getting used :
- Search VPCs and see if there any resources in the region which corresponds to selenium-grid and delete it
- Search EC2 and check if any instances are running
- Search NAT gateways and delete if there is any active gateway
Ever after deleting everything Do a daily check for AWS cost explorer for atleast 3-4 days to make sure there is no resources running. This is needed as AWS bills gets generated next day
By following these steps, you have successfully created an EKS cluster using AWS CloudShell and deployed Selenium Grid using Helm. Now you can finally do the execution from local pointing to AWS Deployed Selenium Grid