Skip to content

Commit

Permalink
K8s deployment (#1113)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sahajamit committed Oct 22, 2020
1 parent ff51c1c commit deadadd
Show file tree
Hide file tree
Showing 4 changed files with 489 additions and 1 deletion.
69 changes: 69 additions & 0 deletions .github/workflows/k8s-deploy-test.yml
@@ -0,0 +1,69 @@
name: "Test Selenium Grid 4 deployment on Minikube Cluster"

on:
push:
branches:
- trunk
pull_request:
branches:
- trunk

jobs:
deploy:
name: Deployment and testing of Grid 4 on Minikube
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Minikube
uses: manusa/actions-setup-minikube@v2.0.1
with:
minikube version: "v1.13.1"
kubernetes version: "v1.19.2"
github token: ${{ secrets.GITHUB_TOKEN }}
driver: none
- name: Interact with Minikube
run: kubectl get nodes
- name: Output Cluster info
run: |
kubectl cluster-info
kubectl get pods -n kube-system
echo "current-context:" $(kubectl config current-context)
echo "environment-kubeconfig:" ${KUBECONFIG}
- name: Deploy Grid4 on minikube
run: kubectl apply -f k8s-deployment-full-grid.yaml
- name: Expose Router service
run: kubectl expose deployment selenium-router-deployment --type=NodePort --port=4444 --target-port=4444
- name: Wait for Pods to get started
run: |
sleep 10
podsCount=$(kubectl get pods -l component=selenium-grid-4 | wc -l)
ctr=0
while [ $podsCount -lt 6 ]
do
((ctr++))
if [[ $ctr -eq 30 ]]; then
echo "Timed out while waiting for Pods to get ready"
exit 1
fi
echo "Waiting for pods to get started...."
sleep 10
podsCount=$(kubectl get pods -l component=selenium-grid-4 | wc -l)
done
echo "All the pods are started"
- name: Waiting for Pods to get ready
run: |
echo "Waiting for pods to attain ready state...."
kubectl wait --for=condition=ready pod -l name=selenium-router --timeout=300s
kubectl wait --for=condition=ready pod -l name=selenium-distributor --timeout=300s
kubectl wait --for=condition=ready pod -l name=selenium-event-bus --timeout=300s
kubectl wait --for=condition=ready pod -l name=selenium-chrome-node --timeout=300s
kubectl get pods -l component=selenium-grid-4
echo "All pods are in ready state now"
- name: Listing all the Grid 4 components
run: kubectl get all -l component=selenium-grid-4
- name: Testing the Grid
run: |
SELENIUM_GRID_URL=$(minikube service selenium-router-deployment --url)
echo $SELENIUM_GRID_URL
python3 $PWD/tests/K8sSmokeTest.py $SELENIUM_GRID_URL
16 changes: 15 additions & 1 deletion README.md
Expand Up @@ -244,7 +244,21 @@ Here is an example using a Hub and 3 Nodes (Chrome, Firefox, and Opera):

___

## Deploying to Kubernetes (:warning: not tested yet with Selenium 4 images)
## Deploying to Kubernetes
Here are the steps to deploy the Grid 4 to a Kubernetes cluster.
``` bash
# Deploying all the grid components to kubernetes
$ kubectl apply -f k8s-deployment-full-grid.yaml

# Exposing the router
$ kubectl expose deployment selenium-router-deployment --type=NodePort --port=4444

# Get the router URL to access the grid from outside K8s cluster
$ minikube service selenium-router-deployment --url

# To list all the Grid componenets
$ kubectl get all -l component=selenium-grid-4
```

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

0 comments on commit deadadd

Please sign in to comment.