<p>I have a k0s Kubernetes cluster on a single node.  I am trying to run a <code>selenium/standalone-chrome</code> to create a remote Selenium node. The trouble that I am having is that it responds if I port forward <code>4444</code> from the pod, but cannot seem to access it via a Service port. I get connection refused. I don't know if it's because it's ignore connections that non-localhost.</p>
<p>The <code>Pod</code> definition for <code>pod/standalone-chrome</code> is:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: standalone-chrome
spec:
  containers:
  - name: standalone-chrome
    image: selenium/standalone-chrome
    ports:
    - containerPort: 4444
    env:
    - name: JAVA_OPTS
      value: '-Dwebdriver.chrome.whitelistedIps=&quot;&quot;'
</code></pre>
<p>The <code>Service</code> definition I have for <code>service/standalone-chrome-service</code> is:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: standalone-chrome-service
  labels:
    app: standalone-chrome
spec:
  ports:
  - port: 4444
    name: standalone-chrome
  type: ClusterIP
  selector:
    app: standalone-chrome
</code></pre>
<p>This creates the following, along with a <code>busybox</code> container I have just for testing connectivity.</p>
<pre><code>NAME                         READY   STATUS    RESTARTS   AGE
pod/busybox1                 1/1     Running   70         2d22h
pod/standalone-chrome        1/1     Running   0          3m15s

NAME                                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/kubernetes                  ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP          18d
service/standalone-chrome-service   ClusterIP   10.111.12.1     &lt;none&gt;        4444/TCP         3m5s
</code></pre>
<p>The issue I am having now is that I'm not able to access the remote Selenium service via <code>standalone-chrome-service</code>.  I get connection refused.  For example, here is trying to reach it via the <code>busybox1</code> container:</p>
<pre><code>$ wget http://standalone-chrome-service:4444
Connecting to standalone-chrome-service:4444 (10.111.12.1:4444)
wget: can't connect to remote host (10.111.12.1): Connection refused
</code></pre>
<p>I am able to port forward from <code>pod/standalone-chrome</code> to my host machine using <code>kubectl port-forward</code> though and it works OK, which I think confirms a service is successfully running but not accessible via the <code>Service</code>:</p>
<pre><code>$ kubectl port-forward pod/standalone-chrome 4444:4444 &amp;
Forwarding from 127.0.0.1:4444 -&gt; 4444
Forwarding from [::1]:4444 -&gt; 4444
$ wget http://localhost:4444
--2021-11-22 13:37:20--  http://localhost:4444/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:4444... connected.
...
</code></pre>
<p>I'd greatly appreciate any help in figuring out how to get the Selenium remote server accessible via the <code>Service</code>.</p>
<hr />
<p>EDIT: Here is the updated Service definition with <code>name</code>...</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: standalone-chrome-service
  labels:
    app: standalone-chrome
spec:
  ports:
  - port: 4444
    name: standalone-chrome
  type: ClusterIP
  selector:
    name: standalone-chrome
</code></pre>
<p>Here is the output of describe:</p>
<pre><code>Name:              standalone-chrome-service
Namespace:         default
Labels:            app=standalone-chrome
Annotations:       &lt;none&gt;
Selector:          name=standalone-chrome
Type:              ClusterIP
IP Families:       &lt;none&gt;
IP:                10.100.179.116
IPs:               10.100.179.116
Port:              standalone-chrome  4444/TCP
TargetPort:        4444/TCP
Endpoints:         &lt;none&gt;
Session Affinity:  None
Events:            &lt;none&gt;
</code></pre>

gnychis
<p>Service's syntax with:</p>
<pre><code>  selector:
    app: standalone-chrome
</code></pre>
<p>is correct, <code>selector</code> should be matched by <code>label</code>.</p>
<blockquote>
<p>Services match a set of Pods using labels and selectors, a grouping
primitive that allows logical operation on objects in Kubernetes.
Labels are key/value pairs attached to objects</p>
</blockquote>
<p>See for more details <a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/expose/expose-intro/" rel="nofollow noreferrer">Using a Service to Expose Your App</a>.</p>
<p>Now you need to add this <code>label</code> (which is <code>app: standalone-chrome</code>) to your <code>pod.yaml</code> metadata:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: standalone-chrome
  labels:
    app: standalone-chrome # this label should match to selector in service
spec:
  containers:
  - name: standalone-chrome
    image: selenium/standalone-chrome
    ports:
    - containerPort: 4444
    env:
    - name: JAVA_OPTS
      value: '-Dwebdriver.chrome.whitelistedIps=&quot;&quot;'
</code></pre>
