text stringlengths 0 59.1k |
|---|
The Selenium Nodes will need to know how to get to the Hub, let's create a service for the nodes to connect to. |
```console |
kubectl create --filename=staging/selenium/selenium-hub-svc.yaml |
``` |
### Verify Selenium Hub Deployment |
Let's verify our deployment of Selenium hub by connecting to the web console. |
#### Kubernetes Nodes Reachable |
If your Kubernetes nodes are reachable from your network, you can verify the hub by hitting it on the nodeport. You can retrieve the nodeport by typing `kubectl describe svc selenium-hub`, however the snippet below automates that by using kubectl's template functionality: |
```console |
export NODEPORT=`kubectl get svc --selector='app=selenium-hub' --output=template --template="{{ with index .items 0}}{{with index .spec.ports 0 }}{{.nodePort}}{{end}}{{end}}"` |
export NODE=`kubectl get nodes --output=template --template="{{with index .items 0 }}{{.metadata.name}}{{end}}"` |
curl http://$NODE:$NODEPORT |
``` |
#### Kubernetes Nodes Unreachable |
If you cannot reach your Kubernetes nodes from your network, you can proxy via kubectl. |
```console |
export PODNAME=`kubectl get pods --selector="app=selenium-hub" --output=template --template="{{with index .items 0}}{{.metadata.name}}{{end}}"` |
kubectl port-forward $PODNAME 4444:4444 |
``` |
In a separate terminal, you can now check the status. |
```console |
curl http://localhost:4444 |
``` |
#### Using Google Container Engine |
If you are using Google Container Engine, you can expose your hub via the internet. This is a bad idea for many reasons, but you can do it as follows: |
```console |
kubectl expose deployment selenium-hub --name=selenium-hub-external --labels="app=selenium-hub,external=true" --type=LoadBalancer |
``` |
Then wait a few minutes, eventually your new `selenium-hub-external` service will be assigned a load balanced IP from gcloud. Once `kubectl get svc selenium-hub-external` shows two IPs, run this snippet. |
```console |
export INTERNET_IP=`kubectl get svc --selector="app=selenium-hub,external=true" --output=template --template="{{with index .items 0}}{{with index .status.loadBalancer.ingress 0}}{{.ip}}{{end}}{{end}}"` |
curl http://$INTERNET_IP:4444/ |
``` |
You should now be able to hit `$INTERNET_IP` via your web browser, and so can everyone else on the Internet! |
### Deploy Firefox and Chrome Nodes: |
Now that the Hub is up, we can deploy workers. |
This will deploy 2 Chrome nodes. |
```console |
kubectl create --filename=staging/selenium/selenium-node-chrome-deployment.yaml |
``` |
And 2 Firefox nodes to match. |
```console |
kubectl create --filename=staging/selenium/selenium-node-firefox-deployment.yaml |
``` |
Once the pods start, you will see them show up in the Selenium Hub interface. |
### Run a Selenium Job |
Let's run a quick Selenium job to validate our setup. |
#### Setup Python Environment |
First, we need to start a python container that we can attach to, then get inside this container. |
```console |
kubectl run selenium-python --tty -i --image=python:slim bash |
``` |
Once inside, we need to install the Selenium library |
```console |
pip install selenium |
``` |
#### Run Selenium Job with Python |
We're all set up, start the python interpreter. |
```console |
python |
``` |
And paste in the contents of selenium-test.py. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.