将 Selenium 代码连接到 k8s 中的 Selenium Hub
Connect Selenium Code to Selenium Hub in k8s
我想通过 selenium hub 和 chrome 节点容器在 kubernetes 上 运行 我的自动化测试脚本。
我的测试脚本也是容器的形式,运行ning是一个pod。
我的测试脚本使用 localhost:4444 连接到网格。
但是网格的 NodePort 为 31376,每次我创建一个新的 selenium 网格服务时它都会不断变化。
有什么方法可以为我的 selenium 集线器保留一个恒定的 NodePort,以便我的脚本可以 运行。
Selenium 中心服务:
apiVersion: v1
kind: Service
metadata:
name: selenium-hub
labels:
app: selenium-hub
spec:
ports:
- port: 4444
targetPort: 4444
name: port0
selector:
app: selenium-hub
type: NodePort
sessionAffinity: None
我不想每次执行命令时都将 link 更改为 selenium hub。
这是我的服务描述:-
C:\KUBE>kubectl describe service selenium-hub
Name: selenium-hub
Namespace: default
Labels: app=selenium-hub
Annotations: <none>
Selector: app=selenium-hub
Type: NodePort
IP: 10.106.49.182
Port: port0 4444/TCP
TargetPort: 4444/TCP
NodePort: port0 31376/TCP
Endpoints:
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
谢谢。
根据the documentation on NodePort
services
If you want a specific port number, you can specify a value in the nodePort field, and the system will allocate you that port or else the API transaction will fail (i.e. you need to take care about possible port collisions yourself). The value you specify must be in the configured range for node ports.
Here is an example,在你的情况下看起来像
apiVersion: v1
kind: Service
metadata:
name: selenium-hub
labels:
app: selenium-hub
spec:
ports:
- port: 4444
targetPort: 4444
name: port0
nodePort: <your-desired-port>
selector:
app: selenium-hub
type: NodePort
sessionAffinity: None
我想通过 selenium hub 和 chrome 节点容器在 kubernetes 上 运行 我的自动化测试脚本。 我的测试脚本也是容器的形式,运行ning是一个pod。 我的测试脚本使用 localhost:4444 连接到网格。 但是网格的 NodePort 为 31376,每次我创建一个新的 selenium 网格服务时它都会不断变化。
有什么方法可以为我的 selenium 集线器保留一个恒定的 NodePort,以便我的脚本可以 运行。
Selenium 中心服务:
apiVersion: v1
kind: Service
metadata:
name: selenium-hub
labels:
app: selenium-hub
spec:
ports:
- port: 4444
targetPort: 4444
name: port0
selector:
app: selenium-hub
type: NodePort
sessionAffinity: None
我不想每次执行命令时都将 link 更改为 selenium hub。
这是我的服务描述:-
C:\KUBE>kubectl describe service selenium-hub
Name: selenium-hub
Namespace: default
Labels: app=selenium-hub
Annotations: <none>
Selector: app=selenium-hub
Type: NodePort
IP: 10.106.49.182
Port: port0 4444/TCP
TargetPort: 4444/TCP
NodePort: port0 31376/TCP
Endpoints:
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
谢谢。
根据the documentation on NodePort
services
If you want a specific port number, you can specify a value in the nodePort field, and the system will allocate you that port or else the API transaction will fail (i.e. you need to take care about possible port collisions yourself). The value you specify must be in the configured range for node ports.
Here is an example,在你的情况下看起来像
apiVersion: v1
kind: Service
metadata:
name: selenium-hub
labels:
app: selenium-hub
spec:
ports:
- port: 4444
targetPort: 4444
name: port0
nodePort: <your-desired-port>
selector:
app: selenium-hub
type: NodePort
sessionAffinity: None