From cd409d6f3e33766e06bb56407a57935444d5836c Mon Sep 17 00:00:00 2001 From: Vlad Ilie Date: Fri, 23 Mar 2018 16:37:37 +0200 Subject: [PATCH] Update selenium examples to use deployments and newer selenium --- staging/selenium/README.md | 20 +++++++++---------- ...b-rc.yaml => selenium-hub-deployment.yaml} | 9 +++++---- ...l => selenium-node-chrome-deployment.yaml} | 9 +++++---- ... => selenium-node-firefox-deployment.yaml} | 16 +++++++++++---- 4 files changed, 32 insertions(+), 22 deletions(-) rename staging/selenium/{selenium-hub-rc.yaml => selenium-hub-deployment.yaml} (85%) rename staging/selenium/{selenium-node-chrome-rc.yaml => selenium-node-chrome-deployment.yaml} (80%) rename staging/selenium/{selenium-node-firefox-rc.yaml => selenium-node-firefox-deployment.yaml} (63%) diff --git a/staging/selenium/README.md b/staging/selenium/README.md index ee101361..2fb33b3d 100644 --- a/staging/selenium/README.md +++ b/staging/selenium/README.md @@ -15,13 +15,13 @@ Your cluster must have 4 CPU and 6 GB of RAM to complete the example up to the s We will be using Selenium Grid Hub to make our Selenium install scalable via a master/worker model. The Selenium Hub is the master, and the Selenium Nodes are the workers(not to be confused with Kubernetes nodes). We only need one hub, but we're using a replication controller to ensure that the hub is always running: ```console -kubectl create --filename=examples/selenium/selenium-hub-rc.yaml +kubectl create --filename=staging/selenium/selenium-hub-deployment.yaml ``` 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=examples/selenium/selenium-hub-svc.yaml +kubectl create --filename=staging/selenium/selenium-hub-svc.yaml ``` ### Verify Selenium Hub Deployment @@ -59,7 +59,7 @@ curl http://localhost:4444 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 rc selenium-hub --name=selenium-hub-external --labels="app=selenium-hub,external=true" --type=LoadBalancer +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. @@ -79,13 +79,13 @@ Now that the Hub is up, we can deploy workers. This will deploy 2 Chrome nodes. ```console -kubectl create --filename=examples/selenium/selenium-node-chrome-rc.yaml +kubectl create --filename=staging/selenium/selenium-node-chrome-deployment.yaml ``` And 2 Firefox nodes to match. ```console -kubectl create --filename=examples/selenium/selenium-node-firefox-rc.yaml +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. @@ -160,8 +160,8 @@ Congratulations, your Selenium Hub is up, with Firefox and Chrome nodes! If you need more Firefox or Chrome nodes, your hardware is the limit: ```console -kubectl scale rc selenium-node-firefox --replicas=10 -kubectl scale rc selenium-node-chrome --replicas=10 +kubectl scale deployment selenium-node-firefox --replicas=10 +kubectl scale deployment selenium-node-chrome --replicas=10 ``` You now have 10 Firefox and 10 Chrome nodes, happy Seleniuming! @@ -185,9 +185,9 @@ Adapted from: https://github.com/SeleniumHQ/docker-selenium To remove all created resources, run the following: ```console -kubectl delete rc selenium-hub -kubectl delete rc selenium-node-chrome -kubectl delete rc selenium-node-firefox +kubectl delete deployment selenium-hub +kubectl delete deployment selenium-node-chrome +kubectl delete deployment selenium-node-firefox kubectl delete deployment selenium-python kubectl delete svc selenium-hub kubectl delete svc selenium-hub-external diff --git a/staging/selenium/selenium-hub-rc.yaml b/staging/selenium/selenium-hub-deployment.yaml similarity index 85% rename from staging/selenium/selenium-hub-rc.yaml rename to staging/selenium/selenium-hub-deployment.yaml index f48510e1..6a8736b2 100644 --- a/staging/selenium/selenium-hub-rc.yaml +++ b/staging/selenium/selenium-hub-deployment.yaml @@ -1,5 +1,5 @@ -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: selenium-hub labels: @@ -7,7 +7,8 @@ metadata: spec: replicas: 1 selector: - app: selenium-hub + matchLabels: + app: selenium-hub template: metadata: labels: @@ -15,7 +16,7 @@ spec: spec: containers: - name: selenium-hub - image: selenium/hub:2.53.0 + image: selenium/hub:3.11 ports: - containerPort: 4444 resources: diff --git a/staging/selenium/selenium-node-chrome-rc.yaml b/staging/selenium/selenium-node-chrome-deployment.yaml similarity index 80% rename from staging/selenium/selenium-node-chrome-rc.yaml rename to staging/selenium/selenium-node-chrome-deployment.yaml index 3c49c1b4..a9b923ad 100644 --- a/staging/selenium/selenium-node-chrome-rc.yaml +++ b/staging/selenium/selenium-node-chrome-deployment.yaml @@ -1,5 +1,5 @@ -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: selenium-node-chrome labels: @@ -7,7 +7,8 @@ metadata: spec: replicas: 2 selector: - app: selenium-node-chrome + matchLabels: + app: selenium-node-chrome template: metadata: labels: @@ -15,7 +16,7 @@ spec: spec: containers: - name: selenium-node-chrome - image: selenium/node-chrome-debug:2.53.0 + image: selenium/node-chrome-debug:3.11 ports: - containerPort: 5900 env: diff --git a/staging/selenium/selenium-node-firefox-rc.yaml b/staging/selenium/selenium-node-firefox-deployment.yaml similarity index 63% rename from staging/selenium/selenium-node-firefox-rc.yaml rename to staging/selenium/selenium-node-firefox-deployment.yaml index d6f66578..3ce6c9c9 100644 --- a/staging/selenium/selenium-node-firefox-rc.yaml +++ b/staging/selenium/selenium-node-firefox-deployment.yaml @@ -1,5 +1,5 @@ -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: selenium-node-firefox labels: @@ -7,17 +7,25 @@ metadata: spec: replicas: 2 selector: - app: selenium-node-firefox + matchLabels: + app: selenium-node-firefox template: metadata: labels: app: selenium-node-firefox spec: + volumes: + - name: dshm + emptyDir: + medium: Memory containers: - name: selenium-node-firefox - image: selenium/node-firefox-debug:2.53.0 + image: selenium/node-firefox-debug:3.11 ports: - containerPort: 5900 + volumeMounts: + - mountPath: /dev/shm + name: dshm env: - name: HUB_PORT_4444_TCP_ADDR value: "selenium-hub"