├── selenium-hub-svc.yaml ├── selenium-node-firefox-rc.yaml ├── selenium-hub-rc.yaml ├── selenium-node-chrome-rc.yaml ├── LICENSE └── README.md /selenium-hub-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: selenium-hub 5 | labels: 6 | name: selenium-hub 7 | spec: 8 | ports: 9 | - port: 4444 10 | targetPort: 4444 11 | name: hub0 12 | selector: 13 | name: selenium-hub 14 | type: NodePort 15 | sessionAffinity: None 16 | -------------------------------------------------------------------------------- /selenium-node-firefox-rc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | name: selenium-node-firefox 5 | labels: 6 | name: selenium-node-firefox 7 | spec: 8 | replicas: 2 9 | selector: 10 | name: selenium-node-firefox 11 | template: 12 | metadata: 13 | labels: 14 | name: selenium-node-firefox 15 | spec: 16 | containers: 17 | - name: selenium-node-firefox 18 | image: selenium/node-firefox-debug:3.4.0 19 | ports: 20 | - containerPort: 5900 21 | env: 22 | - name: HUB_PORT_4444_TCP_ADDR 23 | value: "selenium-hub" 24 | - name: HUB_PORT_4444_TCP_PORT 25 | value: "4444" 26 | resources: 27 | limits: 28 | memory: "1000Mi" 29 | cpu: "1" -------------------------------------------------------------------------------- /selenium-hub-rc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | name: selenium-hub 5 | labels: 6 | name: selenium-hub 7 | spec: 8 | replicas: 1 9 | selector: 10 | name: selenium-hub 11 | template: 12 | metadata: 13 | labels: 14 | name: selenium-hub 15 | spec: 16 | containers: 17 | - name: selenium-hub 18 | image: selenium/hub:3.4.0 19 | ports: 20 | - containerPort: 4444 21 | resources: 22 | limits: 23 | memory: "1000Mi" 24 | cpu: "1" 25 | livenessProbe: 26 | httpGet: 27 | path: /grid/console 28 | port: 4444 29 | initialDelaySeconds: 30 30 | timeoutSeconds: 5 31 | readinessProbe: 32 | httpGet: 33 | path: /grid/console 34 | port: 4444 35 | initialDelaySeconds: 30 36 | timeoutSeconds: 5 37 | -------------------------------------------------------------------------------- /selenium-node-chrome-rc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | name: selenium-node-chrome 5 | labels: 6 | name: selenium-node-chrome 7 | spec: 8 | replicas: 2 9 | selector: 10 | name: selenium-node-chrome 11 | template: 12 | metadata: 13 | labels: 14 | name: selenium-node-chrome 15 | spec: 16 | containers: 17 | - name: selenium-node-chrome 18 | image: selenium/node-chrome:3.4.0 19 | ports: 20 | - containerPort: 5900 21 | env: 22 | - name: HUB_PORT_4444_TCP_ADDR 23 | value: "selenium-hub" 24 | - name: HUB_PORT_4444_TCP_PORT 25 | value: "4444" 26 | resources: 27 | limits: 28 | memory: "1000Mi" 29 | cpu: "5" 30 | volumeMounts: 31 | - mountPath: "/dev/shm" 32 | name: "dshm" 33 | volumes: 34 | - name: "dshm" 35 | emptyDir: 36 | medium: "Memory" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Manoj Kumar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Kubernetes-docker-selenium 2 | 3 | ### Orchestrating docker-selenium via Kubernetes 4 | 5 | 6 | Kubernetes is a platform for hosting Docker containers in a clustered environment with multiple Docker hosts. Kubernetes is a system for managing containerized applications across a cluster of nodes. 7 | 8 | Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes.Basics of Kubernetes 9 | 10 | #### _Kubernetes 101_ 11 | 12 | - Pod: A group of containers 13 | - Labels: Labels for identifying pods 14 | - Kubelet: Container Agent 15 | - etcd: A metadata service 16 | - Proxy: A load balancer for pods 17 | - Replication Controller: Manages replication of pods 18 | 19 | ## _Using Minikube_ 20 | 21 | Running a Kubernetes environment using [Minikube ](https://kubernetes.io/docs/tutorials/stateless-application/hello-minikube/)for simplicity purpose. 22 | 23 | ### Launching selenium hub 24 | ``` 25 | $ kubectl run selenium-hub --image selenium/hub:3.4.0 --port 4444 26 | ``` 27 | #### Exposing selenium-hub to be able to access externally 28 | ``` 29 | $ kubectl expose deployment selenium-hub --type=NodePort 30 | ``` 31 | 32 | #### To Access the selenium-hub url 33 | ``` 34 | $ minikube service selenium-hub --url 35 | 36 | It would show something like, 37 | http://192.168.99.100:xxxx 38 | ``` 39 | 40 | ### Bringing up Selenium Nodes 41 | ``` 42 | $ kubectl run selenium-node-chrome --image selenium/node-chrome:3.4.0 --env="HUB_PORT_4444_TCP_ADDR=selenium-hub" --env="HUB_PORT_4444_TCP_PORT=4444" 43 | ``` 44 | 45 | ``` 46 | $ kubectl run selenium-node-firefox --image selenium/node-firefox:3.4.0 --env="HUB_PORT_4444_TCP_ADDR=selenium-hub" --env="HUB_PORT_4444_TCP_PORT=4444" 47 | ``` 48 | ### Scaling Selenium Grid cluster 49 | ``` 50 | $ kubectl run selenium-node-chrome --image selenium/node-chrome:3.4.0 --env="HUB_PORT_4444_TCP_ADDR=selenium-hub" --env="HUB_PORT_4444_TCP_PORT=4444" 51 | ``` 52 | 53 | ## _Using Google Container Engine_ 54 | 55 | ### Launch a Selenium hub 56 | ``` 57 | $ kubectl -f create selenium-hub-rc.yaml 58 | ``` 59 | #### Selenium hub as a service for nodes to connect 60 | ``` 61 | kubectl create -f selenium-hub-svc.yml 62 | ``` 63 | 64 | ### Bringing up Selenium nodes 65 | #### Chrome 66 | ``` 67 | $kubectl create -f selenium-node-chrome-rc.yaml 68 | ``` 69 | #### Firefox 70 | ``` 71 | $kubectl create -f selenium-node-firefox-rc.yaml 72 | ``` 73 | 74 | ## _Using Helm_ 75 | 76 | Helm is a tool that streamlines installing and managing Kubernetes applications. 77 | Think of it like apt/yum/homebrew for Kubernetes. 78 | 79 | - A Helm package is bundled up as a chart. 80 | - Charts are Helm packages that contain at least two things: 81 | - A description of the package (Chart.yaml) 82 | - One or more templates, which contain Kubernetes manifest files 83 | 84 | - Charts can be stored on disk, or fetched from remote chart repositories (like Debian or RedHat packages) it users git 85 | under the hood 86 | 87 | #### Helm package can be found here: [helm-selenium ](https://kubeapps.com/charts/stable/selenium) 88 | 89 | To get started, its as simple as: 90 | ``` 91 | $ helm install stable/selenium 92 | ``` 93 | --------------------------------------------------------------------------------