Setup Selenium Grid using Kubernetes
Setup Selenium Grid using Kubernetes
- Prerequisite: Kubernetes is installed along with minikube if you are running in your local.
- Create Deployment: To create a Kubernetes deployment for Selenium Hub, create a new YAML file with the below content.
seleniumdeployment.yaml
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: selenium-hub
- spec:
- selector:
- matchLabels:
- app: selenium-hub
- strategy:
- type: RollingUpdate
- rollingUpdate:
- maxSurge: 1
- maxUnavailable: 0
- template:
- metadata:
- labels:
- app: selenium-hub
- spec:
- containers:
- - name: selenium-hub
- image: selenium/hub:3.141.59-20200326
- resources:
- limits:
- memory: "128Mi"
- cpu: "500m"
- ports:
- - containerPort: 4444
- livenessProbe:
- httpGet:
- path: /wd/hub/status
- port: 4444
- initialDelaySeconds: 30
- timeoutSeconds: 5
and run the command
- kubectl create -f seleniumdeployment.yaml
- Create Service: To create a service for the Selenium Hub deployment, create a new YAML file with the below content.
seleniumservice.yaml
- apiVersion: v1
- kind: Service
- metadata:
- name: selenium-service
- labels:
- app: selenium-service
- spec:
- selector:
- app: selenium-hub
- ports:
- - port: 4444
- nodePort: 30001
- type: NodePort
- and run the command
- kubectl create -f seleniumservice.yaml
- Create Selenium Node Replication Controller: To create the Selenium Nodes using Replication Controller, create a new YAML file with the below content.
seleniumnodesrc.yaml
- apiVersion: v1
- kind: ReplicationController
- metadata:
- name: selenium-nodes
- spec:
- replicas: 2
- selector:
- app: selenium-chrome
- template:
- metadata:
- name: selenium-chrome
- labels:
- app: selenium-chrome
- spec:
- containers:
- - name: node-chrome-debug
- image: selenium/node-chrome-debug:3.141.59-20200409
- ports:
- - containerPort: 5555
- env:
- - name: HUB_HOST
- value: "selenium-service"
- - name: HUB_PORT
- value: "4444"
- and run the command
- kubectl create -f seleniumnodesrc.yaml
- Get Service URL: If you are using minikube, you can use this command to get the URL of your selenium hub minikube service selenium-service --url
- View Minikube Dashboard: To view minikube dashboard, run the command minikube dashboard
- Delete All: To delete the selenium hub, nodes, and the service, run the below commands kubectl delete rc selenium-nodes
- kubectl delete deployment selenium-hub
- kubectl delete svc selenium-service
Comments
Post a Comment