k8s中部署分布式UI自动化hub地址无法访问

hub.yaml配置

apiVersion: apps/v1
kind: Deployment
metadata:
  name: selenium-hub
  labels:
    name: selenium-hub
spec:
  replicas: 1
  selector:
    matchLabels:
      name: selenium-hub
  template:
    metadata:
      labels:
        name: selenium-hub
    spec:
      containers:
        - name: selenium-hub
          image: selenium/hub:4.0.0-rc-2-prerelease-20210923
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 4444
            - containerPort: 4442
            - containerPort: 4443
            - containerPort: 5557
          env:
            - name: TZ
              value: "Asia/Shanghai"
          volumeMounts:
            - mountPath: "/etc/localtime"
              name: "host-time"
          livenessProbe:
            httpGet:
              path: /grid/console
              port: 4444
            initialDelaySeconds: 30
            timeoutSeconds: 1
            periodSeconds: 5
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /grid/console
              port: 4444
            initialDelaySeconds: 30
            timeoutSeconds: 1
            periodSeconds: 5
            failureThreshold: 3
      volumes:
        - name: "host-time"
          hostPath:
            path: "/etc/localtime"
---
apiVersion: v1
kind: Service
metadata:
  name: selenium-hub
  labels:
    name: selenium-hub
spec:
  type: NodePort
  ports:
    - name: port1
      protocol: TCP
      port: 4442
      targetPort: 4442
    - name: port2
      protocol: TCP
      port: 4443
      targetPort: 4443
    - name: port3
      protocol: TCP
      port: 5557
      targetPort: 5557
    - port: 4444
      targetPort: 4444
      name: port0
      nodePort: 32757
  selector:
    name: selenium-hub
  sessionAffinity: None

hub.yaml配置

apiVersion: apps/v1
kind: Deployment
metadata:
  name: selenium-node-chrome
  labels:
    name: selenium-node-chrome
spec:
  replicas: 2
  selector:
    matchLabels:
      name: selenium-node-chrome
  template:
    metadata:
      labels:
        name: selenium-node-chrome
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - topologyKey: kubernetes.io/hostname
              labelSelector:
                matchLabels:
                  name: selenium-node-chrome
      containers:
        - name: selenium-node-chrome
          image: selenium/node-chrome:4.0.0-rc-2-prerelease-20210923
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 5900
            - containerPort: 5553
          env:
            - name: SE_EVENT_BUS_HOST
              value: "selenium-hub"
            - name: SE_EVENT_BUS_PUBLISH_PORT
              value: "4442"
            - name: SE_EVENT_BUS_SUBSCRIBE_PORT
              value: "4443"
            - name: SE_NODE_MAX_SESSIONS
              value: "20"
            - name: SE_NODE_OVERRIDE_MAX_SESSIONS
              value: "true"
            - name: TZ
              value: "Asia/Shanghai"
          resources:
            requests:
              memory: "500Mi"
          volumeMounts:
            - mountPath: "/dev/shm"
              name: "dshm"
            - mountPath: "/etc/localtime"
              name: "host-time"
      volumes:
        - name: "dshm"
          hostPath:
            path: "/dev/shm"
        - name: "host-time"
          hostPath:
            path: "/etc/localtime"
---
apiVersion: v1
kind: Service
metadata:
  name: selenium-node-chrome
  labels:
    name: selenium-node-chrome
spec:
  type: NodePort
  ports:
    - port: 5900
      targetPort: 5900
      name: port0
      nodePort: 31002
  selector:
    name: selenium-node-chrome
  sessionAffinity: None

pod状态

image
网络ip

如下链接无法访问

https://192.168.139.134:32757/ui/index.html
image

kubectl get pod -owide

查看一下pod在哪个服务器运行,然后去访问那个服务器的IP

kubectl get svc 看看服务的端口