There are lots of good reasons to be running a Selenium grid in cloud or Kubernetes containers: It’s less maintenance, it’s faster with more reliable network hopping, it’s self healing and it can auto scale. So what do we need to get this off the ground?
So let’s get started, first off we need to login to the portal and create a Kubernetes service/ cluster resource.
Pick subscription & allocate a resource group, my resource group here is called ‘Selenium‘
Cluster name: I’m calling mine here ‘k8s-grid‘ Region: (Europe) West Europe (this is one of the regions that allows for virtual nodes which are required for scaling), unlike (Europe) UK South, for example.
Node Size: B4ms (4 cores to allow for some scaling)
Click next (Node pools) and enable virtual nodes.
Be sure to enable Virtual nodes
Click next (Authentication)
You can choose either a Service principal if you have one, or a slightly easier wrapper around it in System-assigned managed identity. Keep RBAC Enabled with default encryption type.
Click next (Networking)
Just leave this as it comes.
Click next (Integrations)
I turned off Container monitoring for my MSDN account.
Click next (Review and create)
Validation should pass, click create and wait for it to deploy.
After a short time it gets deployed.
Connect to the cluster via CLI
Open powershell or whatever terminal you prefer, login to Azure:
az login
Now connect to the cluster specifying the Resource Group and Cluster name we gave in a previous step:
az aks get-credentials--resource-groupSelenium--name k8s-grid
You should see something like
PowerShell
1
Merged"k8s-grid"as current context inC:\Users\jholsgrove\.kube\config
That’s it, you are connected!
Create the Hub
First create a selenium-hub-deployment.yaml locally with the deployment details (Kubernetes has some good examples here, but I will list them out anyway making the odd tweak)
Next we are going to create a service to allow us to get to the Hub web interface, note we need to make sure the type is set to ‘LoadBalancer‘ and create selenium-hub-svc.yaml:
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
apiVersion:v1
kind:Service
metadata:
name:selenium-hub
labels:
app:selenium-hub
spec:
ports:
-port:4444
targetPort:4444
name:port0
selector:
app:selenium-hub
type:LoadBalancer
sessionAffinity:None
To deploy:
kubectl create-fselenium-hub-svc.yaml
Now run
kubectl get services and note the external IP address that was assigned (this might take a few moments to be assigned)
A slight departure from the usual testing related stuff, awhile ago I made a chat bot service in Azure in a fleeting attempt to dip my toes into AI based tech. The below is a hopefully faithful recreation of how I did it, I really wish I documented it at the time.
Make a QNA Service in Azure
To get started, log into Azure Portal and make a Resource Group.
Add the resource QnA Maker, s...