Skip to content

Commit deadadd

Browse files
authored
K8s deployment (#1113)
* added kubernetes deployment yml for selenium grid 4 * fixed typo in the comments section of k8s yml. * added k8s deployment instructions in README.md * added github action to test on minikube
1 parent ff51c1c commit deadadd

File tree

4 files changed

+489
-1
lines changed

4 files changed

+489
-1
lines changed

.github/workflows/k8s-deploy-test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "Test Selenium Grid 4 deployment on Minikube Cluster"
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
pull_request:
8+
branches:
9+
- trunk
10+
11+
jobs:
12+
deploy:
13+
name: Deployment and testing of Grid 4 on Minikube
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v1
18+
- name: Setup Minikube
19+
uses: manusa/[email protected]
20+
with:
21+
minikube version: "v1.13.1"
22+
kubernetes version: "v1.19.2"
23+
github token: ${{ secrets.GITHUB_TOKEN }}
24+
driver: none
25+
- name: Interact with Minikube
26+
run: kubectl get nodes
27+
- name: Output Cluster info
28+
run: |
29+
kubectl cluster-info
30+
kubectl get pods -n kube-system
31+
echo "current-context:" $(kubectl config current-context)
32+
echo "environment-kubeconfig:" ${KUBECONFIG}
33+
- name: Deploy Grid4 on minikube
34+
run: kubectl apply -f k8s-deployment-full-grid.yaml
35+
- name: Expose Router service
36+
run: kubectl expose deployment selenium-router-deployment --type=NodePort --port=4444 --target-port=4444
37+
- name: Wait for Pods to get started
38+
run: |
39+
sleep 10
40+
podsCount=$(kubectl get pods -l component=selenium-grid-4 | wc -l)
41+
ctr=0
42+
while [ $podsCount -lt 6 ]
43+
do
44+
((ctr++))
45+
if [[ $ctr -eq 30 ]]; then
46+
echo "Timed out while waiting for Pods to get ready"
47+
exit 1
48+
fi
49+
echo "Waiting for pods to get started...."
50+
sleep 10
51+
podsCount=$(kubectl get pods -l component=selenium-grid-4 | wc -l)
52+
done
53+
echo "All the pods are started"
54+
- name: Waiting for Pods to get ready
55+
run: |
56+
echo "Waiting for pods to attain ready state...."
57+
kubectl wait --for=condition=ready pod -l name=selenium-router --timeout=300s
58+
kubectl wait --for=condition=ready pod -l name=selenium-distributor --timeout=300s
59+
kubectl wait --for=condition=ready pod -l name=selenium-event-bus --timeout=300s
60+
kubectl wait --for=condition=ready pod -l name=selenium-chrome-node --timeout=300s
61+
kubectl get pods -l component=selenium-grid-4
62+
echo "All pods are in ready state now"
63+
- name: Listing all the Grid 4 components
64+
run: kubectl get all -l component=selenium-grid-4
65+
- name: Testing the Grid
66+
run: |
67+
SELENIUM_GRID_URL=$(minikube service selenium-router-deployment --url)
68+
echo $SELENIUM_GRID_URL
69+
python3 $PWD/tests/K8sSmokeTest.py $SELENIUM_GRID_URL

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,21 @@ Here is an example using a Hub and 3 Nodes (Chrome, Firefox, and Opera):
244244

245245
___
246246

247-
## Deploying to Kubernetes (:warning: not tested yet with Selenium 4 images)
247+
## Deploying to Kubernetes
248+
Here are the steps to deploy the Grid 4 to a Kubernetes cluster.
249+
``` bash
250+
# Deploying all the grid components to kubernetes
251+
$ kubectl apply -f k8s-deployment-full-grid.yaml
252+
253+
# Exposing the router
254+
$ kubectl expose deployment selenium-router-deployment --type=NodePort --port=4444
255+
256+
# Get the router URL to access the grid from outside K8s cluster
257+
$ minikube service selenium-router-deployment --url
258+
259+
# To list all the Grid componenets
260+
$ kubectl get all -l component=selenium-grid-4
261+
```
248262

249263
Check out [the Kubernetes examples](https://github.com/kubernetes/examples/tree/master/staging/selenium)
250264
on how to deploy selenium hub and nodes on a Kubernetes cluster.

0 commit comments

Comments
 (0)