<p>I want to link my selenium/hub container to my chrome and firefox node containers in a POD.</p>

<p>In docker, it was easily defined in the docker compose yaml file.
I want to know how to achieve this linking in kubernetes.</p>

<p>This is what appears on the log.: <a href="https://i.stack.imgur.com/JJnKZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JJnKZ.png" alt="logs"></a><br>
This is the error image: <a href="https://i.stack.imgur.com/DFjNC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DFjNC.png" alt="error"></a></p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mytestingpod
spec:
  containers:
  - name: seleniumhub
    image: selenium/hub
    ports:
    - containerPort: 4444
    hostPort: 4444
  - name: chromenode
    image: selenium/node-chrome-debug
    ports:
    - containerPort: 5901
    links: seleniumhub:hub
  - name: firefoxnode
    image: selenium/node-firefox-debug
    ports:
    - containerPort: 5902
    links: seleniumhub:hub  
</code></pre>

<p><a href="https://i.stack.imgur.com/DFjNC.png" rel="nofollow noreferrer">2</a>: </p>

<p>You don't need to link them. The way Kubernetes works, <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/#resource-sharing-and-communication" rel="nofollow noreferrer">all the containers in the same Pod are already on the same networking namespace</a>, meaning that they can just talk to each other through <code>localhost</code> and the right port.</p>

<blockquote>
  <p>The applications in a pod all use the same network namespace (same IP and port space), and can thus “find” each other and communicate using localhost. Because of this, applications in a pod must coordinate their usage of ports. Each pod has an IP address in a flat shared networking space that has full communication with other physical computers and pods across the network.</p>
</blockquote>

<p>If you want to access the <code>chromenode</code> container from the <code>seleniumhub</code> container, just send a request to localhost:5901.</p>

<p>If you want to access the <code>seleniumhub</code> container from the <code>chromenode</code> container, just send a request to localhost:4444.</p>
