Selenium:浏览器无法在Kubernetes上运行的Moon上启动

xfyts7mz  于 2022-12-23  发布在  Kubernetes
关注(0)|答案(1)|浏览(188)
    • 问题摘要:**我在虚拟机的K8s群集上安装了moon2。尝试使用Selenium连接到Chrome时卡住。Chrome pod卡在"挂起"状态,我在日志中看到以下错误。

2022/12/16 23:39:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: creating config map 2022/12/16 23:39:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: config map created 2022/12/16 23:39:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: creating pod 2022/12/16 23:39:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: pod created 2022/12/16 23:39:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: waiting pod W1216 23:44:46.574953 1 reflector.go:442] pkg/mod/k8s.io/client-go@v0.23.3/tools/cache/reflector.go:167: watch of *v1.Pod ended with: an error on the server ("unable to decode an event from the watch stream: context canceled") has prevented the request from succeeding 2022/12/16 23:44:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: client disconnected while waited for resources 2022/12/16 23:44:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: deleting pod 2022/12/16 23:44:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: pod deleted 2022/12/16 23:44:46 moon-f54d9dcf8-pctxm: moon: firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c: deleting config map 2

    • 这就是我所尝试的**

1.在ubuntu虚拟机上安装了Kubernetes群集。

~$kubectl get pods -n moon

NAME                   READY   STATUS    RESTARTS        AGE
moon-f54d9dcf8-pctxm   3/3     Running   7 (4d14h ago)   4d14h
moon-f54d9dcf8-v6v58   3/3     Running   7 (4d14h ago)   4d14h
~$kubectl get svc newmoon -n moon
NAME      TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
newmoon   LoadBalancer   10.233.58.212   10.6.152.56   4444:30898/TCP,8080:31836/TCP   2d23h
~$ kubectl get browsersets -n moon -o yaml
apiVersion: v1
items:
- apiVersion: moon.aerokube.com/v1
  kind: BrowserSet
  metadata:
    annotations:
      meta.helm.sh/release-name: moon
      meta.helm.sh/release-namespace: moon
    creationTimestamp: "2022-12-15T05:29:22Z"
    generation: 1
    labels:
      app.kubernetes.io/managed-by: Helm
    name: default
    namespace: moon
    resourceVersion: "27996"
    uid: b072a650-5ab0-4add-a6b1-9d73de8a09ce
  spec:
    cypress:
      chrome:
        repository: quay.io/browsers/cypress-chrome
      chromium:
        repository: quay.io/browsers/cypress-chromium
      edge:
        repository: quay.io/browsers/cypress-edge
      electron:
        repository: quay.io/browsers/cypress-electron
      firefox:
        repository: quay.io/browsers/cypress-firefox
    devtools:
      chrome:
        repository: quay.io/browser/devtools-google-chrome-stable
    playwright:
      chrome:
        repository: quay.io/browser/playwright-chrome
      chromium:
        repository: quay.io/browser/playwright-chromium
      firefox:
        repository: quay.io/browser/playwright-firefox
      webkit:
        repository: quay.io/browser/playwright-webkit
    selenium:
      MicrosoftEdge:
        default: 106.0.1370.42-2
        repository: quay.io/browser/microsoft-edge-stable
      chrome:
        default: 106.0.5249.119-2
        repository: quay.io/browser/google-chrome-stable
      firefox:
        default: 106.0.0-2
        repository: quay.io/browser/firefox-mozilla-build
      opera:
        default: 91.0.4516.65-3
        repository: quay.io/browser/opera-stable
      safari:
        default: 15.0-0
        repository: quay.io/browser/safari
kind: List
metadata:
  resourceVersion: ""
~$

但是当我尝试将其用作Selenium中的远程服务器时,浏览器陷入挂起状态
不知道缺少了什么,任何帮助都将不胜感激。

kpbwa7wx

kpbwa7wx1#

可能您的Kubernetes节点上的计算资源(通常是CPU或内存)不足。更罕见的情况是一些污点被分配到Kubernetes节点。要检查发生了什么,您可以在运行代码时列出pod,并检查是否有浏览器pod长时间处于Pending状态。然后简单地描述相应的pod,并查看输出的末尾以了解原因。

$ kubectl describe po firefox-106-0-0-2-5a3fb0db-51da-45e4-9fd3-03bebb03ac7c -n moon

如果您遇到计算资源不足的问题,请确保您有足够大的Kubernetes节点。我们建议使用具有4或8个CPU和8或16 GB内存的节点。

相关问题