Hi all, for a long time I could not find time to write an article on swtestacademy because of the busy schedule at work. However, during the Eid holiday, I wanted to play with Kubernetes, scale the selenium grid with it, and share my experience with you all. Previously, we have written articles on Docker with Selenium, Selenoid with Selenium, Selenium Grid, and Parallel Testing with TestNG. In this article, we will spin up and scale Selenium Grid with Kubernetes and Docker and run parallel testing with this solution.

We will use Kubernetes for automating deployment, scaling, and management of containerized Selenium Grid, and DockerĀ for operating-system-level virtualization which is also known as containerization.

I will not go into too much theory in this post. However, if you want to learn more theory of Kubernetes, I would like to suggest my friend Karthik K.K.’s Kubernetes series. It will help all of you to learn the Kubernetes fundamentals.

In this article, our aim is to create a selenium grid with a hub, three chrome nodes, and three firefox nodes. These grid modules will communicate with each other over Kubernetes Service. This is the main architecture of our grid setup.

Also, we will use Kubernetes Rolling Deployment, Service, Replication Controller concepts. Finally, we will modify our Selenium TestNG parallel test execution project URL as our grid’s URL and run our tests in parallel.

First, we need to install Docker on our machine (PC or MAC). I am using a MAC but the installation of Docker is pretty straightforward for both OS. After this step, you will start the Docker on your machine.

Then, we need to install Kubernetes and Minikube on our machine. For this, we need to open a terminal and run the below commands consecutively.

After these commands, we should see the below result which shows minikube has started successfully.

When minukube has been started, we can use minikube and kubectl commands to create our Selenium Grid Architecture with Kubernetes. We will communicate over the Kubernetes Service to reach the hub and the nodes. Kubernetes Service has bi-directional communication between the hub and the nodes.

Before starting to create our YAML files, I highly suggested to use Microsoft VS Code and install YAML, Kubernetes, and Docker plugins.