<p>In Kubernetes cluster I am trying to build a selenium hub and node. I am able to do it in the distributive mode, but trying to do in hub node mode.</p>
<h1>Hub-deployment.yaml</h1>
<pre><code>apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: selenium-hub
spec:
  selector:
    matchLabels:
      app: selenium-hub
  replicas: 1
  template:
    metadata:
      labels:
        app: selenium-hub
    spec:
      containers:
        - name: selenium-hub
          image: selenium/hub:4.0 
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 4444
          resources:
            limits:
              cpu: 1000m
              memory: 1000Mi
            requests:
              cpu: 50m
              memory: 100Mi
      imagePullSecrets:
        - name: regcred 
</code></pre>
<h1>hub-service.yaml</h1>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: selenium-hub
spec:
  ports:
  - name: &quot;selenium-hub&quot;
    port: 4444
    targetPort: 4444
  selector:
    app: selenium-hub
  type: ClusterIP
</code></pre>
<h1>node-chrome-deployment.yaml</h1>
<pre><code>apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: selenium-chrome-node
spec:
  selector:
    matchLabels:
      app: selenium-chrome-node
  replicas: 1
  template:
    metadata:
      labels:
        app: selenium-chrome-node
    spec:
      containers:
        - name: selenium-chrome-node
          image: selenium/node-chrome:4.0
          env:
            - name: SE_EVENT_BUS_HOST
              value: &quot;selenium-hub&quot;
            - name: SE_EVENT_BUS_PUBLISH_PORT
              value: &quot;4442&quot;
            - name: SE_EVENT_BUS_SUBSCRIBE_PORT
              value: &quot;4443&quot;
            - name: SE_NODE_MAX_CONCURRENT_SESSIONS
              value: &quot;8&quot;
            - name: SE_SESSION_REQUEST_TIMEOUT
              value: &quot;3600&quot;
            - name: SE_NODE_MAX_SESSIONS
              value: &quot;10&quot;
            - name: SE_NODE_OVERRIDE_MAX_SESSIONS    
              value: &quot;true&quot;      
            - name: SE_NODE_GRID_URL
              value: &quot;http://selenium-hub:4444&quot;
            - name: HUB_HOST
              value: &quot;selenium-hub&quot;
            - name: HUB_PORT
              value: &quot;4444&quot;  
            - name: SE_NODE_HOST
              value: &quot;selenium-chrome-node&quot;
            - name: SE_NODE_PORT
              value: &quot;5555&quot;  
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              cpu: 1000m
              memory: 1000Mi
            requests:
              cpu: 50m
              memory: 100Mi
          ports:
            - containerPort: 5555
          volumeMounts:
            - mountPath: /dev/shm
              name: dshm
      imagePullSecrets:
        - name: regcred
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory


</code></pre>
<h1>node-chrome-service.yaml</h1>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: selenium-chrome-node
spec:
  ports:
  - name: &quot;selenium-chrome-node&quot;
    port: 5555 
    targetPort: 5555
  selector:
    app: selenium-chrome-node
  type: ClusterIP

</code></pre>
<p>Logs:</p>
<pre><code>[events]
publish = &quot;tcp://selenium-hub:4442&quot;
subscribe = &quot;tcp://selenium-hub:4443&quot;

[server]
host = &quot;selenium-chrome-node&quot;
port = &quot;5555&quot;
[node]
grid-url = &quot;http://selenium-hub:4444&quot;
session-timeout = &quot;300&quot;
override-max-sessions = true
detect-drivers = false
max-sessions = 10

[[node.driver-configuration]]
display-name = &quot;chrome&quot;
stereotype = '{&quot;browserName&quot;: &quot;chrome&quot;, &quot;browserVersion&quot;: &quot;95.0&quot;, &quot;platformName&quot;: &quot;Linux&quot;}'
max-sessions = 10
.
.
.
17:00:27.549 INFO [NodeServer$1.start] - Starting registration process for node id d6a68bf5-e5b4-483a-9e71-408b3c158c0b
17:00:27.609 INFO [NodeServer.execute] - Started Selenium node 4.0.0 (revision 3a21814679): http://selenium-chrome-node:5555
17:00:27.621 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
17:00:37.629 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
17:00:47.636 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
17:00:57.641 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
17:01:07.646 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
17:01:17.650 INFO [NodeServer$1.lambda$start$1] - Sending registration event...

</code></pre>
<p>This registration never happens</p>
<p>Logs of hub pod:</p>
<pre><code>4443, advertising as tcp://100.106.0.5:4443]
17:00:25.242 INFO [UnboundZmqEventBus.&lt;init&gt;] - Connecting to tcp://100.106.0.5:4442 and tcp://100.106.0.5:4443
17:00:25.324 INFO [UnboundZmqEventBus.&lt;init&gt;] - Sockets created
17:00:26.333 INFO [UnboundZmqEventBus.&lt;init&gt;] - Event bus ready
17:00:27.621 INFO [Hub.execute] - Started Selenium Hub 4.0.0 (revision 3a21814679): http://100.106.0.5:4444

</code></pre>
<p>How to get the selenium hub 4.0 and chrome-node 4.0 registered ?</p>

<p>The hub also needs to expose the publisher and subscriber ports, so that the it can be reached by your node/chrome pod. Update to the following:</p>
<p><strong>hub-service.yaml</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: selenium-hub
spec:
  ports:
  - name: &quot;selenium-hub&quot;
    port: 4444
    targetPort: 4444
  - name: &quot;subscribe-events&quot;
    port: 4443
    targetPort: 4443
  - name: &quot;publish-events&quot;
    port: 4442
    targetPort: 4442
  selector:
    app: selenium-hub
  type: ClusterIP
</code></pre>
<p>Also found that you have legacy env variables from grid v3 and the v4 alpha/beta releases for your node. These need to be removed, see amended config below:</p>
<p><strong>node-chrome-deployment.yaml</strong></p>
<pre><code>apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: selenium-chrome-node
spec:
  selector:
    matchLabels:
      app: selenium-chrome-node
  replicas: 1
  template:
    metadata:
      labels:
        app: selenium-chrome-node
    spec:
      containers:
        - name: selenium-chrome-node
          image: selenium/node-chrome:4.0
          env:
            - name: SE_EVENT_BUS_HOST
              value: &quot;selenium-hub&quot;
            - name: SE_EVENT_BUS_PUBLISH_PORT
              value: &quot;4442&quot;
            - name: SE_EVENT_BUS_SUBSCRIBE_PORT
              value: &quot;4443&quot;
            - name: SE_SESSION_REQUEST_TIMEOUT
              value: &quot;3600&quot;
            - name: SE_NODE_MAX_SESSIONS
              value: &quot;10&quot;
            - name: SE_NODE_OVERRIDE_MAX_SESSIONS
              value: &quot;true&quot;
            - name: SE_NODE_GRID_URL
              value: &quot;http://selenium-hub:4444&quot;
            - name: SE_NODE_HOST
              value: &quot;selenium-chrome-node&quot;
            - name: SE_NODE_PORT
              value: &quot;5555&quot;
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              cpu: 1000m
              memory: 1000Mi
            requests:
              cpu: 50m
              memory: 100Mi
          ports:
            - containerPort: 5555
          volumeMounts:
            - mountPath: /dev/shm
              name: dshm
      imagePullSecrets:
        - name: regcred
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
</code></pre>
<p>Configuration that has been removed:</p>
<ul>
<li>SE_NODE_MAX_CONCURRENT_SESSIONS</li>
<li>HUB_HOST</li>
<li>HUB_PORT</li>
</ul>
