How to configure kubernetes selenium container to reach external net?

12/2/2017

I tried examples selenium via windows minikube. https://github.com/kubernetes/kubernetes/tree/master/examples/selenium

at Inside the container, i cant install selenium, what should i do?

pip install selenium

cmd:

kubectl run selenium-hub --image selenium/hub:2.53.1 --port 4444
kubectl expose deployment selenium-hub --type=NodePort
kubectl run selenium-node-chrome --image selenium/node-chrome:2.53.1 --env="HUB_PORT_4444_TCP_ADDR=selenium-hub" --env="HUB_PORT_4444_TCP_PORT=4444"
kubectl scale deployment selenium-node-chrome --replicas=4
kubectl run selenium-python --image=google/python-hello  
kubectl exec --stdin=true --tty=true selenium-python-6479976d89-ww7jv  bash

display:

PS C:\Program Files\Docker Toolbox\dockerfiles> kubectl get pods
NAME                                    READY     STATUS    RESTARTS   AGE
selenium-hub-5ffc6ff7db-gwq95           1/1       Running   0          15m
selenium-node-chrome-8659b47488-brwb4   1/1       Running   0          8m
selenium-node-chrome-8659b47488-dnrwr   1/1       Running   0          8m
selenium-node-chrome-8659b47488-hwvvk   1/1       Running   0          11m
selenium-node-chrome-8659b47488-t8g59   1/1       Running   0          8m
selenium-python-6479976d89-ww7jv        1/1       Running   0          6m
PS C:\Program Files\Docker Toolbox\dockerfiles>  kubectl get services
NAME           TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
kubernetes     ClusterIP   10.0.0.1     <none>        443/TCP          17m
selenium-hub   NodePort    10.0.0.230   <none>        4444:32469/TCP   16m
PS C:\Program Files\Docker Toolbox\dockerfiles> kubectl exec --stdin=true --tty=true selenium-python-6479976d89-ww7jv  bash
root@selenium-python-6479976d89-ww7jv:/app# ping yahoo.com
ping: unknown host yahoo.com
-- dlis168
kubernetes
minikube
selenium

2 Answers

5/31/2018

You can avoid this problem by providing ConfigMap to configure kube-dns for custom dns.

apiVersion: v1
kind: ConfigMap
metadata:
name: kube-dns
namespace: kube-system
data:
 stubDomains: |
  {"acme.local": ["1.2.3.4"]}
 upstreamNameservers: |
  ["8.8.8.8"]

See more details at Kubernetes Reference Doc

-- Mursil Sayed
Source: StackOverflow

12/2/2017

It looks like your pod can not resolve DNS. You need to test if your cluster has working kube-dns in kube-system namespace. If it is there and operational, check if it correctly resolves names when called upon directly by pod IP and maybe verify that your containers have correct content in /etc/resolv.conf when started

-- Radek 'Goblin' Pieczonka
Source: StackOverflow